-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSettingsManager.cpp
More file actions
144 lines (117 loc) · 4.27 KB
/
SettingsManager.cpp
File metadata and controls
144 lines (117 loc) · 4.27 KB
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
#include "SettingsManager.h"
/*
* QSettings API:
* m_settings.value(key, default) - Reads value from storage, returns default if not found
* m_settings.setValue(key, value) - Writes value to storage (auto-saves to disk)
*/
// Constructor - initializes QSettings with organization/app name for storage path
SettingsManager::SettingsManager(QObject *parent)
: QObject(parent)
, m_settings("GCS", "GroundControlStation")
{
}
SettingsManager::~SettingsManager()
{
}
// =============================================================================
// APPEARANCE SETTINGS
// =============================================================================
QString SettingsManager::currentTheme() const {
return m_settings.value("appearance/theme", "dark").toString();
}
void SettingsManager::setCurrentTheme(const QString &theme) {
if (currentTheme() != theme) {
m_settings.setValue("appearance/theme", theme);
emit currentThemeChanged();
}
}
int SettingsManager::textSizeBase() const {
return m_settings.value("appearance/textSizeBase", 12).toInt();
}
void SettingsManager::setTextSizeBase(int size) {
if (textSizeBase() != size) {
m_settings.setValue("appearance/textSizeBase", size);
emit textSizeBaseChanged();
}
}
QString SettingsManager::fontFamily() const {
return m_settings.value("appearance/fontFamily", "Arial").toString();
}
void SettingsManager::setFontFamily(const QString &family) {
if (fontFamily() != family) {
m_settings.setValue("appearance/fontFamily", family);
emit fontFamilyChanged();
}
}
// =============================================================================
// LOGGING SETTINGS
// =============================================================================
bool SettingsManager::logAutoScroll() const {
return m_settings.value("logging/autoScroll", true).toBool();
}
void SettingsManager::setLogAutoScroll(bool enabled) {
if (logAutoScroll() != enabled) {
m_settings.setValue("logging/autoScroll", enabled);
emit logAutoScrollChanged();
}
}
// =============================================================================
// STARTUP SETTINGS
// =============================================================================
double SettingsManager::homeLat() const {
return m_settings.value("startup/homeLat", 34.059174611493965).toDouble();
}
void SettingsManager::setHomeLat(double lat) {
if (homeLat() != lat) {
m_settings.setValue("startup/homeLat", lat);
emit homeLatChanged();
}
}
double SettingsManager::homeLong() const {
return m_settings.value("startup/homeLong", -117.82051240067321).toDouble();
}
void SettingsManager::setHomeLong(double lon) {
if (homeLong() != lon) {
m_settings.setValue("startup/homeLong", lon);
emit homeLongChanged();
}
}
bool SettingsManager::leaveAtLastMapLocation() const {
return m_settings.value("startup/leaveAtLastMapLocation", false).toBool();
}
void SettingsManager::setLeaveAtLastMapLocation(bool enabled) {
if (leaveAtLastMapLocation() != enabled) {
m_settings.setValue("startup/leaveAtLastMapLocation", enabled);
emit leaveAtLastMapLocationChanged();
}
}
// =============================================================================
// LAST MAP POSITION (for "leave at last location" feature)
// =============================================================================
double SettingsManager::lastMapLat() const {
return m_settings.value("map/lastLat", 34.059174611493965).toDouble();
}
void SettingsManager::setLastMapLat(double lat) {
if (lastMapLat() != lat) {
m_settings.setValue("map/lastLat", lat);
emit lastMapLatChanged();
}
}
double SettingsManager::lastMapLong() const {
return m_settings.value("map/lastLong", -117.82051240067321).toDouble();
}
void SettingsManager::setLastMapLong(double lon) {
if (lastMapLong() != lon) {
m_settings.setValue("map/lastLong", lon);
emit lastMapLongChanged();
}
}
double SettingsManager::lastMapZoom() const {
return m_settings.value("map/lastZoom", 16.0).toDouble();
}
void SettingsManager::setLastMapZoom(double zoom) {
if (lastMapZoom() != zoom) {
m_settings.setValue("map/lastZoom", zoom);
emit lastMapZoomChanged();
}
}