From 8bf25f3d803c1a7ed110c4cf622d8a233b171ab2 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Mon, 30 Mar 2020 21:48:28 +0200 Subject: Set palette globally --- src/UserSettingsPage.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'src/UserSettingsPage.cpp') diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index 6cd9a95c..f89b5224 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -103,12 +103,43 @@ UserSettings::applyTheme() { QFile stylefile; - if (theme() == "light") { + static QPalette original; + if (this->theme() == "light") { stylefile.setFileName(":/styles/styles/nheko.qss"); - } else if (theme() == "dark") { + QPalette lightActive(/*windowText*/ QColor("#333"), + /*button*/ QColor("#333"), + /*light*/ QColor(), + /*dark*/ QColor(220, 220, 220), + /*mid*/ QColor(), + /*text*/ QColor("#333"), + /*bright_text*/ QColor(), + /*base*/ QColor(220, 220, 220), + /*window*/ QColor("white")); + lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color()); + lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); + lightActive.setColor(QPalette::Link, QColor("#0077b5")); + lightActive.setColor(QPalette::ButtonText, QColor("gray")); + QApplication::setPalette(lightActive); + } else if (this->theme() == "dark") { stylefile.setFileName(":/styles/styles/nheko-dark.qss"); + QPalette darkActive(/*windowText*/ QColor("#caccd1"), + /*button*/ QColor("#caccd1"), + /*light*/ QColor(), + /*dark*/ QColor("#2d3139"), + /*mid*/ QColor(), + /*text*/ QColor("#caccd1"), + /*bright_text*/ QColor(0xff, 0xff, 0xff), + /*base*/ QColor("#2d3139"), + /*window*/ QColor("#202228")); + darkActive.setColor(QPalette::Highlight, QColor("#38a3d8")); + darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color()); + darkActive.setColor(QPalette::ToolTipText, darkActive.text().color()); + darkActive.setColor(QPalette::Link, QColor("#38a3d8")); + darkActive.setColor(QPalette::ButtonText, QColor("gray")); + QApplication::setPalette(darkActive); } else { stylefile.setFileName(":/styles/styles/system.qss"); + QApplication::setPalette(original); } stylefile.open(QFile::ReadOnly); -- cgit 1.5.1 From 6794b6472d3b447954df5d56e36f83f008fd0110 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Wed, 8 Apr 2020 23:08:43 +0200 Subject: Add a few missing palette colors --- resources/qml/delegates/FileMessage.qml | 2 +- resources/qml/delegates/PlayableMediaMessage.qml | 2 +- resources/styles/nheko-dark.qss | 21 ------------ resources/styles/nheko.qss | 12 ------- src/UserSettingsPage.cpp | 41 +++++++++++++----------- 5 files changed, 24 insertions(+), 54 deletions(-) (limited to 'src/UserSettingsPage.cpp') diff --git a/resources/qml/delegates/FileMessage.qml b/resources/qml/delegates/FileMessage.qml index 2fe0a490..9a5300bb 100644 --- a/resources/qml/delegates/FileMessage.qml +++ b/resources/qml/delegates/FileMessage.qml @@ -3,7 +3,7 @@ import QtQuick.Layouts 1.2 Rectangle { radius: 10 - color: colors.base + color: colors.dark height: row.height + 24 width: parent ? parent.width : undefined diff --git a/resources/qml/delegates/PlayableMediaMessage.qml b/resources/qml/delegates/PlayableMediaMessage.qml index a4096864..20177a04 100644 --- a/resources/qml/delegates/PlayableMediaMessage.qml +++ b/resources/qml/delegates/PlayableMediaMessage.qml @@ -8,7 +8,7 @@ import im.nheko 1.0 Rectangle { id: bg radius: 10 - color: colors.base + color: colors.dark height: content.height + 24 width: parent ? parent.width : undefined diff --git a/resources/styles/nheko-dark.qss b/resources/styles/nheko-dark.qss index d89a61bb..875a3828 100644 --- a/resources/styles/nheko-dark.qss +++ b/resources/styles/nheko-dark.qss @@ -176,27 +176,6 @@ UserInfoWidget { border-bottom: 1px solid #202228; } -QPushButton, -QComboBox, -QAbstractItemView, -QComboBox > * { - background: white; - color: #202228; -} - -QComboBox:hover, -QAbstractItemView::item:hover, -QPushButton:hover { - background: #38a3d8; - selection-background-color: #38a3d8; -} - - -QAbstractItemView::item:selected { - border-color: darkblue; - background: grey; -} - Avatar { qproperty-textColor: white; qproperty-backgroundColor: #2d3139; diff --git a/resources/styles/nheko.qss b/resources/styles/nheko.qss index 1a7cb80f..51e5d64e 100644 --- a/resources/styles/nheko.qss +++ b/resources/styles/nheko.qss @@ -190,18 +190,6 @@ RegisterPage { color: #333; } -QComboBox:hover, -QAbstractItemView::item:hover, -QPushButton:hover { - background: #38a3d8; - selection-background-color: #38a3d8; -} - -QAbstractItemView::item:selected { - border-color: darkblue; - background: grey; -} - emoji--Panel, emoji--Panel > * { background-color: #eee; diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp index f89b5224..3afff83b 100644 --- a/src/UserSettingsPage.cpp +++ b/src/UserSettingsPage.cpp @@ -106,15 +106,17 @@ UserSettings::applyTheme() static QPalette original; if (this->theme() == "light") { stylefile.setFileName(":/styles/styles/nheko.qss"); - QPalette lightActive(/*windowText*/ QColor("#333"), - /*button*/ QColor("#333"), - /*light*/ QColor(), - /*dark*/ QColor(220, 220, 220), - /*mid*/ QColor(), - /*text*/ QColor("#333"), - /*bright_text*/ QColor(), - /*base*/ QColor(220, 220, 220), - /*window*/ QColor("white")); + QPalette lightActive( + /*windowText*/ QColor("#333"), + /*button*/ QColor("#333"), + /*light*/ QColor(0xef, 0xef, 0xef), + /*dark*/ QColor(220, 220, 220), + /*mid*/ QColor(0, 0xff, 0), // not used anywhere, this is for debugging + /*text*/ QColor("#333"), + /*bright_text*/ QColor("#333"), + /*base*/ QColor("white"), + /*window*/ QColor("white")); + lightActive.setColor(QPalette::Highlight, QColor("#38a3d8")); lightActive.setColor(QPalette::ToolTipBase, lightActive.base().color()); lightActive.setColor(QPalette::ToolTipText, lightActive.text().color()); lightActive.setColor(QPalette::Link, QColor("#0077b5")); @@ -122,20 +124,21 @@ UserSettings::applyTheme() QApplication::setPalette(lightActive); } else if (this->theme() == "dark") { stylefile.setFileName(":/styles/styles/nheko-dark.qss"); - QPalette darkActive(/*windowText*/ QColor("#caccd1"), - /*button*/ QColor("#caccd1"), - /*light*/ QColor(), - /*dark*/ QColor("#2d3139"), - /*mid*/ QColor(), - /*text*/ QColor("#caccd1"), - /*bright_text*/ QColor(0xff, 0xff, 0xff), - /*base*/ QColor("#2d3139"), - /*window*/ QColor("#202228")); + QPalette darkActive( + /*windowText*/ QColor("#caccd1"), + /*button*/ QColor(0xff, 0xff, 0xff), + /*light*/ QColor("#caccd1"), + /*dark*/ QColor("#2d3139"), + /*mid*/ QColor(0, 0xff, 0), // not used anywhere, this is for debugging + /*text*/ QColor("#caccd1"), + /*bright_text*/ QColor(0xff, 0xff, 0xff), + /*base*/ QColor("#2d3139"), + /*window*/ QColor("#202228")); darkActive.setColor(QPalette::Highlight, QColor("#38a3d8")); darkActive.setColor(QPalette::ToolTipBase, darkActive.base().color()); darkActive.setColor(QPalette::ToolTipText, darkActive.text().color()); darkActive.setColor(QPalette::Link, QColor("#38a3d8")); - darkActive.setColor(QPalette::ButtonText, QColor("gray")); + darkActive.setColor(QPalette::ButtonText, QColor(77, 77, 77)); QApplication::setPalette(darkActive); } else { stylefile.setFileName(":/styles/styles/system.qss"); -- cgit 1.5.1