mirror of https://github.com/RPCS3/rpcs3.git
GUI: improve reset to deafult button
This commit is contained in:
parent
ee98683538
commit
c85806c422
|
@ -692,6 +692,38 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
|
||||||
}
|
}
|
||||||
else
|
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<QColor>());
|
||||||
|
addColoredIcon(ui->pb_tool_bar_color, xgui_settings->GetValue(GUI::mw_toolBarColor).value<QColor>());
|
||||||
|
addColoredIcon(ui->pb_gl_tool_icon_color, xgui_settings->GetValue(GUI::gl_toolIconColor).value<QColor>(), QIcon(":/Icons/home_blue.png"), GUI::gl_tool_icon_color);
|
||||||
|
addColoredIcon(ui->pb_tool_icon_color, xgui_settings->GetValue(GUI::mw_toolIconColor).value<QColor>(), QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color);
|
||||||
|
};
|
||||||
|
AddColoredIcons();
|
||||||
|
|
||||||
ui->cb_show_welcome->setChecked(xgui_settings->GetValue(GUI::ib_show_welcome).toBool());
|
ui->cb_show_welcome->setChecked(xgui_settings->GetValue(GUI::ib_show_welcome).toBool());
|
||||||
|
|
||||||
bool enableUIColors = xgui_settings->GetValue(GUI::m_enableUIColors).toBool();
|
bool enableUIColors = xgui_settings->GetValue(GUI::m_enableUIColors).toBool();
|
||||||
|
@ -701,27 +733,39 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> xSettings, const
|
||||||
ui->pb_tool_bar_color->setEnabled(enableUIColors);
|
ui->pb_tool_bar_color->setEnabled(enableUIColors);
|
||||||
ui->pb_tool_icon_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.
|
// 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();
|
OnApplyConfig();
|
||||||
}
|
}
|
||||||
if (m_startingStylesheet != xgui_settings->GetValue(GUI::m_currentStylesheet).toString())
|
if (m_currentStylesheet != xgui_settings->GetValue(GUI::m_currentStylesheet).toString())
|
||||||
{
|
{
|
||||||
OnApplyStylesheet();
|
OnApplyStylesheet();
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
connect(ui->okButton, &QAbstractButton::clicked, [=]() { ApplyGuiOptions(); });
|
||||||
connect(ui->pb_reset_default, &QAbstractButton::clicked, [=]() {
|
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?"),
|
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)
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::Yes)
|
||||||
{
|
{
|
||||||
|
ApplyGuiOptions(true);
|
||||||
xgui_settings->Reset(true);
|
xgui_settings->Reset(true);
|
||||||
xgui_settings->ChangeToConfig(GUI::Default);
|
xgui_settings->ChangeToConfig(GUI::Default);
|
||||||
Q_EMIT GuiStylesheetRequest(GUI::Default);
|
Q_EMIT GuiStylesheetRequest(GUI::Default);
|
||||||
Q_EMIT GuiSettingsSyncRequest();
|
Q_EMIT GuiSettingsSyncRequest();
|
||||||
|
Q_EMIT GuiRepaintRequest();
|
||||||
AddConfigs();
|
AddConfigs();
|
||||||
AddStylesheets();
|
AddStylesheets();
|
||||||
|
AddColoredIcons();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(ui->pb_backup_config, &QAbstractButton::clicked, this, &settings_dialog::OnBackupCurrentConfig);
|
connect(ui->pb_backup_config, &QAbstractButton::clicked, this, &settings_dialog::OnBackupCurrentConfig);
|
||||||
|
@ -762,33 +806,6 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> 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_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); });
|
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<QColor>());
|
|
||||||
addColoredIcon(ui->pb_tool_bar_color, xgui_settings->GetValue(GUI::mw_toolBarColor).value<QColor>());
|
|
||||||
addColoredIcon(ui->pb_gl_tool_icon_color, xgui_settings->GetValue(GUI::gl_toolIconColor).value<QColor>(), QIcon(":/Icons/home_blue.png"), GUI::gl_tool_icon_color);
|
|
||||||
addColoredIcon(ui->pb_tool_icon_color, xgui_settings->GetValue(GUI::mw_toolIconColor).value<QColor>(), QIcon(":/Icons/stop.png"), GUI::mw_tool_icon_color);
|
|
||||||
|
|
||||||
ui->gs_disableMouse->setChecked(xgui_settings->GetValue(GUI::gs_disableMouse).toBool());
|
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); });
|
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_currentConfig = tr("CurrentSettings");
|
||||||
m_startingConfig = currentSelection;
|
|
||||||
|
|
||||||
int index = ui->combo_configs->findText(currentSelection);
|
int index = ui->combo_configs->findText(m_currentConfig);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
ui->combo_configs->setCurrentIndex(index);
|
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)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
ui->combo_stylesheets->setCurrentIndex(index);
|
ui->combo_stylesheets->setCurrentIndex(index);
|
||||||
|
@ -964,15 +980,16 @@ void settings_dialog::OnBackupCurrentConfig()
|
||||||
|
|
||||||
void settings_dialog::OnApplyConfig()
|
void settings_dialog::OnApplyConfig()
|
||||||
{
|
{
|
||||||
QString name = ui->combo_configs->currentText();
|
m_currentConfig = ui->combo_configs->currentText();
|
||||||
xgui_settings->SetValue(GUI::m_currentConfig, name);
|
xgui_settings->SetValue(GUI::m_currentConfig, m_currentConfig);
|
||||||
xgui_settings->ChangeToConfig(name);
|
xgui_settings->ChangeToConfig(m_currentConfig);
|
||||||
Q_EMIT GuiSettingsSyncRequest();
|
Q_EMIT GuiSettingsSyncRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void settings_dialog::OnApplyStylesheet()
|
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());
|
Q_EMIT GuiStylesheetRequest(xgui_settings->GetCurrentStylesheetPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ private:
|
||||||
//emulator tab
|
//emulator tab
|
||||||
void AddConfigs();
|
void AddConfigs();
|
||||||
void AddStylesheets();
|
void AddStylesheets();
|
||||||
QString m_startingStylesheet;
|
QString m_currentStylesheet;
|
||||||
QString m_startingConfig;
|
QString m_currentConfig;
|
||||||
//gpu tab
|
//gpu tab
|
||||||
QString m_oldRender = "";
|
QString m_oldRender = "";
|
||||||
bool m_isD3D12 = false;
|
bool m_isD3D12 = false;
|
||||||
|
|
Loading…
Reference in New Issue