new SystemHelpers::isLightTheme()
parent
d0b1374b70
commit
c610075c9c
|
@ -1,8 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <QString>
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <QSettings>
|
||||||
|
#else
|
||||||
|
#include <QtGui/QGuiApplication>
|
||||||
|
#include <QtGui/QPalette>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "appconfig.h"
|
#include "appconfig.h"
|
||||||
|
|
||||||
class SystemHelpers {
|
class SystemHelpers {
|
||||||
|
@ -21,5 +27,12 @@ class SystemHelpers {
|
||||||
QDir().mkpath(root);
|
QDir().mkpath(root);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
static bool isLightTheme() {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QSettings settings(QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"), QSettings::NativeFormat);
|
||||||
|
return settings.value(QStringLiteral("SystemUsesLightTheme")).toInt() == 1;
|
||||||
|
#else
|
||||||
|
return qApp->palette().text().color().value() <= QColor(Qt::lightGray).value();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,11 +25,6 @@
|
||||||
#include "helpers/system_helpers.h"
|
#include "helpers/system_helpers.h"
|
||||||
#include "hotkeymanager.h"
|
#include "hotkeymanager.h"
|
||||||
#include "models/codeblock.h"
|
#include "models/codeblock.h"
|
||||||
#include "porting/system_manifest.h"
|
|
||||||
|
|
||||||
#if defined(Q_OS_WIN)
|
|
||||||
#include <QSettings>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TrayManager::TrayManager(QWidget * parent, DatabaseConnection* db)
|
TrayManager::TrayManager(QWidget * parent, DatabaseConnection* db)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
|
@ -316,18 +311,11 @@ void TrayManager::setTrayMessage(MessageType type, const QString& title, const Q
|
||||||
|
|
||||||
QIcon TrayManager::getTrayIcon()
|
QIcon TrayManager::getTrayIcon()
|
||||||
{
|
{
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_MACOS)
|
||||||
QIcon icon = QIcon(palette().text().color().value() >= QColor(Qt::lightGray).value()
|
|
||||||
? QStringLiteral(":/icons/shirt-light.svg")
|
|
||||||
: QStringLiteral(":/icons/shirt-dark.svg"));
|
|
||||||
#elif defined(Q_OS_MACOS)
|
|
||||||
QIcon icon = QIcon(QStringLiteral(":/icons/shirt-dark.svg"));
|
QIcon icon = QIcon(QStringLiteral(":/icons/shirt-dark.svg"));
|
||||||
icon.setIsMask(true);
|
icon.setIsMask(true);
|
||||||
#elif defined(Q_OS_WIN)
|
#else
|
||||||
QSettings settings(QStringLiteral("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"), QSettings::NativeFormat);
|
QIcon icon = SystemHelpers::isLightTheme() ? QIcon(QStringLiteral(":/icons/shirt-dark.svg")) : QIcon(QStringLiteral(":/icons/shirt-light.svg"));
|
||||||
QIcon icon = QIcon(settings.value(QStringLiteral("SystemUsesLightTheme")).toInt() == 0
|
|
||||||
? QStringLiteral(":/icons/shirt-light.svg")
|
|
||||||
: QStringLiteral(":/icons/shirt-dark.svg"));
|
|
||||||
#endif
|
#endif
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue