fix: dark/light theme's combobox dropdown list display error

This commit is contained in:
royqh1979 2021-09-04 20:28:14 +08:00
parent ad2310d4b5
commit 20ee430f29
3 changed files with 13 additions and 1 deletions

View File

@ -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;

View File

@ -1290,9 +1290,11 @@ QComboBox::item:alternate {
background: #FAFAFA;
}
/*
QComboBox::item:checked {
font-weight: bold;
}
*/
QComboBox::item:selected {
border: 0px solid transparent;

View File

@ -417,17 +417,23 @@ void changeTheme(const QString &themeName)
{
if (themeName.isEmpty() || themeName == "default") {
QApplication::setStyle("Fusion");
QApplication* app = dynamic_cast<QApplication*>(QApplication::instance());
app->setStyleSheet("");
return ;
}
QStyleFactory styleFactory;
if (styleFactory.keys().contains(themeName)) {
QApplication::setStyle(themeName);
QApplication* app = dynamic_cast<QApplication*>(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*>(QApplication::instance())->setStyleSheet(ts.readAll());