Skip to content

Commit

Permalink
Adjust color theme detection
Browse files Browse the repository at this point in the history
  • Loading branch information
ElTh0r0 committed Jul 17, 2024
1 parent b9e5cd1 commit aed421f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
13 changes: 4 additions & 9 deletions application/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,6 @@ void Settings::readSettings(const QString &sSharePath) {
m_pSettings->value(QStringLiteral("WindowState")).toByteArray();
m_aSplitterState =
m_pSettings->value(QStringLiteral("SplitterState")).toByteArray();
m_nDarkThreshold =
m_pSettings->value(QStringLiteral("DarkThreshold"), -1).toDouble();
m_pSettings->endGroup();
}

Expand Down Expand Up @@ -362,6 +360,7 @@ void Settings::removeObsolete() {
m_pSettings->remove(QStringLiteral("Inyoka/WikiUrl"));
m_pSettings->remove(QStringLiteral("ConstructionArea"));
m_pSettings->remove(QStringLiteral("Inyoka/ConstructionArea"));
m_pSettings->remove(QStringLiteral("Window/DarkThreshold"));
m_pSettings->beginGroup(QStringLiteral("FindDialog"));
m_pSettings->remove(QLatin1String(""));
m_pSettings->endGroup();
Expand Down Expand Up @@ -508,18 +507,14 @@ auto Settings::getSplitterState() const -> QByteArray {

auto Settings::isDarkScheme() const -> bool {
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
if (-1 == m_nDarkThreshold &&
Qt::ColorScheme::Dark == QGuiApplication::styleHints()->colorScheme()) {
if (Qt::ColorScheme::Dark == QGuiApplication::styleHints()->colorScheme()) {
return true;
}
#endif

double nThreshold = 0.5;
if (-1 != m_nDarkThreshold) {
nThreshold = m_nDarkThreshold;
}
// Fallback: If window is darker than text
if (m_pParent->window()->palette().window().color().lightnessF() <
nThreshold) {
m_pParent->window()->palette().windowText().color().lightnessF()) {
return true;
}

Expand Down
1 change: 0 additions & 1 deletion application/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class Settings : public QObject {
QByteArray m_aWindowState;
QByteArray m_aWindowGeometry;
QByteArray m_aSplitterState;
double m_nDarkThreshold;

// Last opened
static const quint16 m_cMAXFILES = 10;
Expand Down

0 comments on commit aed421f

Please sign in to comment.