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:
parent
7c7889a04d
commit
d5bb0936bf
3 changed files with 21 additions and 7 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue