1
0
Fork 0
forked from suyu/suyu

Merge pull request #2376 from lioncash/const

yuzu/configure_hotkey: Minor changes
This commit is contained in:
bunnei 2019-04-16 22:13:12 -04:00 committed by GitHub
commit 2654eb659e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 12 deletions

View file

@ -12,7 +12,7 @@
#include "yuzu/hotkeys.h"
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry)
: QDialog(parent), registry(registry), ui(new Ui::ConfigureDialog) {
: QDialog(parent), ui(new Ui::ConfigureDialog), registry(registry) {
ui->setupUi(this);
ui->hotkeysTab->Populate(registry);
this->setConfiguration();

View file

@ -66,20 +66,21 @@ void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) {
}
void ConfigureHotkeys::Configure(QModelIndex index) {
if (index.parent() == QModelIndex())
if (!index.parent().isValid()) {
return;
}
index = index.sibling(index.row(), 1);
auto* model = ui->hotkey_list->model();
auto previous_key = model->data(index);
auto* const model = ui->hotkey_list->model();
const auto previous_key = model->data(index);
auto* hotkey_dialog = new SequenceDialog;
int return_code = hotkey_dialog->exec();
SequenceDialog hotkey_dialog{this};
auto key_sequence = hotkey_dialog->GetSequence();
if (return_code == QDialog::Rejected || key_sequence.isEmpty())
const int return_code = hotkey_dialog.exec();
const auto key_sequence = hotkey_dialog.GetSequence();
if (return_code == QDialog::Rejected || key_sequence.isEmpty()) {
return;
}
if (IsUsedKey(key_sequence) && key_sequence != QKeySequence(previous_key.toString())) {
QMessageBox::critical(this, tr("Error in inputted key"),
@ -90,7 +91,7 @@ void ConfigureHotkeys::Configure(QModelIndex index) {
}
}
bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) {
bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) const {
return GetUsedKeyList().contains(key_sequence);
}

View file

@ -6,7 +6,6 @@
#include <memory>
#include <QWidget>
#include "core/settings.h"
namespace Ui {
class ConfigureHotkeys;
@ -39,7 +38,7 @@ signals:
private:
void Configure(QModelIndex index);
bool IsUsedKey(QKeySequence key_sequence);
bool IsUsedKey(QKeySequence key_sequence) const;
QList<QKeySequence> GetUsedKeyList() const;
std::unique_ptr<Ui::ConfigureHotkeys> ui;