From c03fb00ac142e27ba8d7e7cc1dde0539375b7d96 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 25 May 2019 03:53:41 -0400 Subject: configure_hotkeys: Remove unused EmitHotkeysChanged() 1. This is something that should be solely emitted by the hotkey dialog itself 2. This is functionally unused, given there's nothing listening for the signal. --- src/yuzu/configuration/configure_hotkeys.cpp | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src/yuzu/configuration/configure_hotkeys.cpp') diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index a7a8752e5..9155da4e8 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -31,10 +31,6 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent) ConfigureHotkeys::~ConfigureHotkeys() = default; -void ConfigureHotkeys::EmitHotkeysChanged() { - emit HotkeysChanged(GetUsedKeyList()); -} - QList ConfigureHotkeys::GetUsedKeyList() const { QList list; for (int r = 0; r < model->rowCount(); r++) { @@ -87,7 +83,6 @@ void ConfigureHotkeys::Configure(QModelIndex index) { tr("You're using a key that's already bound.")); } else { model->setData(index, key_sequence.toString(QKeySequence::NativeText)); - EmitHotkeysChanged(); } } -- cgit v1.2.3 From ef3c0f54d0cdfc3a4a24daac93ecc65a4359b0df Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 25 May 2019 04:03:15 -0400 Subject: configure_hotkeys: Move conflict detection logic to IsUsedKey() We don't need to extract the entire set of hotkeys into a list and then iterate through it. We can traverse the list and early-exit if we're able to. --- src/yuzu/configuration/configure_hotkeys.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/yuzu/configuration/configure_hotkeys.cpp') diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 9155da4e8..02f2daabc 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -31,18 +31,6 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent) ConfigureHotkeys::~ConfigureHotkeys() = default; -QList ConfigureHotkeys::GetUsedKeyList() const { - QList list; - for (int r = 0; r < model->rowCount(); r++) { - const QStandardItem* parent = model->item(r, 0); - for (int r2 = 0; r2 < parent->rowCount(); r2++) { - const QStandardItem* keyseq = parent->child(r2, 1); - list << QKeySequence::fromString(keyseq->text(), QKeySequence::NativeText); - } - } - return list; -} - void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) { for (const auto& group : registry.hotkey_groups) { auto* parent_item = new QStandardItem(group.first); @@ -87,7 +75,21 @@ void ConfigureHotkeys::Configure(QModelIndex index) { } bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) const { - return GetUsedKeyList().contains(key_sequence); + for (int r = 0; r < model->rowCount(); r++) { + const QStandardItem* const parent = model->item(r, 0); + + for (int r2 = 0; r2 < parent->rowCount(); r2++) { + const QStandardItem* const key_seq_item = parent->child(r2, 1); + const auto key_seq_str = key_seq_item->text(); + const auto key_seq = QKeySequence::fromString(key_seq_str, QKeySequence::NativeText); + + if (key_sequence == key_seq) { + return true; + } + } + } + + return false; } void ConfigureHotkeys::applyConfiguration(HotkeyRegistry& registry) { -- cgit v1.2.3 From d61199721d4815841edd564ee2153cff11e66996 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 25 May 2019 04:06:48 -0400 Subject: configure_hotkeys: Change critical error dialog into a warning dialog critical() is intended for critical/fatal errors that threaten the overall stability of an application. A user entering a conflicting key sequence is neither of those. --- src/yuzu/configuration/configure_hotkeys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configure_hotkeys.cpp') diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 02f2daabc..583fd6a0e 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -67,8 +67,8 @@ void ConfigureHotkeys::Configure(QModelIndex index) { } if (IsUsedKey(key_sequence) && key_sequence != QKeySequence(previous_key.toString())) { - QMessageBox::critical(this, tr("Error in inputted key"), - tr("You're using a key that's already bound.")); + QMessageBox::warning(this, tr("Error in inputted key"), + tr("You're using a key that's already bound.")); } else { model->setData(index, key_sequence.toString(QKeySequence::NativeText)); } -- cgit v1.2.3 From 6640f631e2a97f376c42ef2e1e5a316ab61d9dc5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 25 May 2019 04:19:51 -0400 Subject: configure_hotkeys: Tidy up key sequence conflict error string Avoids mentioning the user and formalizes the error itself. --- src/yuzu/configuration/configure_hotkeys.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/yuzu/configuration/configure_hotkeys.cpp') diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index 583fd6a0e..c486ac2ed 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -67,8 +67,8 @@ void ConfigureHotkeys::Configure(QModelIndex index) { } if (IsUsedKey(key_sequence) && key_sequence != QKeySequence(previous_key.toString())) { - QMessageBox::warning(this, tr("Error in inputted key"), - tr("You're using a key that's already bound.")); + QMessageBox::warning(this, tr("Conflicting Key Sequence"), + tr("The entered key sequence is already assigned to another hotkey.")); } else { model->setData(index, key_sequence.toString(QKeySequence::NativeText)); } -- cgit v1.2.3 From 88cd5e888e6bcd611dbcd18648697ef2e6bcba04 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 25 May 2019 04:34:51 -0400 Subject: configure_hotkeys: Remove unnecessary Settings::Apply() call Nothing from the hotkeys dialog relies on this call occurring, and is already called from the dialog that calls applyConfiguration(). --- src/yuzu/configuration/configure_hotkeys.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/yuzu/configuration/configure_hotkeys.cpp') diff --git a/src/yuzu/configuration/configure_hotkeys.cpp b/src/yuzu/configuration/configure_hotkeys.cpp index c486ac2ed..9fb970c21 100644 --- a/src/yuzu/configuration/configure_hotkeys.cpp +++ b/src/yuzu/configuration/configure_hotkeys.cpp @@ -111,7 +111,6 @@ void ConfigureHotkeys::applyConfiguration(HotkeyRegistry& registry) { } registry.SaveHotkeys(); - Settings::Apply(); } void ConfigureHotkeys::retranslateUi() { -- cgit v1.2.3