mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
[Hotkey] Display hotkey name plus device name in hotkey model, resize view if new key has been added or removed
This commit is contained in:
committed by
Mat Sutcliffe
parent
ef4640e66f
commit
2a34786039
@@ -76,12 +76,13 @@ namespace BlackGui
|
||||
const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), getAllIdentifiers(), this);
|
||||
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
|
||||
{
|
||||
addHotkeytoSettings(selectedActionHotkey);
|
||||
addHotkeyToSettings(selectedActionHotkey);
|
||||
const int position = m_model.rowCount();
|
||||
m_model.insertRows(position, 1, QModelIndex());
|
||||
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
||||
m_model.setData(index, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||
}
|
||||
this->resizeView();
|
||||
}
|
||||
|
||||
void CSettingsHotkeyComponent::editEntry()
|
||||
@@ -100,6 +101,7 @@ namespace BlackGui
|
||||
updateHotkeyInSettings(actionHotkey, selectedActionHotkey);
|
||||
m_model.setData(indexHotkey, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||
}
|
||||
this->resizeView();
|
||||
}
|
||||
|
||||
void CSettingsHotkeyComponent::removeEntry()
|
||||
@@ -111,9 +113,10 @@ namespace BlackGui
|
||||
removeHotkeyFromSettings(actionHotkey);
|
||||
m_model.removeRows(index.row(), 1, QModelIndex());
|
||||
}
|
||||
this->resizeView();
|
||||
}
|
||||
|
||||
void CSettingsHotkeyComponent::addHotkeytoSettings(const CActionHotkey &actionHotkey)
|
||||
void CSettingsHotkeyComponent::addHotkeyToSettings(const CActionHotkey &actionHotkey)
|
||||
{
|
||||
CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal());
|
||||
actionHotkeyList.push_back(actionHotkey);
|
||||
@@ -171,6 +174,7 @@ namespace BlackGui
|
||||
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
||||
m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||
}
|
||||
this->resizeView();
|
||||
}
|
||||
|
||||
CIdentifierList CSettingsHotkeyComponent::getAllIdentifiers() const
|
||||
@@ -184,6 +188,11 @@ namespace BlackGui
|
||||
return identifiers;
|
||||
}
|
||||
|
||||
void CSettingsHotkeyComponent::resizeView()
|
||||
{
|
||||
ui->tv_Hotkeys->resizeRowsToContents();
|
||||
}
|
||||
|
||||
void CSettingsHotkeyComponent::hotkeySlot(bool keyDown)
|
||||
{
|
||||
if (keyDown)
|
||||
|
||||
@@ -55,11 +55,12 @@ namespace BlackGui
|
||||
void editEntry();
|
||||
void removeEntry();
|
||||
void hotkeySlot(bool keyDown);
|
||||
void addHotkeytoSettings(const BlackMisc::Input::CActionHotkey &actionHotkey);
|
||||
void addHotkeyToSettings(const BlackMisc::Input::CActionHotkey &actionHotkey);
|
||||
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 = {});
|
||||
BlackMisc::CIdentifierList getAllIdentifiers() const;
|
||||
void resizeView();
|
||||
|
||||
QScopedPointer<Ui::CSettingsHotkeyComponent> ui;
|
||||
Models::CActionHotkeyListModel m_model; //!< hotkeys model
|
||||
|
||||
@@ -43,17 +43,19 @@ namespace BlackGui
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
{
|
||||
if (index.column() == 0)
|
||||
const int col = index.column();
|
||||
if (col == 0)
|
||||
{
|
||||
const CIdentifier identifier = m_actionHotkeys[index.row()].getApplicableMachine();
|
||||
return identifier.getMachineName();
|
||||
}
|
||||
if (index.column() == 1)
|
||||
if (col == 1)
|
||||
{
|
||||
CHotkeyCombination combination = m_actionHotkeys[index.row()].getCombination();
|
||||
return combination.toQString();
|
||||
const CHotkeyCombination combination = m_actionHotkeys[index.row()].getCombination();
|
||||
return combination.asStringWithDeviceNames();
|
||||
// return combination.toQString();
|
||||
}
|
||||
if (index.column() == 2)
|
||||
if (col == 2)
|
||||
{
|
||||
return m_actionHotkeys[index.row()].getAction();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user