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.
This commit is contained in:
Joseph Donofry 2019-08-10 13:14:37 -04:00
parent 7c7889a04d
commit d5bb0936bf
No known key found for this signature in database
GPG key ID: E8A1D78EF044B0CB
3 changed files with 21 additions and 7 deletions

View file

@ -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