Make icon colors update in real time

Reference: 64df298e5a
This commit is contained in:
tomboylover93 2024-12-22 11:49:53 -03:00
parent ac757e272a
commit e2dbef12c7
2 changed files with 27 additions and 1 deletions

View File

@ -1167,5 +1167,32 @@ bool MainWindow::eventFilter(QObject* obj, QEvent* event) {
}
}
}
if (event->type() == QEvent::ApplicationPaletteChange) {
if (ui->setThemeSystem->isChecked()) {
bool isSystemDarkMode;
#ifdef __linux__
const QPalette defaultPalette;
const auto text = defaultPalette.color(QPalette::WindowText);
const auto window = defaultPalette.color(QPalette::Window);
isSystemDarkMode = (text.lightness() > window.lightness());
#else
isSystemDarkMode =
(QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Dark);
#endif
if (isSystemDarkMode) {
if (isIconBlack) {
SetUiIcons(false);
isIconBlack = false;
}
} else {
if (!isIconBlack) {
SetUiIcons(true);
isIconBlack = true;
}
}
}
}
return QMainWindow::eventFilter(obj, event);
}

View File

@ -538,7 +538,6 @@ void SettingsDialog::UpdateSettings() {
foreach (QWidget* widget, QApplication::topLevelWidgets()) {
widget->update();
}
QCoreApplication::processEvents();
}
void SettingsDialog::ResetInstallFolders() {