Qt: Add a gui tab to the settings dialog

this is mainly to make place in the emulator tab
This commit is contained in:
Megamouse 2018-05-29 23:25:45 +02:00 committed by Ivan
parent cf2cb7978b
commit cc50d503ef
3 changed files with 282 additions and 143 deletions

View file

@ -38,6 +38,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
bool showDebugTab = xgui_settings->GetValue(gui::m_showDebugTab).toBool();
xgui_settings->SetValue(gui::m_showDebugTab, showDebugTab);
if (!showDebugTab)
{
ui->tab_widget_settings->removeTab(8);
}
if (game)
{
ui->tab_widget_settings->removeTab(7);
}
@ -50,6 +54,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
SubscribeDescription(ui->description_system);
SubscribeDescription(ui->description_network);
SubscribeDescription(ui->description_emulator);
SubscribeDescription(ui->description_gui);
SubscribeDescription(ui->description_debug);
// read tooltips from json
@ -76,9 +81,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
QJsonObject json_net = json_obj.value("network").toObject();
QJsonObject json_emu = json_obj.value("emulator").toObject();
QJsonObject json_emu_gui = json_emu.value("gui").toObject();
QJsonObject json_emu_misc = json_emu.value("misc").toObject();
QJsonObject json_gui = json_obj.value("gui").toObject();
QJsonObject json_debug = json_obj.value("debug").toObject();
if (game)
@ -693,22 +699,12 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
SubscribeTooltip(ui->maxLLVMThreads, json_emu_misc["maxLLVMThreads"].toString());
ui->maxLLVMThreads->setItemText(ui->maxLLVMThreads->findData("0"), tr("All (%1)").arg(std::thread::hardware_concurrency()));
SubscribeTooltip(ui->combo_configs, json_emu_gui["configs"].toString());
SubscribeTooltip(ui->combo_stylesheets, json_emu_gui["stylesheets"].toString());
// Checkboxes
SubscribeTooltip(ui->gs_resizeOnBoot, json_emu_misc["gs_resizeOnBoot"].toString());
SubscribeTooltip(ui->gs_disableMouse, json_emu_misc["gs_disableMouse"].toString());
SubscribeTooltip(ui->cb_show_welcome, json_emu_gui["show_welcome"].toString());
SubscribeTooltip(ui->cb_custom_colors, json_emu_gui["custom_colors"].toString());
SubscribeTooltip(ui->useRichPresence, json_emu_gui["useRichPresence"].toString());
xemu_settings->EnhanceCheckBox(ui->exitOnStop, emu_settings::ExitRPCS3OnFinish);
SubscribeTooltip(ui->exitOnStop, json_emu_misc["exitOnStop"].toString());
@ -730,14 +726,71 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
xemu_settings->EnhanceCheckBox(ui->showShaderCompilationHint, emu_settings::ShowShaderCompilationHint);
SubscribeTooltip(ui->showShaderCompilationHint, json_emu_misc["showShaderCompilationHint"].toString());
if (game)
if (!game)
{
ui->gb_stylesheets->setEnabled(false);
ui->gb_settings->setEnabled(false);
ui->gb_colors->setEnabled(false);
ui->gb_viewport->setEnabled(false);
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);
});
bool enableButtons = xgui_settings->GetValue(gui::gs_resize).toBool();
ui->gs_resizeOnBoot->setChecked(enableButtons);
ui->gs_width->setEnabled(enableButtons);
ui->gs_height->setEnabled(enableButtons);
QRect screen = QApplication::desktop()->screenGeometry();
int width = xgui_settings->GetValue(gui::gs_width).toInt();
int height = xgui_settings->GetValue(gui::gs_height).toInt();
ui->gs_width->setValue(std::min(width, screen.width()));
ui->gs_height->setValue(std::min(height, screen.height()));
connect(ui->gs_resizeOnBoot, &QCheckBox::clicked, [=](bool val)
{
xgui_settings->SetValue(gui::gs_resize, val);
ui->gs_width->setEnabled(val);
ui->gs_height->setEnabled(val);
});
connect(ui->gs_width, &QSpinBox::editingFinished, [=]()
{
ui->gs_width->setValue(std::min(ui->gs_width->value(), QApplication::desktop()->screenGeometry().width()));
xgui_settings->SetValue(gui::gs_width, ui->gs_width->value());
});
connect(ui->gs_height, &QSpinBox::editingFinished, [=]()
{
ui->gs_height->setValue(std::min(ui->gs_height->value(), QApplication::desktop()->screenGeometry().height()));
xgui_settings->SetValue(gui::gs_height, ui->gs_height->value());
});
ui->useRichPresence->setChecked(xgui_settings->GetValue(gui::m_richPresence).toBool());
connect(ui->useRichPresence, &QCheckBox::clicked, [=](bool val)
{
xgui_settings->SetValue(gui::m_richPresence, val);
});
}
else
// _____ _ _ _ _______ _
// / ____|| | | || | |__ __| | |
// | | __|| | | || | | | __ _| |__
// | | |_ || | | || | | |/ _` | '_ \
// | |__| || |__| || | | | (_| | |_) |
// \_____| \____/ |_| |_|\__,_|_.__/
// Comboboxes
SubscribeTooltip(ui->combo_configs, json_gui["configs"].toString());
SubscribeTooltip(ui->combo_stylesheets, json_gui["stylesheets"].toString());
// Checkboxes:
SubscribeTooltip(ui->cb_custom_colors, json_gui["custom_colors"].toString());
// Checkboxes: gui options
SubscribeTooltip(ui->cb_show_welcome, json_gui["show_welcome"].toString());
SubscribeTooltip(ui->useRichPresence, json_gui["useRichPresence"].toString());
if (!game)
{
// colorize preview icons
auto addColoredIcon = [&](QPushButton *button, const QColor& color, const QIcon& icon = QIcon(), const QColor& iconColor = QColor())
@ -876,47 +929,6 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
colorDialog(gui::mw_toolIconColor, tr("Choose tool icon color"), ui->pb_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);
});
bool enableButtons = xgui_settings->GetValue(gui::gs_resize).toBool();
ui->gs_resizeOnBoot->setChecked(enableButtons);
ui->gs_width->setEnabled(enableButtons);
ui->gs_height->setEnabled(enableButtons);
QRect screen = QApplication::desktop()->screenGeometry();
int width = xgui_settings->GetValue(gui::gs_width).toInt();
int height = xgui_settings->GetValue(gui::gs_height).toInt();
ui->gs_width->setValue(std::min(width, screen.width()));
ui->gs_height->setValue(std::min(height, screen.height()));
connect(ui->gs_resizeOnBoot, &QCheckBox::clicked, [=](bool val)
{
xgui_settings->SetValue(gui::gs_resize, val);
ui->gs_width->setEnabled(val);
ui->gs_height->setEnabled(val);
});
connect(ui->gs_width, &QSpinBox::editingFinished, [=]()
{
ui->gs_width->setValue(std::min(ui->gs_width->value(), QApplication::desktop()->screenGeometry().width()));
xgui_settings->SetValue(gui::gs_width, ui->gs_width->value());
});
connect(ui->gs_height, &QSpinBox::editingFinished, [=]()
{
ui->gs_height->setValue(std::min(ui->gs_height->value(), QApplication::desktop()->screenGeometry().height()));
xgui_settings->SetValue(gui::gs_height, ui->gs_height->value());
});
ui->useRichPresence->setChecked(xgui_settings->GetValue(gui::m_richPresence).toBool());
connect(ui->useRichPresence, &QCheckBox::clicked, [=](bool val)
{
xgui_settings->SetValue(gui::m_richPresence, val);
});
AddConfigs();
AddStylesheets();
}