From 3cc3440bbaaabb706dc185b5f8485cea329c90f0 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 19 Dec 2017 06:28:22 +0100 Subject: [PATCH] Ref T211, hotkey dialog fixes * add identifier of current hotkey if any * utility function getAllIdentifiers * setWindowFlags to hide "?" --- src/blackgui/components/hotkeydialog.cpp | 14 +++++++++++--- .../components/settingshotkeycomponent.cpp | 14 ++------------ src/blackgui/components/settingshotkeycomponent.h | 2 ++ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/blackgui/components/hotkeydialog.cpp b/src/blackgui/components/hotkeydialog.cpp index 84ff7a4bd..ecd6ad7c0 100644 --- a/src/blackgui/components/hotkeydialog.cpp +++ b/src/blackgui/components/hotkeydialog.cpp @@ -69,6 +69,7 @@ namespace BlackGui m_actionHotkey(actionHotkey), m_actionModel(this) { + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); m_inputManager = BlackCore::CInputManager::instance(); ui->setupUi(this); @@ -80,15 +81,22 @@ namespace BlackGui if (!actionHotkey.getCombination().isEmpty()) { ui->pb_SelectedHotkey->setText(actionHotkey.getCombination().toQString()); } + CIdentifierList machineIdentifiers(identifiers); + if (actionHotkey.isValid()) { machineIdentifiers.push_back(actionHotkey.getApplicableMachine()); } int index = -1; - const CIdentifierList machinesUnique = applications.getMachinesUnique(); - for (const auto &app : machinesUnique) + const CIdentifierList machineIdentifiersUnique = machineIdentifiers.getMachinesUnique(); + for (const auto &app : machineIdentifiersUnique) { ui->cb_Identifier->addItem(app.getMachineName(), QVariant::fromValue(app)); if (m_actionHotkey.getApplicableMachine().isFromSameMachine(app)) { index = ui->cb_Identifier->count() - 1; } } - if (index != ui->cb_Identifier->currentIndex()) + if (index < 0 && ui->cb_Identifier->count() > 0) + { + // if nothing was found + ui->cb_Identifier->setCurrentIndex(0); + } + else if (index != ui->cb_Identifier->currentIndex()) { ui->cb_Identifier->setCurrentIndex(index); } diff --git a/src/blackgui/components/settingshotkeycomponent.cpp b/src/blackgui/components/settingshotkeycomponent.cpp index f5a815e92..3d9f35f5f 100644 --- a/src/blackgui/components/settingshotkeycomponent.cpp +++ b/src/blackgui/components/settingshotkeycomponent.cpp @@ -71,12 +71,7 @@ namespace BlackGui void CSettingsHotkeyComponent::addEntry() { - BlackMisc::CIdentifierList registeredApps; - if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications(); - - // add local application - registeredApps.push_back(CIdentifier()); - const auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), registeredApps, this); + const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), getAllIdentifiers(), this); if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey)) { addHotkeytoSettings(selectedActionHotkey); @@ -96,13 +91,8 @@ namespace BlackGui const QModelIndex indexHotkey = model->index(index.row(), 0, QModelIndex()); Q_ASSERT_X(indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).canConvert(), Q_FUNC_INFO, "No action hotkey"); CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value(); - BlackMisc::CIdentifierList registeredApps; - Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui"); - if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications(); - // add local application - registeredApps.push_back(CIdentifier()); - const auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(actionHotkey, registeredApps, this); + const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(actionHotkey, getAllIdentifiers(), this); if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey, { actionHotkey })) { updateHotkeyInSettings(actionHotkey, selectedActionHotkey); diff --git a/src/blackgui/components/settingshotkeycomponent.h b/src/blackgui/components/settingshotkeycomponent.h index b00e28ecf..20ba8e337 100644 --- a/src/blackgui/components/settingshotkeycomponent.h +++ b/src/blackgui/components/settingshotkeycomponent.h @@ -16,6 +16,7 @@ #include "blackgui/models/actionhotkeylistmodel.h" #include "blackcore/actionbind.h" #include "blackcore/application/applicationsettings.h" +#include "blackmisc/identifierlist.h" #include "blackmisc/settingscache.h" #include "blackmisc/icons.h" @@ -60,6 +61,7 @@ namespace BlackGui void removeHotkeyFromSettings(const BlackMisc::Input::CActionHotkey &actionHotkey); bool checkAndConfirmConflicts(const BlackMisc::Input::CActionHotkey &actionHotkey, const BlackMisc::Input::CActionHotkeyList &ignore = {}); void reloadHotkeysFromSettings(); + BlackMisc::CIdentifierList getAllIdentifiers() const; QScopedPointer ui; BlackGui::Models::CActionHotkeyListModel m_model;