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:
parent
0a5621fafc
commit
cb1825a769
8 changed files with 177 additions and 136 deletions
|
@ -4,11 +4,14 @@
|
|||
|
||||
#include "citra_qt/configuration/config.h"
|
||||
#include "citra_qt/configuration/configure_dialog.h"
|
||||
#include "citra_qt/hotkeys.h"
|
||||
#include "core/settings.h"
|
||||
#include "ui_configure.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();
|
||||
connect(ui->generalTab, &ConfigureGeneral::languageChanged, this,
|
||||
&ConfigureDialog::onLanguageChanged);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -56,6 +56,10 @@ void ConfigureGeneral::setConfiguration() {
|
|||
ui->language_combobox->findData(UISettings::values.language));
|
||||
}
|
||||
|
||||
void ConfigureGeneral::PopulateHotkeyList(const HotkeyRegistry& registry) {
|
||||
ui->hotkeysDialog->Populate(registry);
|
||||
}
|
||||
|
||||
void ConfigureGeneral::applyConfiguration() {
|
||||
UISettings::values.confirm_before_closing = ui->toggle_check_exit->isChecked();
|
||||
UISettings::values.theme =
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <memory>
|
||||
#include <QWidget>
|
||||
|
||||
class HotkeyRegistry;
|
||||
|
||||
namespace Ui {
|
||||
class ConfigureGeneral;
|
||||
}
|
||||
|
@ -18,6 +20,7 @@ public:
|
|||
explicit ConfigureGeneral(QWidget* parent = nullptr);
|
||||
~ConfigureGeneral();
|
||||
|
||||
void PopulateHotkeyList(const HotkeyRegistry& registry);
|
||||
void applyConfiguration();
|
||||
void retranslateUi();
|
||||
|
||||
|
@ -30,6 +33,5 @@ signals:
|
|||
private:
|
||||
void setConfiguration();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::ConfigureGeneral> ui;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue