Enroute Flight Navigation
A navigation app for VFR pilots
GlobalSettings.h
1/***************************************************************************
2 * Copyright (C) 2019-2024 by Stefan Kebekus *
3 * stefan.kebekus@gmail.com *
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, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21#pragma once
22
23#include <QProperty>
24#include <QQmlEngine>
25#include <QSettings>
26
27#include "GlobalObject.h"
28#include "notification/Notification.h"
29#include "units/ByteSize.h"
30#include "units/Distance.h"
31
32
44
45class GlobalSettings : public QObject
46{
47 Q_OBJECT
48 QML_ELEMENT
49 QML_SINGLETON
50
51public:
59 Q_ENUM(MapBearingPolicy)
60
61
62 //
63 // Constructor and destructor
64 //
65
66
70 explicit GlobalSettings(QObject *parent = nullptr);
71
72 // No default constructor, important for QML singleton
73 explicit GlobalSettings() = delete;
74
75 // Standard Destructor
76 ~GlobalSettings() override = default;
77
78 // factory function for QML singleton
79 static GlobalSettings* create(QQmlEngine * /*unused*/, QJSEngine * /*unused*/)
80 {
82 }
83
84
85 //
86 // Properties
87 //
88
91
92
100
108
113 Q_PROPERTY(Units::Distance airspaceAltitudeLimit_min MEMBER airspaceAltitudeLimit_min CONSTANT)
114
119 Q_PROPERTY(Units::Distance airspaceAltitudeLimit_max MEMBER airspaceAltitudeLimit_max CONSTANT)
120
123
128 Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
129
132
135
138
145
152
155
157 Q_PROPERTY(bool nightMode READ nightMode WRITE setNightMode NOTIFY nightModeChanged)
158
161
167 Q_PROPERTY(Units::ByteSize privacyHash READ privacyHash WRITE setPrivacyHash NOTIFY privacyHashChanged)
168
171
178
179
180 //
181 // Getter Methods
182 //
183
188 [[nodiscard]] auto acceptedTerms() const -> int { return m_settings.value(QStringLiteral("acceptedTerms"), 0).toInt(); }
189
194 [[nodiscard]] bool alwaysOpenExternalWebsites() const { return m_settings.value(QStringLiteral("alwaysOpenExternalWebsites"), false).toBool(); }
195
200 [[nodiscard]] auto airspaceAltitudeLimit() const -> Units::Distance;
201
206 [[nodiscard]] bool expandNotamAbbreviations() const { return m_settings.value(QStringLiteral("expandNotamAbbreviations"), false).toBool(); }
207
212 [[nodiscard]] auto fontSize() const -> int;
213
218 [[nodiscard]] auto hideGlidingSectors() const -> bool { return m_settings.value(QStringLiteral("Map/hideGlidingSectors"), true).toBool(); }
219
224 [[nodiscard]] auto ignoreSSLProblems() const -> bool { return m_settings.value(QStringLiteral("ignoreSSLProblems"), false).toBool(); }
225
230 [[nodiscard]] auto lastValidAirspaceAltitudeLimit() const -> Units::Distance;
231
236 [[nodiscard]] auto lastWhatsNewHash() const -> Units::ByteSize
237 {
238 return m_settings.value(QStringLiteral("lastWhatsNewHash"), 0).value<size_t>();
239 }
240
245 [[nodiscard]] auto lastWhatsNewInMapsHash() const -> Units::ByteSize
246 {
247 return m_settings.value(QStringLiteral("lastWhatsNewInMapsHash"), 0).value<size_t>();
248 }
249
254 [[nodiscard]] auto mapBearingPolicy() const -> MapBearingPolicy;
255
260 [[nodiscard]] auto nightMode() const -> bool { return m_settings.value(QStringLiteral("Map/nightMode"), false).toBool(); }
261
266 [[nodiscard]] bool positioningByTrafficDataReceiver() const { return m_positioningByTrafficDataReceiver.value(); }
267
272 [[nodiscard]] QBindable<bool> bindablePositioningByTrafficDataReceiver() const { return &m_positioningByTrafficDataReceiver; }
273
278 [[nodiscard]] auto privacyHash() const -> Units::ByteSize { return m_settings.value(QStringLiteral("privacyHash"), 0).value<size_t>(); }
279
284 [[nodiscard]] auto showAltitudeAGL() const -> bool { return m_settings.value(QStringLiteral("showAltitudeAGL"), false).toBool(); }
285
290 [[nodiscard]] auto voiceNotifications() const -> uint
291 {
292 return m_settings.value(QStringLiteral("voiceNotifications"),
297 }
298
299
300 //
301 // Setter Methods
302 //
303
308 void setAcceptedTerms(int terms);
309
314 void setAlwaysOpenExternalWebsites(bool alwaysOpen);
315
324 void setAirspaceAltitudeLimit(Units::Distance newAirspaceAltitudeLimit);
325
330 void setExpandNotamAbbreviations(bool newExpandNotamAbbreviations);
331
336 void setHideGlidingSectors(bool hide);
337
342 void setFontSize(int newFontSize);
343
348 void setIgnoreSSLProblems(bool ignore);
349
354 void setLargeFonts(bool newLargeFonts);
355
361
367
373
378 void setNightMode(bool newNightMode);
379
384 void setPositioningByTrafficDataReceiver(bool newPositioningByTrafficDataReceiver);
385
391
396 void setShowAltitudeAGL(bool newShowAltitudeAGL);
397
402 void setVoiceNotifications(uint newVoiceNotifications);
403
404
405 //
406 // Constants
407 //
408
411
412signals:
415
418
421
424
427
430
433
436
439
442
445
448
451
454
457
458private:
459 Q_DISABLE_COPY_MOVE(GlobalSettings)
460
461 QSettings m_settings;
462
463 QProperty<bool> m_positioningByTrafficDataReceiver;
464};
static Q_INVOKABLE GlobalSettings * globalSettings()
Pointer to appplication-wide static Settings instance.
GlobalSettings(QObject *parent=nullptr)
Standard constructor.
void setShowAltitudeAGL(bool newShowAltitudeAGL)
Setter function for property of the same name.
void lastWhatsNewInMapsHashChanged()
Notifier signal.
void setLastWhatsNewHash(Units::ByteSize lwnh)
Getter function for property of the same name.
bool expandNotamAbbreviations
Should we expand notam abbreviations.
void setFontSize(int newFontSize)
Setter function for property of the same name.
uint voiceNotifications
Voice notifications that should be played.
bool ignoreSSLProblems
Ignore SSL security problems.
bool nightMode
Night mode.
bool alwaysOpenExternalWebsites
Privacy setting: always open external web sites.
bool positioningByTrafficDataReceiver
Use traffic data receiver for positioning.
bool positioningByTrafficDataReceiver() const
Getter function for property of the same name.
void setLargeFonts(bool newLargeFonts)
Getter function for property of the same name.
Units::Distance airspaceAltitudeLimit
Airspace altitude limit for map display.
QBindable< bool > bindablePositioningByTrafficDataReceiver() const
Getter function for property of the same name.
Units::Distance airspaceAltitudeLimit_max
Maximum acceptable value for property airspaceAltitudeLimit.
Units::ByteSize lastWhatsNewHash
Hash of the last "what's new" message that was shown to the user.
void setPositioningByTrafficDataReceiver(bool newPositioningByTrafficDataReceiver)
Setter function for property of the same name.
auto voiceNotifications() const -> uint
Getter function for property of the same name.
void airspaceAltitudeLimitChanged()
Notifier signal.
void privacyHashChanged()
Notifier signal.
MapBearingPolicy mapBearingPolicy
Map bearing policy.
void fontSizeChanged()
Notifier signal.
auto airspaceAltitudeLimit() const -> Units::Distance
Getter function for property of the same name.
auto lastWhatsNewInMapsHash() const -> Units::ByteSize
Getter function for property of the same name.
void alwaysOpenExternalWebsitesChanged()
Notifier signal.
void setNightMode(bool newNightMode)
Setter function for property of the same name.
void showAltitudeAGLChanged()
Notifier signal.
MapBearingPolicy
Possible map bearing policies.
void setLastWhatsNewInMapsHash(Units::ByteSize lwnh)
Getter function for property of the same name.
auto mapBearingPolicy() const -> MapBearingPolicy
Getter function for property of the same name.
void ignoreSSLProblemsChanged()
Notifier signal.
void setExpandNotamAbbreviations(bool newExpandNotamAbbreviations)
Setter function for property of the same name.
Units::ByteSize privacyHash
Hash of the last "privacy" message that was accepted by the user.
void lastWhatsNewHashChanged()
Notifier signal.
auto privacyHash() const -> Units::ByteSize
Getter function for property of the same name.
auto lastValidAirspaceAltitudeLimit() const -> Units::Distance
Getter function for property with the same name.
bool alwaysOpenExternalWebsites() const
Getter function for property of the same name.
void mapBearingPolicyChanged()
Notifier signal.
void setVoiceNotifications(uint newVoiceNotifications)
Setter function for property of the same name.
void setAirspaceAltitudeLimit(Units::Distance newAirspaceAltitudeLimit)
Setter function for property of the same name.
void voiceNotificationsChanged()
Notifier signal.
void setPrivacyHash(Units::ByteSize newHash)
Getter function for property of the same name.
bool hideGlidingSectors
Hide gliding sectors.
void expandNotamAbbreviationsChanged()
Notifier signal.
void setIgnoreSSLProblems(bool ignore)
Setter function for property of the same name.
void acceptedTermsChanged()
Notifier signal.
void setHideGlidingSectors(bool hide)
Setter function for property of the same name.
int fontSize
Font size.
void hideGlidingSectorsChanged()
Notifier signal.
void setAcceptedTerms(int terms)
Setter function for property of the same name.
void setMapBearingPolicy(MapBearingPolicy policy)
Setter function for property of the same name.
void setAlwaysOpenExternalWebsites(bool alwaysOpen)
Setter function for property of the same name.
auto showAltitudeAGL() const -> bool
Getter function for property of the same name.
auto ignoreSSLProblems() const -> bool
Getter function for property of the same name.
void nightModeChanged()
Notifier signal.
int acceptedTerms
Find out if Terms & Conditions have been accepted.
Units::ByteSize lastWhatsNewInMapsHash
Hash of the last "what's new in maps" message that was shown to the user.
Units::Distance airspaceAltitudeLimit_min
Minimum acceptable value for property airspaceAltitudeLimit.
bool showAltitudeAGL
Show Altitude AGL.
void lastValidAirspaceAltitudeLimitChanged()
Notifier signal.
Units::Distance lastValidAirspaceAltitudeLimit
Last finite value of airspaceAltitudeLimit.
auto fontSize() const -> int
Getter function for property with the same name.
@ Warning_Navigation
Serious warning, "Prohibited Airspace 1 minutes ahead".
@ Info_Navigation
Information pertaining to navigation, "Top of descent reached".
@ Alert
Alert. Immediate action is required to avoid accident or serious rule infringion.
@ Warning
Generic warning, "Traffic data receiver inop".
Convenience class for size_t.
Definition ByteSize.h:37
Convenience class for distance computations.
Definition Distance.h:35
static Q_INVOKABLE constexpr Units::Distance fromFT(double distanceInFT)
Constructs a distance.
Definition Distance.h:108
Conversion between units used in aviation.
Definition Angle.h:34