-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSettingsManager.h
224 lines (181 loc) · 8.23 KB
/
SettingsManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*!
* This file is part of OffloadBuddy.
* COPYRIGHT (C) 2020 Emeric Grange - All Rights Reserved
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* \date 2018
* \author Emeric Grange <[email protected]>
*/
#ifndef SETTINGS_MANAGER_H
#define SETTINGS_MANAGER_H
/* ************************************************************************** */
#include <QObject>
#include <QVariant>
#include <QList>
#include <QSize>
/* ************************************************************************** */
namespace SettingsUtils
{
Q_NAMESPACE
enum OrderBy
{
OrderByDate = 0,
OrderByDuration,
OrderByShotType,
OrderByName,
OrderByFilePath,
OrderBySize,
OrderByGps,
OrderByCamera,
};
Q_ENUM_NS(OrderBy)
}
/* ************************************************************************** */
/*!
* \brief The SettingsManager class
*
* Handle application settings, and syncing with associated settings file.
*/
class SettingsManager: public QObject
{
Q_OBJECT
Q_PROPERTY(bool firstLaunch READ isFirstLaunch NOTIFY firstLaunchChanged)
Q_PROPERTY(QSize initialSize READ getInitialSize NOTIFY initialSizeChanged)
Q_PROPERTY(QSize initialPosition READ getInitialPosition NOTIFY initialSizeChanged)
Q_PROPERTY(uint initialVisibility READ getInitialVisibility NOTIFY initialSizeChanged)
Q_PROPERTY(QString appTheme READ getAppTheme WRITE setAppTheme NOTIFY appThemeChanged)
Q_PROPERTY(bool appThemeAuto READ getAppThemeAuto WRITE setAppThemeAuto NOTIFY appThemeAutoChanged)
Q_PROPERTY(bool appThemeCSD READ getAppThemeCSD WRITE setAppThemeCSD NOTIFY appThemeCSDChanged)
Q_PROPERTY(uint appUnits READ getAppUnits WRITE setAppUnits NOTIFY appUnitsChanged)
Q_PROPERTY(QString appLanguage READ getAppLanguage WRITE setAppLanguage NOTIFY appLanguageChanged)
Q_PROPERTY(QString appOrientation READ getAppOrientation WRITE setAppOrientation NOTIFY appOrientationChanged)
Q_PROPERTY(uint thumbQuality READ getThumbQuality WRITE setThumbQuality NOTIFY thumbQualityChanged)
Q_PROPERTY(uint thumbFormat READ getThumbFormat WRITE setThumbFormat NOTIFY thumbFormatChanged)
Q_PROPERTY(uint thumbSize READ getThumbSize WRITE setThumbSize NOTIFY thumbSizeChanged)
Q_PROPERTY(bool autoMerge READ getAutoMerge WRITE setAutoMerge NOTIFY autoMergeChanged)
Q_PROPERTY(bool autoTelemetry READ getAutoTelemetry WRITE setAutoTelemetry NOTIFY autoTelemetryChanged)
Q_PROPERTY(bool autoDelete READ getAutoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged)
Q_PROPERTY(bool ignoreJunk READ getIgnoreJunk WRITE setIgnoreJunk NOTIFY ignoreJunkChanged)
Q_PROPERTY(bool ignoreHdAudio READ getIgnoreHdAudio WRITE setIgnoreHdAudio NOTIFY ignoreHdAudioChanged)
Q_PROPERTY(bool moveToTrash READ getMoveToTrash WRITE setMoveToTrash NOTIFY moveToTrashChanged)
Q_PROPERTY(bool mtpFullScan READ getMtpFullScan WRITE setMtpFullScan NOTIFY mtpFullScanChanged)
Q_PROPERTY(uint librarySortRole READ getLibrarySortRole WRITE setLibrarySortRole NOTIFY librarySortChanged)
Q_PROPERTY(uint librarySortOrder READ getLibrarySortOrder WRITE setLibrarySortOrder NOTIFY librarySortChanged)
Q_PROPERTY(uint deviceSortRole READ getDeviceSortRole WRITE setDeviceSortRole NOTIFY deviceSortChanged)
Q_PROPERTY(uint deviceSortOrder READ getDeviceSortOrder WRITE setDeviceSortOrder NOTIFY deviceSortChanged)
bool m_firstlaunch = true;
// Application window
QSize m_appSize;
QSize m_appPosition;
unsigned m_appVisibility = 1; //!< QWindow::Visibility
// Application generic
QString m_appTheme = "THEME_LIGHT_AND_WARM";
bool m_appThemeAuto = false;
bool m_appThemeCSD = false;
unsigned m_appUnits = 0; //!< QLocale::MeasurementSystem
QString m_appLanguage = "auto";
QString m_appOrientation = "locked";
// Application specific
unsigned m_thumbQuality = 1;
unsigned m_thumbFormat = 3;
unsigned m_thumbSize = 3;
bool m_ignoreJunk = true;
bool m_ignoreHdAudio = true;
bool m_autoMerge = false;
bool m_autoTelemetry = false;
bool m_autoDelete = false;
bool m_moveToTrash = false;
bool m_mtpFullScan = false;
unsigned m_librarySortRole = SettingsUtils::OrderByDate;
unsigned m_librarySortOrder = 1;
unsigned m_deviceSortRole = SettingsUtils::OrderByDate;
unsigned m_deviceSortOrder = 1;
// Saved settings
bool readSettings();
bool writeSettings();
// Singleton
static SettingsManager *instance;
SettingsManager();
~SettingsManager();
Q_SIGNALS:
void firstLaunchChanged();
void initialSizeChanged();
void appThemeChanged();
void appThemeAutoChanged();
void appThemeCSDChanged();
void appUnitsChanged();
void appLanguageChanged();
void appOrientationChanged();
void autoMergeChanged();
void autoTelemetryChanged();
void autoDeleteChanged();
void ignoreJunkChanged();
void ignoreHdAudioChanged();
void thumbQualityChanged();
void thumbFormatChanged();
void thumbSizeChanged();
void moveToTrashChanged();
void mtpFullScanChanged();
void librarySortChanged();
void deviceSortChanged();
public:
static SettingsManager *getInstance();
bool isFirstLaunch() const { return m_firstlaunch; }
QSize getInitialSize() { return m_appSize; }
QSize getInitialPosition() { return m_appPosition; }
unsigned getInitialVisibility() { return m_appVisibility; }
QString getAppTheme() const { return m_appTheme; }
void setAppTheme(const QString &value);
bool getAppThemeAuto() const { return m_appThemeAuto; }
void setAppThemeAuto(const bool value);
bool getAppThemeCSD() const { return m_appThemeCSD; }
void setAppThemeCSD(const bool value);
unsigned getAppUnits() const { return m_appUnits; }
void setAppUnits(const unsigned value);
QString getAppLanguage() const { return m_appLanguage; }
void setAppLanguage(const QString &value);
QString getAppOrientation() const { return m_appOrientation; }
void setAppOrientation(const QString &value);
bool getAutoMerge() const { return m_autoMerge; }
void setAutoMerge(const bool value);
bool getAutoTelemetry() const { return m_autoTelemetry; }
void setAutoTelemetry(const bool value);
bool getAutoDelete() const { return m_autoDelete; }
void setAutoDelete(const bool value);
bool getIgnoreJunk() const { return m_ignoreJunk; }
void setIgnoreJunk(const bool value);
bool getIgnoreHdAudio() const { return m_ignoreHdAudio; }
void setIgnoreHdAudio(const bool value);
unsigned getThumbQuality() const { return m_thumbQuality; }
void setThumbQuality(const unsigned value);
unsigned getThumbFormat() const { return m_thumbFormat; }
void setThumbFormat(const unsigned value);
unsigned getThumbSize() const { return m_thumbSize; }
void setThumbSize(const unsigned value);
bool getMoveToTrash() const { return m_moveToTrash; }
void setMoveToTrash(const bool value);
bool getMtpFullScan() const { return m_mtpFullScan; }
void setMtpFullScan(const bool value);
unsigned getLibrarySortRole() const { return m_librarySortRole; }
void setLibrarySortRole(const unsigned order);
unsigned getLibrarySortOrder() const { return m_librarySortOrder; }
void setLibrarySortOrder(const unsigned order);
unsigned getDeviceSortRole() const { return m_deviceSortRole; }
void setDeviceSortRole(const unsigned order);
unsigned getDeviceSortOrder() const { return m_deviceSortOrder; }
void setDeviceSortOrder(const unsigned order);
};
/* ************************************************************************** */
#endif // SETTINGS_MANAGER_H