|
@@ -31,22 +31,6 @@ ConfigureHotkeys::ConfigureHotkeys(QWidget* parent)
|
|
|
|
|
|
|
|
ConfigureHotkeys::~ConfigureHotkeys() = default;
|
|
ConfigureHotkeys::~ConfigureHotkeys() = default;
|
|
|
|
|
|
|
|
-void ConfigureHotkeys::EmitHotkeysChanged() {
|
|
|
|
|
- emit HotkeysChanged(GetUsedKeyList());
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-QList<QKeySequence> ConfigureHotkeys::GetUsedKeyList() const {
|
|
|
|
|
- QList<QKeySequence> 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) {
|
|
void ConfigureHotkeys::Populate(const HotkeyRegistry& registry) {
|
|
|
for (const auto& group : registry.hotkey_groups) {
|
|
for (const auto& group : registry.hotkey_groups) {
|
|
|
auto* parent_item = new QStandardItem(group.first);
|
|
auto* parent_item = new QStandardItem(group.first);
|
|
@@ -83,16 +67,29 @@ void ConfigureHotkeys::Configure(QModelIndex index) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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"),
|
|
|
|
|
- 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 {
|
|
} else {
|
|
|
model->setData(index, key_sequence.toString(QKeySequence::NativeText));
|
|
model->setData(index, key_sequence.toString(QKeySequence::NativeText));
|
|
|
- EmitHotkeysChanged();
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool ConfigureHotkeys::IsUsedKey(QKeySequence key_sequence) const {
|
|
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) {
|
|
void ConfigureHotkeys::applyConfiguration(HotkeyRegistry& registry) {
|
|
@@ -114,7 +111,6 @@ void ConfigureHotkeys::applyConfiguration(HotkeyRegistry& registry) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
registry.SaveHotkeys();
|
|
registry.SaveHotkeys();
|
|
|
- Settings::Apply();
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ConfigureHotkeys::retranslateUi() {
|
|
void ConfigureHotkeys::retranslateUi() {
|