mirror of
https://github.com/yuzu-emu/yuzu-android.git
synced 2025-06-26 20:17:52 -05:00
qt/hotkey: Get rid of global hotkey map instance
Instead, we make a proper registry class and house it within the main window, then pass it to whatever needs access to the loaded hotkeys. This way, we avoid a global variable, and don't need to initialize a std::map instance before the program can do anything.
This commit is contained in:
@ -6,9 +6,12 @@
|
||||
#include "ui_configure.h"
|
||||
#include "yuzu/configuration/config.h"
|
||||
#include "yuzu/configuration/configure_dialog.h"
|
||||
#include "yuzu/hotkeys.h"
|
||||
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ConfigureDialog) {
|
||||
ConfigureDialog::ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry)
|
||||
: QDialog(parent), ui(new Ui::ConfigureDialog) {
|
||||
ui->setupUi(this);
|
||||
ui->generalTab->PopulateHotkeyList(registry);
|
||||
this->setConfiguration();
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <QDialog>
|
||||
|
||||
class HotkeyRegistry;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureDialog;
|
||||
}
|
||||
@ -15,7 +17,7 @@ class ConfigureDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ConfigureDialog(QWidget* parent);
|
||||
explicit ConfigureDialog(QWidget* parent, const HotkeyRegistry& registry);
|
||||
~ConfigureDialog();
|
||||
|
||||
void applyConfiguration();
|
||||
|
@ -35,6 +35,10 @@ void ConfigureGeneral::setConfiguration() {
|
||||
ui->use_docked_mode->setChecked(Settings::values.use_docked_mode);
|
||||
}
|
||||
|
||||
void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) {
|
||||
ui->widget->Populate(registry);
|
||||
}
|
||||
|
||||
void ConfigureGeneral::applyConfiguration() {
|
||||
UISettings::values.gamedir_deepscan = ui->toggle_deepscan->isChecked();
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <memory>
|
||||
#include <QWidget>
|
||||
|
||||
class HotkeyRegistry;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureGeneral;
|
||||
}
|
||||
@ -18,11 +20,11 @@ public:
|
||||
explicit ConfigureGeneral(QWidget* parent = nullptr);
|
||||
~ConfigureGeneral();
|
||||
|
||||
void PopulateHotkeyList(const HotkeyRegistry& registry);
|
||||
void applyConfiguration();
|
||||
|
||||
private:
|
||||
void setConfiguration();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureGeneral> ui;
|
||||
};
|
||||
|
Reference in New Issue
Block a user