mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2024-11-30 01:25:51 +00:00
Qt: Split icon theme and style init
This commit is contained in:
parent
e87761b9e6
commit
f2909b447b
|
@ -89,12 +89,12 @@ MainWindow::~MainWindow()
|
|||
|
||||
void MainWindow::initializeAndShow()
|
||||
{
|
||||
setIconThemeFromSettings();
|
||||
|
||||
m_ui.setupUi(this);
|
||||
setStyleFromSettings();
|
||||
setupAdditionalUi();
|
||||
connectSignals();
|
||||
setThemeFromSettings();
|
||||
|
||||
resize(800, 700);
|
||||
|
||||
restoreStateFromConfig();
|
||||
switchToGameListView();
|
||||
|
@ -1304,16 +1304,16 @@ void MainWindow::addThemeToMenu(const QString& name, const QString& key)
|
|||
void MainWindow::setTheme(const QString& theme)
|
||||
{
|
||||
m_host_interface->SetStringSettingValue("UI", "Theme", theme.toUtf8().constData());
|
||||
setThemeFromSettings();
|
||||
setStyleFromSettings();
|
||||
setIconThemeFromSettings();
|
||||
updateMenuSelectedTheme();
|
||||
}
|
||||
|
||||
void MainWindow::setThemeFromSettings()
|
||||
void MainWindow::setStyleFromSettings()
|
||||
{
|
||||
QString theme = QString::fromStdString(m_host_interface->GetStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
|
||||
QString icon_theme;
|
||||
const std::string theme(m_host_interface->GetStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
|
||||
|
||||
if (theme == QStringLiteral("qdarkstyle"))
|
||||
if (theme == "qdarkstyle")
|
||||
{
|
||||
qApp->setStyle(m_unthemed_style_name);
|
||||
qApp->setPalette(QApplication::style()->standardPalette());
|
||||
|
@ -1321,18 +1321,14 @@ void MainWindow::setThemeFromSettings()
|
|||
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"))
|
||||
else if (theme == "fusion")
|
||||
{
|
||||
qApp->setPalette(QApplication::style()->standardPalette());
|
||||
qApp->setStyleSheet(QString());
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
||||
icon_theme = QStringLiteral("black");
|
||||
}
|
||||
else if (theme == QStringLiteral("darkfusion"))
|
||||
else if (theme == "darkfusion")
|
||||
{
|
||||
// adapted from https://gist.github.com/QuantumCD/6245215
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
@ -1366,10 +1362,8 @@ void MainWindow::setThemeFromSettings()
|
|||
qApp->setPalette(darkPalette);
|
||||
|
||||
qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: #2a82da; border: 1px solid white; }");
|
||||
|
||||
icon_theme = QStringLiteral("white");
|
||||
}
|
||||
else if (theme == QStringLiteral("darkfusionblue"))
|
||||
else if (theme == "darkfusionblue")
|
||||
{
|
||||
// adapted from https://gist.github.com/QuantumCD/6245215
|
||||
qApp->setStyle(QStyleFactory::create("Fusion"));
|
||||
|
@ -1404,17 +1398,24 @@ void MainWindow::setThemeFromSettings()
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::setIconThemeFromSettings()
|
||||
{
|
||||
const std::string theme(m_host_interface->GetStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
|
||||
QString icon_theme;
|
||||
|
||||
if (theme == "qdarkstyle" || theme == "darkfusion" || theme == "darkfusionblue")
|
||||
icon_theme = QStringLiteral("white");
|
||||
else
|
||||
icon_theme = QStringLiteral("black");
|
||||
|
||||
QIcon::setThemeName(icon_theme);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,8 @@ private:
|
|||
}
|
||||
|
||||
void setTheme(const QString& theme);
|
||||
void setThemeFromSettings();
|
||||
void setStyleFromSettings();
|
||||
void setIconThemeFromSettings();
|
||||
void setupAdditionalUi();
|
||||
void connectSignals();
|
||||
void addThemeToMenu(const QString& name, const QString& key);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>754</width>
|
||||
<height>600</height>
|
||||
<width>800</width>
|
||||
<height>700</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="acceptDrops">
|
||||
|
|
Loading…
Reference in a new issue