Skip to content

Commit

Permalink
Merge branch 'feature/cleanup' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kebekus committed Dec 8, 2024
2 parents c4e3546 + a20e92f commit 19cf398
Show file tree
Hide file tree
Showing 32 changed files with 612 additions and 570 deletions.
2 changes: 1 addition & 1 deletion src/AndroidManifest.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
<meta-data android:name="android.app.lib_name" android:value="enroute"/>

<!-- Messages maps -->
<meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/>
<!-- meta-data android:value="@string/unsupported_android_version" android:name="android.app.unsupported_android_version"/ -->
<!-- Messages maps -->

<!-- Splash screen -->
Expand Down
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ qt_add_qml_module(${PROJECT_NAME}
URI akaflieg_freiburg.enroute
VERSION 1.0
NO_RESOURCE_TARGET_PATH
DEPENDENCIES
QtQuick
QML_FILES
qml/main.qml
qml/dialogs/AddBTDeviceDialog.qml
Expand Down Expand Up @@ -624,7 +626,6 @@ qt_add_qml_module(${PROJECT_NAME}
traffic/TrafficDataProvider_BluetoothLowEnergy.cpp
)


#
# Translations
#
Expand Down
62 changes: 30 additions & 32 deletions src/GlobalSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ GlobalSettings::GlobalSettings(QObject *parent)
QCoreApplication::processEvents();

// Save some values
settings.setValue(QStringLiteral("lastVersion"), ENROUTE_VERSION_STRING);
m_settings.setValue(QStringLiteral("lastVersion"), ENROUTE_VERSION_STRING);

// Read values
m_positioningByTrafficDataReceiver = m_settings.value(QStringLiteral("positioningByTrafficDataReceiver"), false).toBool();

// Convert old setting to new system
if (settings.contains(QStringLiteral("Map/hideUpperAirspaces"))) {
auto hide = settings.value(QStringLiteral("Map/hideUpperAirspaces"), false).toBool();
if (m_settings.contains(QStringLiteral("Map/hideUpperAirspaces"))) {
auto hide = m_settings.value(QStringLiteral("Map/hideUpperAirspaces"), false).toBool();
if (hide) {
setAirspaceAltitudeLimit( Units::Distance::fromFT(10000) );
} else {
setAirspaceAltitudeLimit( Units::Distance::fromFT(qInf()) );
}
settings.remove(QStringLiteral("Map/hideUpperAirspaces"));
m_settings.remove(QStringLiteral("Map/hideUpperAirspaces"));
}
}

Expand All @@ -56,7 +59,7 @@ GlobalSettings::GlobalSettings(QObject *parent)

auto GlobalSettings::airspaceAltitudeLimit() const -> Units::Distance
{
auto aspAlttLimit = Units::Distance::fromFT( settings.value(QStringLiteral("Map/airspaceAltitudeLimit_ft"), qQNaN()).toDouble() );
auto aspAlttLimit = Units::Distance::fromFT( m_settings.value(QStringLiteral("Map/airspaceAltitudeLimit_ft"), qQNaN()).toDouble() );
if (aspAlttLimit < airspaceAltitudeLimit_min) {
aspAlttLimit = airspaceAltitudeLimit_min;
}
Expand All @@ -69,21 +72,21 @@ auto GlobalSettings::airspaceAltitudeLimit() const -> Units::Distance

auto GlobalSettings::fontSize() const -> int
{
auto fontSize = settings.value(QStringLiteral("fontSize"), 14).toInt();
auto fontSize = m_settings.value(QStringLiteral("fontSize"), 14).toInt();
return qBound(14, fontSize, 20);
}


auto GlobalSettings::lastValidAirspaceAltitudeLimit() const -> Units::Distance
{
auto result = Units::Distance::fromFT(settings.value(QStringLiteral("Map/lastValidAirspaceAltitudeLimit_ft"), 99999).toInt() );
auto result = Units::Distance::fromFT(m_settings.value(QStringLiteral("Map/lastValidAirspaceAltitudeLimit_ft"), 99999).toInt() );
return qBound(airspaceAltitudeLimit_min, result, airspaceAltitudeLimit_max);
}


auto GlobalSettings::mapBearingPolicy() const -> GlobalSettings::MapBearingPolicy
{
auto intVal = settings.value(QStringLiteral("Map/bearingPolicy"), 0).toInt();
auto intVal = m_settings.value(QStringLiteral("Map/bearingPolicy"), 0).toInt();
if (intVal == 0) {
return NUp;
}
Expand All @@ -103,7 +106,7 @@ void GlobalSettings::setAcceptedTerms(int terms)
if (terms == acceptedTerms()) {
return;
}
settings.setValue(QStringLiteral("acceptedTerms"), terms);
m_settings.setValue(QStringLiteral("acceptedTerms"), terms);
emit acceptedTermsChanged();
}

Expand All @@ -113,7 +116,7 @@ void GlobalSettings::setAlwaysOpenExternalWebsites(bool alwaysOpen)
if (alwaysOpen == alwaysOpenExternalWebsites()) {
return;
}
settings.setValue(QStringLiteral("alwaysOpenExternalWebsites"), alwaysOpen);
m_settings.setValue(QStringLiteral("alwaysOpenExternalWebsites"), alwaysOpen);
emit alwaysOpenExternalWebsitesChanged();
}

Expand All @@ -128,13 +131,13 @@ void GlobalSettings::setAirspaceAltitudeLimit(Units::Distance newAirspaceAltitud
}

if (newAirspaceAltitudeLimit != airspaceAltitudeLimit()) {
settings.setValue(QStringLiteral("Map/airspaceAltitudeLimit_ft"), newAirspaceAltitudeLimit.toFeet());
m_settings.setValue(QStringLiteral("Map/airspaceAltitudeLimit_ft"), newAirspaceAltitudeLimit.toFeet());
emit airspaceAltitudeLimitChanged();
}

if (newAirspaceAltitudeLimit.isFinite() &&
(newAirspaceAltitudeLimit != lastValidAirspaceAltitudeLimit())) {
settings.setValue(QStringLiteral("Map/lastValidAirspaceAltitudeLimit_ft"), newAirspaceAltitudeLimit.toFeet());
m_settings.setValue(QStringLiteral("Map/lastValidAirspaceAltitudeLimit_ft"), newAirspaceAltitudeLimit.toFeet());
emit lastValidAirspaceAltitudeLimitChanged();
}
}
Expand All @@ -146,7 +149,7 @@ void GlobalSettings::setExpandNotamAbbreviations(bool newExpandNotamAbbreviation
{
return;
}
settings.setValue(QStringLiteral("expandNotamAbbreviations"), newExpandNotamAbbreviations);
m_settings.setValue(QStringLiteral("expandNotamAbbreviations"), newExpandNotamAbbreviations);
emit expandNotamAbbreviationsChanged();
}

Expand All @@ -160,7 +163,7 @@ void GlobalSettings::setFontSize(int newFontSize)
{
return;
}
settings.setValue(QStringLiteral("fontSize"), newFontSize);
m_settings.setValue(QStringLiteral("fontSize"), newFontSize);
emit fontSizeChanged();
}

Expand All @@ -171,7 +174,7 @@ void GlobalSettings::setHideGlidingSectors(bool hide)
{
return;
}
settings.setValue(QStringLiteral("Map/hideGlidingSectors"), hide);
m_settings.setValue(QStringLiteral("Map/hideGlidingSectors"), hide);
emit hideGlidingSectorsChanged();
}

Expand All @@ -182,7 +185,7 @@ void GlobalSettings::setIgnoreSSLProblems(bool ignore)
{
return;
}
settings.setValue(QStringLiteral("ignoreSSLProblems"), ignore);
m_settings.setValue(QStringLiteral("ignoreSSLProblems"), ignore);
emit ignoreSSLProblemsChanged();
}

Expand All @@ -193,7 +196,7 @@ void GlobalSettings::setLastWhatsNewHash(Units::ByteSize lwnh)
{
return;
}
settings.setValue(QStringLiteral("lastWhatsNewHash"), QVariant::fromValue((size_t)lwnh));
m_settings.setValue(QStringLiteral("lastWhatsNewHash"), QVariant::fromValue((size_t)lwnh));
emit lastWhatsNewHashChanged();
}

Expand All @@ -204,7 +207,7 @@ void GlobalSettings::setLastWhatsNewInMapsHash(Units::ByteSize lwnh)
{
return;
}
settings.setValue(QStringLiteral("lastWhatsNewInMapsHash"), QVariant::fromValue((size_t)lwnh));
m_settings.setValue(QStringLiteral("lastWhatsNewInMapsHash"), QVariant::fromValue((size_t)lwnh));
emit lastWhatsNewInMapsHashChanged();
}

Expand All @@ -215,7 +218,7 @@ void GlobalSettings::setPrivacyHash(Units::ByteSize newHash)
{
return;
}
settings.setValue(QStringLiteral("privacyHash"), QVariant::fromValue((size_t)newHash));
m_settings.setValue(QStringLiteral("privacyHash"), QVariant::fromValue((size_t)newHash));
emit privacyHashChanged();
}

Expand All @@ -229,13 +232,13 @@ void GlobalSettings::setMapBearingPolicy(MapBearingPolicy policy)

switch(policy){
case NUp:
settings.setValue(QStringLiteral("Map/bearingPolicy"), 0);
m_settings.setValue(QStringLiteral("Map/bearingPolicy"), 0);
break;
case TTUp:
settings.setValue(QStringLiteral("Map/bearingPolicy"), 1);
m_settings.setValue(QStringLiteral("Map/bearingPolicy"), 1);
break;
default:
settings.setValue(QStringLiteral("Map/bearingPolicy"), 2);
m_settings.setValue(QStringLiteral("Map/bearingPolicy"), 2);
break;
}
emit mapBearingPolicyChanged();
Expand All @@ -249,20 +252,15 @@ void GlobalSettings::setNightMode(bool newNightMode)
return;
}

settings.setValue(QStringLiteral("Map/nightMode"), newNightMode);
m_settings.setValue(QStringLiteral("Map/nightMode"), newNightMode);
emit nightModeChanged();
}


void GlobalSettings::setPositioningByTrafficDataReceiver(bool newPositioningByTrafficDataReceiver)
{
if (newPositioningByTrafficDataReceiver == positioningByTrafficDataReceiver())
{
return;
}

settings.setValue(QStringLiteral("positioningByTrafficDataReceiver"), newPositioningByTrafficDataReceiver);
emit positioningByTrafficDataReceiverChanged();
m_settings.setValue(QStringLiteral("positioningByTrafficDataReceiver"), newPositioningByTrafficDataReceiver);
m_positioningByTrafficDataReceiver = newPositioningByTrafficDataReceiver;
}


Expand All @@ -272,7 +270,7 @@ void GlobalSettings::setShowAltitudeAGL(bool newShowAltitudeAGL)
{
return;
}
settings.setValue(QStringLiteral("showAltitudeAGL"), newShowAltitudeAGL);
m_settings.setValue(QStringLiteral("showAltitudeAGL"), newShowAltitudeAGL);
emit showAltitudeAGLChanged();
}

Expand All @@ -283,6 +281,6 @@ void GlobalSettings::setVoiceNotifications(uint newVoiceNotifications)
{
return;
}
settings.setValue(QStringLiteral("voiceNotifications"), newVoiceNotifications);
m_settings.setValue(QStringLiteral("voiceNotifications"), newVoiceNotifications);
emit voiceNotificationsChanged();
}
44 changes: 25 additions & 19 deletions src/GlobalSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#pragma once

#include <QProperty>
#include <QQmlEngine>
#include <QSettings>

Expand Down Expand Up @@ -155,6 +156,9 @@ class GlobalSettings : public QObject
/*! \brief Night mode */
Q_PROPERTY(bool nightMode READ nightMode WRITE setNightMode NOTIFY nightModeChanged)

/*! \brief Use traffic data receiver for positioning */
Q_PROPERTY(bool positioningByTrafficDataReceiver READ positioningByTrafficDataReceiver WRITE setPositioningByTrafficDataReceiver BINDABLE bindablePositioningByTrafficDataReceiver)

/*! \brief Hash of the last "privacy" message that was accepted by the user
*
* This property is used in the app to determine if the message has been
Expand All @@ -165,9 +169,6 @@ class GlobalSettings : public QObject
/*! \brief Show Altitude AGL */
Q_PROPERTY(bool showAltitudeAGL READ showAltitudeAGL WRITE setShowAltitudeAGL NOTIFY showAltitudeAGLChanged)

/*! \brief Use traffic data receiver for positioning */
Q_PROPERTY(bool positioningByTrafficDataReceiver READ positioningByTrafficDataReceiver WRITE setPositioningByTrafficDataReceiver NOTIFY positioningByTrafficDataReceiverChanged)

/*! \brief Voice notifications that should be played
*
* This property is an "or" of the entries of Notifications::Notification::Importance. It determines
Expand All @@ -184,13 +185,13 @@ class GlobalSettings : public QObject
*
* @returns Property acceptedTerms
*/
[[nodiscard]] auto acceptedTerms() const -> int { return settings.value(QStringLiteral("acceptedTerms"), 0).toInt(); }
[[nodiscard]] auto acceptedTerms() const -> int { return m_settings.value(QStringLiteral("acceptedTerms"), 0).toInt(); }

/*! \brief Getter function for property of the same name
*
* @returns Property alwaysOpenExternalWebsites
*/
[[nodiscard]] bool alwaysOpenExternalWebsites() const { return settings.value(QStringLiteral("alwaysOpenExternalWebsites"), false).toBool(); }
[[nodiscard]] bool alwaysOpenExternalWebsites() const { return m_settings.value(QStringLiteral("alwaysOpenExternalWebsites"), false).toBool(); }

/*! \brief Getter function for property of the same name
*
Expand All @@ -202,7 +203,7 @@ class GlobalSettings : public QObject
*
* @returns Property expandNotamAbbreviations
*/
[[nodiscard]] bool expandNotamAbbreviations() const { return settings.value(QStringLiteral("expandNotamAbbreviations"), false).toBool(); }
[[nodiscard]] bool expandNotamAbbreviations() const { return m_settings.value(QStringLiteral("expandNotamAbbreviations"), false).toBool(); }

/*! \brief Getter function for property with the same name
*
Expand All @@ -214,13 +215,13 @@ class GlobalSettings : public QObject
*
* @returns Property hideGlidingSectors
*/
[[nodiscard]] auto hideGlidingSectors() const -> bool { return settings.value(QStringLiteral("Map/hideGlidingSectors"), true).toBool(); }
[[nodiscard]] auto hideGlidingSectors() const -> bool { return m_settings.value(QStringLiteral("Map/hideGlidingSectors"), true).toBool(); }

/*! \brief Getter function for property of the same name
*
* @returns Property ignoreSSLProblems
*/
[[nodiscard]] auto ignoreSSLProblems() const -> bool { return settings.value(QStringLiteral("ignoreSSLProblems"), false).toBool(); }
[[nodiscard]] auto ignoreSSLProblems() const -> bool { return m_settings.value(QStringLiteral("ignoreSSLProblems"), false).toBool(); }

/*! \brief Getter function for property with the same name
*
Expand All @@ -234,7 +235,7 @@ class GlobalSettings : public QObject
*/
[[nodiscard]] auto lastWhatsNewHash() const -> Units::ByteSize
{
return settings.value(QStringLiteral("lastWhatsNewHash"), 0).value<size_t>();
return m_settings.value(QStringLiteral("lastWhatsNewHash"), 0).value<size_t>();
}

/*! \brief Getter function for property of the same name
Expand All @@ -243,7 +244,7 @@ class GlobalSettings : public QObject
*/
[[nodiscard]] auto lastWhatsNewInMapsHash() const -> Units::ByteSize
{
return settings.value(QStringLiteral("lastWhatsNewInMapsHash"), 0).value<size_t>();
return m_settings.value(QStringLiteral("lastWhatsNewInMapsHash"), 0).value<size_t>();
}

/*! \brief Getter function for property of the same name
Expand All @@ -256,33 +257,39 @@ class GlobalSettings : public QObject
*
* @returns Property night mode
*/
[[nodiscard]] auto nightMode() const -> bool { return settings.value(QStringLiteral("Map/nightMode"), false).toBool(); }
[[nodiscard]] auto nightMode() const -> bool { return m_settings.value(QStringLiteral("Map/nightMode"), false).toBool(); }

/*! \brief Getter function for property of the same name
*
* @returns Property positioningByTrafficDataReceiver
*/
[[nodiscard]] bool positioningByTrafficDataReceiver() const { return m_positioningByTrafficDataReceiver.value(); }

/*! \brief Getter function for property of the same name
*
* @returns Property positioningByTrafficDataReceiver
*/
[[nodiscard]] auto positioningByTrafficDataReceiver() const -> bool { return settings.value(QStringLiteral("positioningByTrafficDataReceiver"), false).toBool(); }
[[nodiscard]] QBindable<bool> bindablePositioningByTrafficDataReceiver() const { return &m_positioningByTrafficDataReceiver; }

/*! \brief Getter function for property of the same name
*
* @returns Property privacyHash
*/
[[nodiscard]] auto privacyHash() const -> Units::ByteSize { return settings.value(QStringLiteral("privacyHash"), 0).value<size_t>(); }
[[nodiscard]] auto privacyHash() const -> Units::ByteSize { return m_settings.value(QStringLiteral("privacyHash"), 0).value<size_t>(); }

/*! \brief Getter function for property of the same name
*
* @returns Property positioningByTrafficDataReceiver
*/
[[nodiscard]] auto showAltitudeAGL() const -> bool { return settings.value(QStringLiteral("showAltitudeAGL"), false).toBool(); }
[[nodiscard]] auto showAltitudeAGL() const -> bool { return m_settings.value(QStringLiteral("showAltitudeAGL"), false).toBool(); }

/*! \brief Getter function for property of the same name
*
* @returns Property voiceNotifications
*/
[[nodiscard]] auto voiceNotifications() const -> uint
{
return settings.value(QStringLiteral("voiceNotifications"),
return m_settings.value(QStringLiteral("voiceNotifications"),
Notifications::Notification::Info_Navigation |
Notifications::Notification::Warning |
Notifications::Notification::Warning_Navigation |
Expand Down Expand Up @@ -439,9 +446,6 @@ class GlobalSettings : public QObject
/*! \brief Notifier signal */
void nightModeChanged();

/*! \brief Notifier signal */
void positioningByTrafficDataReceiverChanged();

/*! \brief Notifier signal */
void privacyHashChanged();

Expand All @@ -454,5 +458,7 @@ class GlobalSettings : public QObject
private:
Q_DISABLE_COPY_MOVE(GlobalSettings)

QSettings settings;
QSettings m_settings;

QProperty<bool> m_positioningByTrafficDataReceiver;
};
2 changes: 1 addition & 1 deletion src/fileFormats/GeoTIFF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ QList<double> FileFormats::GeoTIFF::getTransformation(const QMap<quint16, QVaria
{
return {};
}
auto tiepoint = tiepoints[0];
const auto &tiepoint = tiepoints[0];

auto pixelSize = readPixelSize(TIFFFields);
if (!pixelSize.isValid())
Expand Down
Loading

0 comments on commit 19cf398

Please sign in to comment.