openPilotLog
astyle.h
1 /*
2  *openPilotLog - A FOSS Pilot Logbook Application
3  *Copyright (C) 2020-2021 Felix Turowsky
4  *
5  *This program is free software: you can redistribute it and/or modify
6  *it under the terms of the GNU General Public License as published by
7  *the Free Software Foundation, either version 3 of the License, or
8  *(at your option) any later version.
9  *
10  *This program is distributed in the hope that it will be useful,
11  *but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *GNU General Public License for more details.
14  *
15  *You should have received a copy of the GNU General Public License
16  *along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 #ifndef ASTYLE_H
19 #define ASTYLE_H
20 #include <QString>
21 #include <QFileInfo>
22 #include <QMap>
23 #include <QTextStream>
24 
29 struct StyleSheet
30 {
31  StyleSheet(QLatin1String style_sheet_name, QLatin1String file_name)
32  : styleSheetName(style_sheet_name), fileName(file_name)
33  {}
34  QLatin1String styleSheetName;
35  QLatin1String fileName;
36 };
37 
38 static inline QString read_stylesheet(const QString &stylesheet)
39 {
40  QFile file(stylesheet);
41  file.open(QFile::ReadOnly | QFile::Text);
42  QTextStream stream(&file);
43  return stream.readAll();
44 }
45 
49 class AStyle
50 {
51 private:
52  static QString currentStyle;
53  static void resetStyle();
54 public:
55  static const QStringList styles;
56  static const QString defaultStyle;
57  static const QList<StyleSheet> styleSheets;
58 
59  static void setup();
60  static void setStyle(const QString &style_key);
61  static void setStyle(const StyleSheet &style_sheet);
62  static void setStyle(const QPalette &palette);
63  static QPalette darkPalette();
64  static const QString& style();
65 };
66 
67 #endif // ASTYLE_H
StyleSheet
The StyleSheet struct holds the Display Name and File Name (in the resource system) for the available...
Definition: astyle.h:30
AStyle::setup
static void setup()
Setup Application style by reading from openPilotLog.ini.
Definition: astyle.cpp:47
AStyle
The AStyle class encapsulates style and stylesheet logic.
Definition: astyle.h:50