summary refs log tree commit diff
path: root/src/Utils.cpp
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/Utils.cpp
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 '')
-rw-r--r--src/Utils.cpp17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/Utils.cpp b/src/Utils.cpp

index a3c15c96..5c664b7c 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp
@@ -4,6 +4,7 @@ #include <QComboBox> #include <QDesktopWidget> #include <QGuiApplication> +#include <QProcessEnvironment> #include <QScreen> #include <QSettings> #include <QTextDocument> @@ -387,14 +388,20 @@ QString utils::linkColor() { QSettings settings; - const auto theme = settings.value("user/theme", "light").toString(); + // Default to system theme if QT_QPA_PLATFORMTHEME var is set. + QString defaultTheme = + QProcessEnvironment::systemEnvironment().value("QT_QPA_PLATFORMTHEME", "").isEmpty() + ? "light" + : "system"; + const auto theme = settings.value("user/theme", defaultTheme).toString(); - if (theme == "light") + if (theme == "light") { return "#0077b5"; - else if (theme == "dark") + } else if (theme == "dark") { return "#38A3D8"; - - return QPalette().color(QPalette::Link).name(); + } else { + return QPalette().color(QPalette::Link).name(); + } } uint32_t