From 951510971915ef3c5c22495e42cd6d4dc2e09e9f Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Mon, 15 Aug 2016 23:50:36 +0200 Subject: [PATCH] Initially fill hotkey settings component from settings When the component was constructed, the table view with configured hotkeys was empty even if hotkeys were configured. This commit reloads the configured settings during component construction and populates the table. --- .../components/settingshotkeycomponent.cpp | 14 ++++++++++++++ src/blackgui/components/settingshotkeycomponent.h | 1 + 2 files changed, 15 insertions(+) diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index 10fc23a59..871d6be47 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -48,6 +48,7 @@ namespace BlackGui connect(ui->pb_editHotkey, &QPushButton::clicked, this, &CSettingsHotkeyComponent::ps_editEntry); connect(ui->pb_removeHotkey, &QPushButton::clicked, this, &CSettingsHotkeyComponent::ps_removeEntry); + reloadHotkeysFromSettings(); ui->tv_hotkeys->selectRow(0); } @@ -149,6 +150,19 @@ namespace BlackGui return true; } + void CSettingsHotkeyComponent::reloadHotkeysFromSettings() + { + const CActionHotkeyList hotkeys = m_actionHotkeys.getThreadLocal(); + m_model.clear(); + for (const auto &hotkey : hotkeys) + { + int position = m_model.rowCount(); + m_model.insertRows(position, 1, QModelIndex()); + QModelIndex index = m_model.index(position, 0, QModelIndex()); + m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole); + } + } + void CSettingsHotkeyComponent::ps_hotkeySlot(bool keyDown) { if (keyDown) QMessageBox::information(this, "Test", "Push-To-Talk"); diff --git a/src/blackgui/components/settingshotkeycomponent.h b/src/blackgui/components/settingshotkeycomponent.h index b917cb721..8d1f809bc 100644 --- a/src/blackgui/components/settingshotkeycomponent.h +++ b/src/blackgui/components/settingshotkeycomponent.h @@ -55,6 +55,7 @@ namespace BlackGui void updateHotkeyInSettings(const BlackMisc::Input::CActionHotkey &oldValue, const BlackMisc::Input::CActionHotkey &newValue); void removeHotkeyFromSettings(const BlackMisc::Input::CActionHotkey &actionHotkey); bool checkAndConfirmConflicts(const BlackMisc::Input::CActionHotkey &actionHotkey, const BlackMisc::Input::CActionHotkeyList &ignore = {}); + void reloadHotkeysFromSettings(); QScopedPointer ui; BlackGui::Models::CActionHotkeyListModel m_model;