configure_debug: Port to support both per-game and global modes

This commit is contained in:
Zach Hilman
2018-10-17 21:30:57 -04:00
parent f33be7c01c
commit 0f042773d3
3 changed files with 45 additions and 3 deletions

View File

@@ -18,14 +18,35 @@
ConfigureDebug::ConfigureDebug(QWidget* parent) : QWidget(parent), ui(new Ui::ConfigureDebug) {
ui->setupUi(this);
this->setConfiguration();
connect(ui->open_log_button, &QPushButton::pressed, []() {
QString path = QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::LogDir));
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
});
connect(ui->homebrew_args_edit, &QLineEdit::textChanged, [this](const QString& str) {
if (!ui->program_args_checkbox->isHidden())
ui->program_args_checkbox->setChecked(true);
});
}
ConfigureDebug::~ConfigureDebug() = default;
void ConfigureDebug::setPerGame(bool per_game) {
ui->override_label->setHidden(!per_game);
ui->program_args_checkbox->setHidden(!per_game);
ui->groupBox_2->setHidden(per_game);
ui->groupBox->setHidden(per_game);
}
void ConfigureDebug::loadValuesChange(const PerGameValuesChange& change) {
ui->program_args_checkbox->setChecked(change.program_args);
}
void ConfigureDebug::mergeValuesChange(PerGameValuesChange& change) {
change.program_args = ui->program_args_checkbox->isChecked();
}
void ConfigureDebug::setConfiguration() {
ui->toggle_gdbstub->setChecked(Settings::values.use_gdbstub);
ui->gdbport_spinbox->setEnabled(Settings::values.use_gdbstub);
@@ -33,7 +54,7 @@ void ConfigureDebug::setConfiguration() {
ui->toggle_console->setEnabled(!Core::System::GetInstance().IsPoweredOn());
ui->toggle_console->setChecked(UISettings::values.show_console);
ui->log_filter_edit->setText(QString::fromStdString(Settings::values.log_filter));
ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values.program_args));
ui->homebrew_args_edit->setText(QString::fromStdString(Settings::values->program_args));
}
void ConfigureDebug::applyConfiguration() {
@@ -41,7 +62,7 @@ void ConfigureDebug::applyConfiguration() {
Settings::values.gdbstub_port = ui->gdbport_spinbox->value();
UISettings::values.show_console = ui->toggle_console->isChecked();
Settings::values.log_filter = ui->log_filter_edit->text().toStdString();
Settings::values.program_args = ui->homebrew_args_edit->text().toStdString();
Settings::values->program_args = ui->homebrew_args_edit->text().toStdString();
Debugger::ToggleConsole();
Log::Filter filter;
filter.ParseFilterString(Settings::values.log_filter);

View File

@@ -6,6 +6,7 @@
#include <memory>
#include <QWidget>
#include "configuration/config.h"
namespace Ui {
class ConfigureDebug;
@@ -20,9 +21,12 @@ public:
void applyConfiguration();
void setPerGame(bool per_game);
void loadValuesChange(const PerGameValuesChange& change);
void mergeValuesChange(PerGameValuesChange& change);
private:
void setConfiguration();
private:
std::unique_ptr<Ui::ConfigureDebug> ui;
};

View File

@@ -124,6 +124,13 @@
<item>
<widget class="QLineEdit" name="homebrew_args_edit"/>
</item>
<item>
<widget class="QCheckBox" name="program_args_checkbox">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
</layout>
@@ -142,6 +149,16 @@
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="override_label">
<property name="text">
<string>Check the box next to the homebrew arguments string to override the global default setting with this one for this game only.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>