diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 8f22dc55b5..263506da1c 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -692,6 +692,38 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const } else { + // colorize preview icons + auto addColoredIcon = [&](QPushButton *button, const QColor& color, const QIcon& icon = QIcon(), const QColor& iconColor = QColor()) { + QLabel* text = new QLabel(button->text()); + text->setObjectName("color_button"); + text->setAlignment(Qt::AlignCenter); + text->setAttribute(Qt::WA_TransparentForMouseEvents, true); + delete button->layout(); + if (icon.isNull()) + { + QPixmap pixmap(100, 100); + pixmap.fill(color); + button->setIcon(pixmap); + } + else + { + button->setIcon(gui_settings::colorizedIcon(icon, iconColor, color)); + } + button->setText(""); + button->setStyleSheet(styleSheet().append("text-align:left;")); + button->setLayout(new QGridLayout); + button->layout()->setContentsMargins(0, 0, 0, 0); + button->layout()->addWidget(text); + }; + + auto AddColoredIcons = [=]() { + addColoredIcon(ui->pb_gl_icon_color, xgui_settings->GetValue(GUI::gl_iconColor).value()); + addColoredIcon(ui->pb_tool_bar_color, xgui_settings->GetValue(GUI::mw_toolBarColor).value()); + addColoredIcon(ui->pb_gl_tool_icon_color, xgui_settings->GetValue(GUI::gl_toolIconColor).value(), QIcon(":/Icons/home_blue.png"), GUI::gl_tool_icon_color); + addColoredIcon(ui->pb_tool_icon_color, xgui_settings->GetValue(GUI::mw_toolIconColor).value(), QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color); + }; + AddColoredIcons(); + ui->cb_show_welcome->setChecked(xgui_settings->GetValue(GUI::ib_show_welcome).toBool()); bool enableUIColors = xgui_settings->GetValue(GUI::m_enableUIColors).toBool(); @@ -701,27 +733,39 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const ui->pb_tool_bar_color->setEnabled(enableUIColors); ui->pb_tool_icon_color->setEnabled(enableUIColors); - connect(ui->okButton, &QAbstractButton::clicked, [this]() { + auto ApplyGuiOptions = [&](bool reset = false) { + if (reset) + { + m_currentConfig = GUI::Default; + m_currentStylesheet = GUI::Default; + ui->combo_configs->setCurrentText(GUI::Default); + ui->combo_stylesheets->setCurrentText(GUI::Default); + } // Only attempt to load a config if changes occurred. - if (m_startingConfig != xgui_settings->GetValue(GUI::m_currentConfig).toString()) + if (m_currentConfig != xgui_settings->GetValue(GUI::m_currentConfig).toString()) { OnApplyConfig(); } - if (m_startingStylesheet != xgui_settings->GetValue(GUI::m_currentStylesheet).toString()) + if (m_currentStylesheet != xgui_settings->GetValue(GUI::m_currentStylesheet).toString()) { OnApplyStylesheet(); } - }); + }; + + connect(ui->okButton, &QAbstractButton::clicked, [=]() { ApplyGuiOptions(); }); connect(ui->pb_reset_default, &QAbstractButton::clicked, [=]() { if (QMessageBox::question(this, tr("Reset GUI to default?"), tr("This will include your stylesheet as well. Do you wish to proceed?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes) { + ApplyGuiOptions(true); xgui_settings->Reset(true); xgui_settings->ChangeToConfig(GUI::Default); Q_EMIT GuiStylesheetRequest(GUI::Default); Q_EMIT GuiSettingsSyncRequest(); + Q_EMIT GuiRepaintRequest(); AddConfigs(); AddStylesheets(); + AddColoredIcons(); } }); connect(ui->pb_backup_config, &QAbstractButton::clicked, this, &settings_dialog::OnBackupCurrentConfig); @@ -762,33 +806,6 @@ settings_dialog::settings_dialog(std::shared_ptr xSettings, const connect(ui->pb_tool_bar_color, &QAbstractButton::clicked, [=]() { colorDialog(GUI::mw_toolBarColor, tr("Choose tool bar color"), ui->pb_tool_bar_color); }); connect(ui->pb_tool_icon_color, &QAbstractButton::clicked, [=]() { colorDialog(GUI::mw_toolIconColor, tr("Choose tool icon color"), ui->pb_tool_icon_color); }); - // colorize preview icons - auto addColoredIcon = [&](QPushButton *button, const QColor& color, const QIcon& icon = QIcon(), const QColor& iconColor = QColor()){ - QLabel* text = new QLabel(button->text()); - text->setObjectName("color_button"); - text->setAlignment(Qt::AlignCenter); - text->setAttribute(Qt::WA_TransparentForMouseEvents, true); - if (icon.isNull()) - { - QPixmap pixmap(100, 100); - pixmap.fill(color); - button->setIcon(pixmap); - } - else - { - button->setIcon(gui_settings::colorizedIcon(icon, iconColor, color)); - } - button->setText(""); - button->setStyleSheet(styleSheet().append("text-align:left;")); - button->setLayout(new QGridLayout); - button->layout()->setContentsMargins(0, 0, 0, 0); - button->layout()->addWidget(text); - }; - addColoredIcon(ui->pb_gl_icon_color, xgui_settings->GetValue(GUI::gl_iconColor).value()); - addColoredIcon(ui->pb_tool_bar_color, xgui_settings->GetValue(GUI::mw_toolBarColor).value()); - addColoredIcon(ui->pb_gl_tool_icon_color, xgui_settings->GetValue(GUI::gl_toolIconColor).value(), QIcon(":/Icons/home_blue.png"), GUI::gl_tool_icon_color); - addColoredIcon(ui->pb_tool_icon_color, xgui_settings->GetValue(GUI::mw_toolIconColor).value(), QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color); - ui->gs_disableMouse->setChecked(xgui_settings->GetValue(GUI::gs_disableMouse).toBool()); connect(ui->gs_disableMouse, &QCheckBox::clicked, [=](bool val) { xgui_settings->SetValue(GUI::gs_disableMouse, val); }); @@ -887,10 +904,9 @@ void settings_dialog::AddConfigs() } } - QString currentSelection = tr("CurrentSettings"); - m_startingConfig = currentSelection; + m_currentConfig = tr("CurrentSettings"); - int index = ui->combo_configs->findText(currentSelection); + int index = ui->combo_configs->findText(m_currentConfig); if (index != -1) { ui->combo_configs->setCurrentIndex(index); @@ -915,9 +931,9 @@ void settings_dialog::AddStylesheets() } } - m_startingStylesheet = xgui_settings->GetValue(GUI::m_currentStylesheet).toString(); + m_currentStylesheet = xgui_settings->GetValue(GUI::m_currentStylesheet).toString(); - int index = ui->combo_stylesheets->findText(m_startingStylesheet); + int index = ui->combo_stylesheets->findText(m_currentStylesheet); if (index != -1) { ui->combo_stylesheets->setCurrentIndex(index); @@ -964,15 +980,16 @@ void settings_dialog::OnBackupCurrentConfig() void settings_dialog::OnApplyConfig() { - QString name = ui->combo_configs->currentText(); - xgui_settings->SetValue(GUI::m_currentConfig, name); - xgui_settings->ChangeToConfig(name); + m_currentConfig = ui->combo_configs->currentText(); + xgui_settings->SetValue(GUI::m_currentConfig, m_currentConfig); + xgui_settings->ChangeToConfig(m_currentConfig); Q_EMIT GuiSettingsSyncRequest(); } void settings_dialog::OnApplyStylesheet() { - xgui_settings->SetValue(GUI::m_currentStylesheet, ui->combo_stylesheets->currentText()); + m_currentStylesheet = ui->combo_stylesheets->currentText(); + xgui_settings->SetValue(GUI::m_currentStylesheet, m_currentStylesheet); Q_EMIT GuiStylesheetRequest(xgui_settings->GetCurrentStylesheetPath()); } diff --git a/rpcs3/rpcs3qt/settings_dialog.h b/rpcs3/rpcs3qt/settings_dialog.h index 06e9d626b8..11cdf391d9 100644 --- a/rpcs3/rpcs3qt/settings_dialog.h +++ b/rpcs3/rpcs3qt/settings_dialog.h @@ -34,8 +34,8 @@ private: //emulator tab void AddConfigs(); void AddStylesheets(); - QString m_startingStylesheet; - QString m_startingConfig; + QString m_currentStylesheet; + QString m_currentConfig; //gpu tab QString m_oldRender = ""; bool m_isD3D12 = false;