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 
60 class Application final : public QApplication {
61  Q_OBJECT
62 
63 public:
64  // Constructors / Destructor
65  Application() = delete;
66  Application(const Application& other) = delete;
67  Application(int& argc, char** argv) noexcept;
68  ~Application() noexcept;
69 
70  // Getters
71  const Version& getAppVersion() const noexcept { return mAppVersion; }
72  const QString& getAppVersionLabel() const noexcept {
73  return mAppVersionLabel;
74  }
75  const QString& getGitRevision() const noexcept { return mGitRevision; }
76  const QDateTime& getBuildDate() const noexcept { return mBuildDate; }
77  const Version& getFileFormatVersion() const noexcept {
78  return mFileFormatVersion;
79  }
80  bool isFileFormatStable() const noexcept { return mIsFileFormatStable; }
81  const FilePath& getResourcesDir() const noexcept { return mResourcesDir; }
82  FilePath getResourcesFilePath(const QString& filepath) const noexcept;
83  const QFont& getDefaultSansSerifFont() const noexcept {
84  return mSansSerifFont;
85  }
86  const QFont& getDefaultMonospaceFont() const noexcept {
87  return mMonospaceFont;
88  }
89  const StrokeFontPool& getStrokeFonts() const noexcept {
90  return *mStrokeFontPool;
91  }
92  QString getDefaultStrokeFontName() const noexcept { return "newstroke.bene"; }
93  const StrokeFont& getDefaultStrokeFont() const noexcept;
94 
95  // Reimplemented from QApplication
96  bool notify(QObject* receiver, QEvent* e);
97 
98  // Operator Overloadings
99  Application& operator=(const Application& rhs) = delete;
100 
101  // Static Methods
102  static Application* instance() noexcept;
103 
104 public slots:
105  static void about() noexcept;
106 
107 private: // Data
110  QString mGitRevision;
111  QDateTime mBuildDate;
115  QScopedPointer<StrokeFontPool>
119 };
120 
121 /*******************************************************************************
122  * End of File
123  ******************************************************************************/
124 
125 } // namespace librepcb
126 
127 #endif // LIBREPCB_APPLICATION_H
FilePath mResourcesDir
Definition: application.h:114
static Application * instance() noexcept
Definition: application.cpp:206
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:72
const StrokeFontPool & getStrokeFonts() const noexcept
Definition: application.h:89
QFont mMonospaceFont
Definition: application.h:118
const QFont & getDefaultSansSerifFont() const noexcept
Definition: application.h:83
QDateTime mBuildDate
Definition: application.h:111
const Version & getFileFormatVersion() const noexcept
Definition: application.h:77
QString getDefaultStrokeFontName() const noexcept
Definition: application.h:92
FilePath getResourcesFilePath(const QString &filepath) const noexcept
Definition: application.cpp:175
const QFont & getDefaultMonospaceFont() const noexcept
Definition: application.h:86
QString mGitRevision
Definition: application.h:110
Version mFileFormatVersion
Definition: application.h:112
QFont mSansSerifFont
Definition: application.h:117
bool isFileFormatStable() const noexcept
Definition: application.h:80
bool notify(QObject *receiver, QEvent *e)
Definition: application.cpp:193
const QDateTime & getBuildDate() const noexcept
Definition: application.h:76
static void about() noexcept
Definition: application.cpp:216
QString mAppVersionLabel
Definition: application.h:109
const StrokeFont & getDefaultStrokeFont() const noexcept
Definition: application.cpp:180
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:130
const QString & getGitRevision() const noexcept
Definition: application.h:75
~Application() noexcept
Definition: application.cpp:168
Version mAppVersion
Definition: application.h:108
const FilePath & getResourcesDir() const noexcept
Definition: application.h:81
QScopedPointer< StrokeFontPool > mStrokeFontPool
all application stroke fonts
Definition: application.h:116
The StrokeFontPool class.
Definition: strokefontpool.h:46
The StrokeFont class.
Definition: strokefont.h:52
bool mIsFileFormatStable
Definition: application.h:113
const Version & getAppVersion() const noexcept
Definition: application.h:71
The Application class extends the QApplication with the exception-safe method notify() ...
Definition: application.h:60