Qt: Add icons by @andercard0
This commit is contained in:
@ -46,6 +46,8 @@ static constexpr char DISC_IMAGE_FILTER[] = QT_TRANSLATE_NOOP(
|
||||
"(*.ecm);;Media Descriptor Sidecar Images (*.mds);;PlayStation EBOOTs (*.pbp);;PlayStation Executables (*.exe "
|
||||
"*.psexe);;Portable Sound Format Files (*.psf *.minipsf);;Playlists (*.m3u)");
|
||||
|
||||
static const char* DEFAULT_THEME_NAME = "darkfusion";
|
||||
|
||||
ALWAYS_INLINE static QString getWindowTitle(const QString& game_title)
|
||||
{
|
||||
if (game_title.isEmpty())
|
||||
@ -90,7 +92,7 @@ void MainWindow::initializeAndShow()
|
||||
m_ui.setupUi(this);
|
||||
setupAdditionalUi();
|
||||
connectSignals();
|
||||
updateTheme();
|
||||
setThemeFromSettings();
|
||||
|
||||
resize(800, 700);
|
||||
|
||||
@ -474,7 +476,7 @@ void MainWindow::onSystemPerformanceCountersUpdated(float speed, float fps, floa
|
||||
void MainWindow::onRunningGameChanged(const QString& filename, const QString& game_code, const QString& game_title)
|
||||
{
|
||||
setWindowTitle(getWindowTitle(game_title));
|
||||
|
||||
|
||||
if (m_display_widget)
|
||||
m_display_widget->setWindowTitle(windowTitle());
|
||||
|
||||
@ -1288,6 +1290,7 @@ void MainWindow::connectSignals()
|
||||
addThemeToMenu(tr("Dark Fusion (Gray)"), QStringLiteral("darkfusion"));
|
||||
addThemeToMenu(tr("Dark Fusion (Blue)"), QStringLiteral("darkfusionblue"));
|
||||
addThemeToMenu(tr("QDarkStyle"), QStringLiteral("qdarkstyle"));
|
||||
updateMenuSelectedTheme();
|
||||
}
|
||||
|
||||
void MainWindow::addThemeToMenu(const QString& name, const QString& key)
|
||||
@ -1301,12 +1304,15 @@ void MainWindow::addThemeToMenu(const QString& name, const QString& key)
|
||||
void MainWindow::setTheme(const QString& theme)
|
||||
{
|
||||
m_host_interface->SetStringSettingValue("UI", "Theme", theme.toUtf8().constData());
|
||||
updateTheme();
|
||||
setThemeFromSettings();
|
||||
updateMenuSelectedTheme();
|
||||
}
|
||||
|
||||
void MainWindow::updateTheme()
|
||||
void MainWindow::setThemeFromSettings()
|
||||
{
|
||||
QString theme = QString::fromStdString(m_host_interface->GetStringSettingValue("UI", "Theme", "darkfusion"));
|
||||
QString theme = QString::fromStdString(m_host_interface->GetStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
|
||||
QString icon_theme;
|
||||
|
||||
if (theme == QStringLiteral("qdarkstyle"))
|
||||
{
|
||||
qApp->setStyle(m_unthemed_style_name);
|
||||
@ -1315,12 +1321,16 @@ void MainWindow::updateTheme()
|
||||
QFile f(QStringLiteral(":qdarkstyle/style.qss"));
|
||||
if (f.open(QFile::ReadOnly | QFile::Text))
|
||||
qApp->setStyleSheet(f.readAll());
|
||||
|
||||
icon_theme = QStringLiteral("white");
|
||||
}
|
||||
else if (theme == QStringLiteral("fusion"))
|
||||
{
|
||||
qApp->setPalette(QApplication::style()->standardPalette());
|
||||
qApp->setStyleSheet(QString());
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
||||
icon_theme = QStringLiteral("black");
|
||||
}
|
||||
else if (theme == QStringLiteral("darkfusion"))
|
||||
{
|
||||
@ -1356,6 +1366,8 @@ void MainWindow::updateTheme()
|
||||
qApp->setPalette(darkPalette);
|
||||
|
||||
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
|
||||
|
||||
icon_theme = QStringLiteral("white");
|
||||
}
|
||||
else if (theme == QStringLiteral("darkfusionblue"))
|
||||
{
|
||||
@ -1392,27 +1404,19 @@ void MainWindow::updateTheme()
|
||||
qApp->setPalette(darkPalette);
|
||||
|
||||
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
|
||||
|
||||
icon_theme = QStringLiteral("white");
|
||||
}
|
||||
else
|
||||
{
|
||||
qApp->setPalette(QApplication::style()->standardPalette());
|
||||
qApp->setStyleSheet(QString());
|
||||
qApp->setStyle(m_unthemed_style_name);
|
||||
|
||||
icon_theme = QStringLiteral("black");
|
||||
}
|
||||
|
||||
for (QObject* obj : m_ui.menuSettingsTheme->children())
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(obj);
|
||||
if (action)
|
||||
{
|
||||
QVariant action_data(action->data());
|
||||
if (action_data.isValid())
|
||||
{
|
||||
QSignalBlocker blocker(action);
|
||||
action->setChecked(action_data == theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
QIcon::setThemeName(icon_theme);
|
||||
}
|
||||
|
||||
void MainWindow::onSettingsResetToDefault()
|
||||
@ -1435,6 +1439,7 @@ void MainWindow::onSettingsResetToDefault()
|
||||
updateDebugMenuGPURenderer();
|
||||
updateDebugMenuCropMode();
|
||||
updateDebugMenuVisibility();
|
||||
updateMenuSelectedTheme();
|
||||
}
|
||||
|
||||
void MainWindow::saveStateToConfig()
|
||||
@ -1575,6 +1580,25 @@ void MainWindow::updateDebugMenuCropMode()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateMenuSelectedTheme()
|
||||
{
|
||||
QString theme = QString::fromStdString(m_host_interface->GetStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
|
||||
|
||||
for (QObject* obj : m_ui.menuSettingsTheme->children())
|
||||
{
|
||||
QAction* action = qobject_cast<QAction*>(obj);
|
||||
if (action)
|
||||
{
|
||||
QVariant action_data(action->data());
|
||||
if (action_data.isValid())
|
||||
{
|
||||
QSignalBlocker blocker(action);
|
||||
action->setChecked(action_data == theme);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::ensureGameListLoaded()
|
||||
{
|
||||
if (m_host_interface->getGameList()->IsGameListLoaded())
|
||||
|
||||
Reference in New Issue
Block a user