summary refs log tree commit diff
path: root/src/UserSettingsPage.h
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2019-08-10 13:14:37 -0400
committerJoseph Donofry <joedonofry@gmail.com>2019-08-10 13:14:37 -0400
commitd5bb0936bf8b16dc4a8b505192077576dbe96149 (patch)
tree48490289b2d3bfffa279f2097a4ed0471b8fcea2 /src/UserSettingsPage.h
parentFix linting issues w/ the last commit (diff)
downloadnheko-d5bb0936bf8b16dc4a8b505192077576dbe96149.tar.xz
Use 'system' theme as default if QT_QPA_PLATFORMTHEME is set
On first launch, before the user has configured any settings,
check the value of the QT_QPA_PLATFORMTHEME environment var.
If it is set, use the system theme as the default instead of the
light theme.  This fixes #72.
Diffstat (limited to 'src/UserSettingsPage.h')
-rw-r--r--src/UserSettingsPage.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index ffff1e20..dce12315 100644
--- a/src/UserSettingsPage.h
+++ b/src/UserSettingsPage.h
@@ -85,7 +85,7 @@ public:
                 save();
         }
 
-        QString theme() const { return !theme_.isEmpty() ? theme_ : "light"; }
+        QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
         bool isTrayEnabled() const { return isTrayEnabled_; }
         bool isStartInTrayEnabled() const { return isStartInTrayEnabled_; }
         bool isGroupViewEnabled() const { return isGroupViewEnabled_; }
@@ -100,6 +100,11 @@ signals:
         void groupViewStateChanged(bool state);
 
 private:
+        // Default to system theme if QT_QPA_PLATFORMTHEME var is set.
+        QString defaultTheme_ =
+          QProcessEnvironment::systemEnvironment().value("QT_QPA_PLATFORMTHEME", "").isEmpty()
+            ? "light"
+            : "system";
         QString theme_;
         bool isTrayEnabled_;
         bool isStartInTrayEnabled_;