LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
application.h
Go to the documentation of this file.
1 /*
2  * LibrePCB - Professional EDA for everyone!
3  * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4  * https://librepcb.org/
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef LIBREPCB_APPLICATION_H
21 #define LIBREPCB_APPLICATION_H
22 
23 /*******************************************************************************
24  * Includes
25  ******************************************************************************/
26 #include "fileio/filepath.h"
27 #include "version.h"
28 
29 #include <QApplication>
30 #include <QFont>
31 #include <QtCore>
32 
33 /*******************************************************************************
34  * Namespace / Forward Declarations
35  ******************************************************************************/
36 namespace librepcb {
37 
38 class StrokeFont;
39 class StrokeFontPool;
40 
41 /*******************************************************************************
42  * Macros
43  ******************************************************************************/
44 #if defined(qApp)
45 #undef qApp
46 #endif
47 #define qApp (Application::instance())
48 
49 /*******************************************************************************
50  * Class Application
51  ******************************************************************************/
52 
57 class Application final : public QApplication {
58  Q_OBJECT
59 
60 public:
61  // Constructors / Destructor
62  Application() = delete;
63  Application(const Application& other) = delete;
64  Application(int& argc, char** argv) noexcept;
65  ~Application() noexcept;
66 
67  // Getters
68  const Version& getAppVersion() const noexcept { return mAppVersion; }
69  const QString& getAppVersionLabel() const noexcept {
70  return mAppVersionLabel;
71  }
72  const QString& getGitRevision() const noexcept { return mGitRevision; }
73  const QDateTime& getBuildDate() const noexcept { return mBuildDate; }
74  const Version& getFileFormatVersion() const noexcept {
75  return mFileFormatVersion;
76  }
77  bool isFileFormatStable() const noexcept { return mIsFileFormatStable; }
78  const FilePath& getResourcesDir() const noexcept { return mResourcesDir; }
79  FilePath getResourcesFilePath(const QString& filepath) const noexcept;
80  const QFont& getDefaultSansSerifFont() const noexcept {
81  return mSansSerifFont;
82  }
83  const QFont& getDefaultMonospaceFont() const noexcept {
84  return mMonospaceFont;
85  }
86  const StrokeFontPool& getStrokeFonts() const noexcept {
87  return *mStrokeFontPool;
88  }
89  QString getDefaultStrokeFontName() const noexcept { return "newstroke.bene"; }
90  const StrokeFont& getDefaultStrokeFont() const noexcept;
91 
92  // Reimplemented from QApplication
93  bool notify(QObject* receiver, QEvent* e);
94 
95  // Operator Overloadings
96  Application& operator=(const Application& rhs) = delete;
97 
98  // Static Methods
99  static Application* instance() noexcept;
100 
101 public slots:
102  static void about() noexcept;
103 
104 private: // Data
107  QString mGitRevision;
108  QDateTime mBuildDate;
112  QScopedPointer<StrokeFontPool>
116 };
117 
118 /*******************************************************************************
119  * End of File
120  ******************************************************************************/
121 
122 } // namespace librepcb
123 
124 #endif // LIBREPCB_APPLICATION_H
FilePath mResourcesDir
Definition: application.h:111
static Application * instance() noexcept
Definition: application.cpp:208
The Version class represents a version number in the format "1.42.7".
Definition: version.h:60
const QString & getAppVersionLabel() const noexcept
Definition: application.h:69
const StrokeFontPool & getStrokeFonts() const noexcept
Definition: application.h:86
QFont mMonospaceFont
Definition: application.h:115
const QFont & getDefaultSansSerifFont() const noexcept
Definition: application.h:80
QDateTime mBuildDate
Definition: application.h:108
const Version & getFileFormatVersion() const noexcept
Definition: application.h:74
QString getDefaultStrokeFontName() const noexcept
Definition: application.h:89
FilePath getResourcesFilePath(const QString &filepath) const noexcept
Definition: application.cpp:177
const QFont & getDefaultMonospaceFont() const noexcept
Definition: application.h:83
QString mGitRevision
Definition: application.h:107
Version mFileFormatVersion
Definition: application.h:109
QFont mSansSerifFont
Definition: application.h:114
bool isFileFormatStable() const noexcept
Definition: application.h:77
bool notify(QObject *receiver, QEvent *e)
Definition: application.cpp:195
const QDateTime & getBuildDate() const noexcept
Definition: application.h:73
static void about() noexcept
Definition: application.cpp:218
QString mAppVersionLabel
Definition: application.h:106
const StrokeFont & getDefaultStrokeFont() const noexcept
Definition: application.cpp:182
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
const QString & getGitRevision() const noexcept
Definition: application.h:72
~Application() noexcept
Definition: application.cpp:170
Version mAppVersion
Definition: application.h:105
const FilePath & getResourcesDir() const noexcept
Definition: application.h:78
QScopedPointer< StrokeFontPool > mStrokeFontPool
all application stroke fonts
Definition: application.h:113
The StrokeFontPool class.
Definition: strokefontpool.h:46
The StrokeFont class.
Definition: strokefont.h:52
bool mIsFileFormatStable
Definition: application.h:110
const Version & getAppVersion() const noexcept
Definition: application.h:68
The Application class extends the QApplication with the exception-safe method notify() ...
Definition: application.h:57