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.
This commit is contained in:
Roland Winklmeier
2016-08-15 23:50:36 +02:00
committed by Mathew Sutcliffe
parent c6bfd3b01d
commit 9515109719
2 changed files with 15 additions and 0 deletions

View File

@@ -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");

View File

@@ -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::CSettingsHotkeyComponent> ui;
BlackGui::Models::CActionHotkeyListModel m_model;