Merge pull request #4744 from FearlessTobi/port-2376
Port yuzu-emu/yuzu#2376: "yuzu/configure_hotkey: Minor changes"
This commit is contained in:
commit
6848592044
@ -11,7 +11,7 @@
|
|||||||
#include "ui_configure.h"
|
#include "ui_configure.h"
|
||||||
|
|
||||||
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, bool enable_web_config)
|
ConfigureDialog::ConfigureDialog(QWidget* parent, HotkeyRegistry& registry, bool enable_web_config)
|
||||||
: QDialog(parent), registry(registry), ui(new Ui::ConfigureDialog) {
|
: QDialog(parent), ui(new Ui::ConfigureDialog), registry(registry) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->hotkeysTab->Populate(registry);
|
ui->hotkeysTab->Populate(registry);
|
||||||
ui->webTab->SetWebServiceConfigEnabled(enable_web_config);
|
ui->webTab->SetWebServiceConfigEnabled(enable_web_config);
|
||||||
|
@ -35,7 +35,7 @@ void ConfigureHotkeys::EmitHotkeysChanged() {
|
|||||||
emit HotkeysChanged(GetUsedKeyList());
|
emit HotkeysChanged(GetUsedKeyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<QKeySequence> ConfigureHotkeys::GetUsedKeyList() {
|
QList<QKeySequence> ConfigureHotkeys::GetUsedKeyList() const {
|
||||||
QList<QKeySequence> list;
|
QList<QKeySequence> list;
|
||||||
for (int r = 0; r < model->rowCount(); r++) {
|
for (int r = 0; r < model->rowCount(); r++) {
|
||||||
QStandardItem* parent = model->item(r, 0);
|
QStandardItem* parent = model->item(r, 0);
|
||||||
@ -70,20 +70,21 @@ void ConfigureHotkeys::OnInputKeysChanged(QList<QKeySequence> new_key_list) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureHotkeys::Configure(QModelIndex index) {
|
void ConfigureHotkeys::Configure(QModelIndex index) {
|
||||||
if (index.parent() == QModelIndex())
|
if (!index.parent().isValid()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
index = index.sibling(index.row(), 1);
|
index = index.sibling(index.row(), 1);
|
||||||
auto* model = ui->hotkey_list->model();
|
auto* const model = ui->hotkey_list->model();
|
||||||
auto previous_key = model->data(index);
|
const auto previous_key = model->data(index);
|
||||||
|
|
||||||
auto* hotkey_dialog = new SequenceDialog;
|
SequenceDialog hotkey_dialog{this};
|
||||||
int return_code = hotkey_dialog->exec();
|
|
||||||
|
|
||||||
auto key_sequence = hotkey_dialog->GetSequence();
|
const int return_code = hotkey_dialog.exec();
|
||||||
|
const auto key_sequence = hotkey_dialog.GetSequence();
|
||||||
if (return_code == QDialog::Rejected || key_sequence.isEmpty())
|
if (return_code == QDialog::Rejected || key_sequence.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsUsedKey(key_sequence) && key_sequence != QKeySequence(previous_key.toString())) {
|
if (IsUsedKey(key_sequence) && key_sequence != QKeySequence(previous_key.toString())) {
|
||||||
QMessageBox::critical(this, tr("Error in inputted key"),
|
QMessageBox::critical(this, tr("Error in inputted key"),
|
||||||
@ -94,7 +95,7 @@ void ConfigureHotkeys::Configure(QModelIndex index) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) {
|
bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) const {
|
||||||
return input_keys_list.contains(key_sequence) || GetUsedKeyList().contains(key_sequence);
|
return input_keys_list.contains(key_sequence) || GetUsedKeyList().contains(key_sequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "core/settings.h"
|
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class ConfigureHotkeys;
|
class ConfigureHotkeys;
|
||||||
@ -42,8 +41,8 @@ signals:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void Configure(QModelIndex index);
|
void Configure(QModelIndex index);
|
||||||
bool IsUsedKey(QKeySequence key_sequence);
|
bool IsUsedKey(QKeySequence key_sequence) const;
|
||||||
QList<QKeySequence> GetUsedKeyList();
|
QList<QKeySequence> GetUsedKeyList() const;
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureHotkeys> ui;
|
std::unique_ptr<Ui::ConfigureHotkeys> ui;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user