Qt: Calculate icon theme from palette instead of name

This commit is contained in:
TellowKrinkle 2022-05-25 16:20:34 -05:00 committed by refractionpcsx2
parent 6b66cd7f29
commit dbfb93a50f
2 changed files with 8 additions and 14 deletions

View File

@ -88,10 +88,10 @@ MainWindow::~MainWindow()
void MainWindow::initialize()
{
setIconThemeFromSettings();
setStyleFromSettings();
setIconThemeFromStyle();
m_ui.setupUi(this);
setupAdditionalUi();
setStyleFromSettings();
connectSignals();
connectVMThreadSignals(g_emu_thread);
@ -549,17 +549,11 @@ void MainWindow::setStyleFromSettings()
}
}
void MainWindow::setIconThemeFromSettings()
void MainWindow::setIconThemeFromStyle()
{
const std::string theme(Host::GetBaseStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
QString icon_theme;
if (theme == "darkfusion" || theme == "darkfusionblue" || theme == "dualtoneOrangeBlue" || theme == "ScarletDevilRed")
icon_theme = QStringLiteral("white");
else
icon_theme = QStringLiteral("black");
QIcon::setThemeName(icon_theme);
QPalette palette = qApp->palette();
bool dark = palette.windowText().color().value() > palette.window().color().value();
QIcon::setThemeName(dark ? QStringLiteral("white") : QStringLiteral("black"));
}
void MainWindow::onScreenshotActionTriggered()
@ -1219,7 +1213,7 @@ void MainWindow::onToolsOpenDataDirectoryTriggered()
void MainWindow::onThemeChanged()
{
setStyleFromSettings();
setIconThemeFromSettings();
setIconThemeFromStyle();
recreate();
}

View File

@ -169,7 +169,7 @@ private:
void setupAdditionalUi();
void connectSignals();
void setStyleFromSettings();
void setIconThemeFromSettings();
void setIconThemeFromStyle();
void saveStateToConfig();
void restoreStateFromConfig();