From d5bb0936bf8b16dc4a8b505192077576dbe96149 Mon Sep 17 00:00:00 2001 From: Joseph Donofry Date: Sat, 10 Aug 2019 13:14:37 -0400 Subject: 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. --- src/Utils.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/Utils.cpp') 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 #include #include +#include #include #include #include @@ -387,14 +388,20 @@ QString utils::linkColor() { QSettings settings; - const auto theme = settings.value("user/theme", "light").toString(); - - if (theme == "light") + // 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") { 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 -- cgit 1.5.1