From 20ee430f29bc7b0f4ab9cb60ac449591cbe92208 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Sat, 4 Sep 2021 20:28:14 +0800 Subject: [PATCH] fix: dark/light theme's combobox dropdown list display error --- RedPandaIDE/themes/dark/style.qss | 6 +++++- RedPandaIDE/themes/light/style.qss | 2 ++ RedPandaIDE/utils.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/RedPandaIDE/themes/dark/style.qss b/RedPandaIDE/themes/dark/style.qss index cbb51841..86b91cd1 100644 --- a/RedPandaIDE/themes/dark/style.qss +++ b/RedPandaIDE/themes/dark/style.qss @@ -1227,7 +1227,9 @@ QComboBox { /* padding-right = 36; 4 + 16*2 See scrollbar size */ /* changed to 4px to fix #239 */ /* Fixes #103, #111 */ + /* min-height: 1.5em; + */ /* padding-top: 2px; removed to fix #132 */ /* padding-bottom: 2px; removed to fix #132 */ /* min-width: 75px; removed to fix #109 */ @@ -1247,7 +1249,7 @@ QComboBox QAbstractItemView:hover { } QComboBox QAbstractItemView:selected { - background: #346792; + background-color: #346792; color: #455364; } @@ -1290,9 +1292,11 @@ QComboBox::item:alternate { background: #19232D; } +/* QComboBox::item:checked { font-weight: bold; } +*/ QComboBox::item:selected { border: 0px solid transparent; diff --git a/RedPandaIDE/themes/light/style.qss b/RedPandaIDE/themes/light/style.qss index a780d215..e73350ea 100644 --- a/RedPandaIDE/themes/light/style.qss +++ b/RedPandaIDE/themes/light/style.qss @@ -1290,9 +1290,11 @@ QComboBox::item:alternate { background: #FAFAFA; } +/* QComboBox::item:checked { font-weight: bold; } +*/ QComboBox::item:selected { border: 0px solid transparent; diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index cdd76ca8..6f57d99d 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -417,17 +417,23 @@ void changeTheme(const QString &themeName) { if (themeName.isEmpty() || themeName == "default") { QApplication::setStyle("Fusion"); + QApplication* app = dynamic_cast(QApplication::instance()); + app->setStyleSheet(""); return ; } QStyleFactory styleFactory; if (styleFactory.keys().contains(themeName)) { QApplication::setStyle(themeName); + QApplication* app = dynamic_cast(QApplication::instance()); + app->setStyleSheet(""); + return; } QFile f(QString(":/themes/%1/style.qss").arg(themeName)); if (!f.exists()) { qDebug()<<"Unable to set stylesheet, file not found\n"; } else { + QApplication::setStyle("fusion"); f.open(QFile::ReadOnly | QFile::Text); QTextStream ts(&f); dynamic_cast(QApplication::instance())->setStyleSheet(ts.readAll());