Ref T211, hotkey dialog fixes

* add identifier of current hotkey if any
* utility function getAllIdentifiers
* setWindowFlags to hide "?"
This commit is contained in:
Klaus Basan
2017-12-19 06:28:22 +01:00
parent aaf4c35f80
commit 3cc3440bba
3 changed files with 15 additions and 15 deletions

View File

@@ -69,6 +69,7 @@ namespace BlackGui
m_actionHotkey(actionHotkey), m_actionHotkey(actionHotkey),
m_actionModel(this) m_actionModel(this)
{ {
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
m_inputManager = BlackCore::CInputManager::instance(); m_inputManager = BlackCore::CInputManager::instance();
ui->setupUi(this); ui->setupUi(this);
@@ -80,15 +81,22 @@ namespace BlackGui
if (!actionHotkey.getCombination().isEmpty()) { ui->pb_SelectedHotkey->setText(actionHotkey.getCombination().toQString()); } 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; int index = -1;
const CIdentifierList machinesUnique = applications.getMachinesUnique(); const CIdentifierList machineIdentifiersUnique = machineIdentifiers.getMachinesUnique();
for (const auto &app : machinesUnique) for (const auto &app : machineIdentifiersUnique)
{ {
ui->cb_Identifier->addItem(app.getMachineName(), QVariant::fromValue(app)); ui->cb_Identifier->addItem(app.getMachineName(), QVariant::fromValue(app));
if (m_actionHotkey.getApplicableMachine().isFromSameMachine(app)) { index = ui->cb_Identifier->count() - 1; } 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); ui->cb_Identifier->setCurrentIndex(index);
} }

View File

@@ -71,12 +71,7 @@ namespace BlackGui
void CSettingsHotkeyComponent::addEntry() void CSettingsHotkeyComponent::addEntry()
{ {
BlackMisc::CIdentifierList registeredApps; const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), getAllIdentifiers(), this);
if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications();
// add local application
registeredApps.push_back(CIdentifier());
const auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), registeredApps, this);
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey)) if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
{ {
addHotkeytoSettings(selectedActionHotkey); addHotkeytoSettings(selectedActionHotkey);
@@ -96,13 +91,8 @@ namespace BlackGui
const QModelIndex indexHotkey = model->index(index.row(), 0, QModelIndex()); const QModelIndex indexHotkey = model->index(index.row(), 0, QModelIndex());
Q_ASSERT_X(indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).canConvert<CActionHotkey>(), Q_FUNC_INFO, "No action hotkey"); Q_ASSERT_X(indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).canConvert<CActionHotkey>(), Q_FUNC_INFO, "No action hotkey");
CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>(); CActionHotkey actionHotkey = indexHotkey.data(CActionHotkeyListModel::ActionHotkeyRole).value<CActionHotkey>();
BlackMisc::CIdentifierList registeredApps;
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
if (sGui->getIContextApplication()) registeredApps = sGui->getIContextApplication()->getRegisteredApplications();
// add local application const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(actionHotkey, getAllIdentifiers(), this);
registeredApps.push_back(CIdentifier());
const auto selectedActionHotkey = CHotkeyDialog::getActionHotkey(actionHotkey, registeredApps, this);
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey, { actionHotkey })) if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey, { actionHotkey }))
{ {
updateHotkeyInSettings(actionHotkey, selectedActionHotkey); updateHotkeyInSettings(actionHotkey, selectedActionHotkey);

View File

@@ -16,6 +16,7 @@
#include "blackgui/models/actionhotkeylistmodel.h" #include "blackgui/models/actionhotkeylistmodel.h"
#include "blackcore/actionbind.h" #include "blackcore/actionbind.h"
#include "blackcore/application/applicationsettings.h" #include "blackcore/application/applicationsettings.h"
#include "blackmisc/identifierlist.h"
#include "blackmisc/settingscache.h" #include "blackmisc/settingscache.h"
#include "blackmisc/icons.h" #include "blackmisc/icons.h"
@@ -60,6 +61,7 @@ namespace BlackGui
void removeHotkeyFromSettings(const BlackMisc::Input::CActionHotkey &actionHotkey); void removeHotkeyFromSettings(const BlackMisc::Input::CActionHotkey &actionHotkey);
bool checkAndConfirmConflicts(const BlackMisc::Input::CActionHotkey &actionHotkey, const BlackMisc::Input::CActionHotkeyList &ignore = {}); bool checkAndConfirmConflicts(const BlackMisc::Input::CActionHotkey &actionHotkey, const BlackMisc::Input::CActionHotkeyList &ignore = {});
void reloadHotkeysFromSettings(); void reloadHotkeysFromSettings();
BlackMisc::CIdentifierList getAllIdentifiers() const;
QScopedPointer<Ui::CSettingsHotkeyComponent> ui; QScopedPointer<Ui::CSettingsHotkeyComponent> ui;
BlackGui::Models::CActionHotkeyListModel m_model; BlackGui::Models::CActionHotkeyListModel m_model;