mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 12:35:43 +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);
|
const CActionHotkey selectedActionHotkey = CHotkeyDialog::getActionHotkey(CActionHotkey(), getAllIdentifiers(), this);
|
||||||
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
|
if (selectedActionHotkey.isValid() && checkAndConfirmConflicts(selectedActionHotkey))
|
||||||
{
|
{
|
||||||
addHotkeytoSettings(selectedActionHotkey);
|
addHotkeyToSettings(selectedActionHotkey);
|
||||||
const int position = m_model.rowCount();
|
const int position = m_model.rowCount();
|
||||||
m_model.insertRows(position, 1, QModelIndex());
|
m_model.insertRows(position, 1, QModelIndex());
|
||||||
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
||||||
m_model.setData(index, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
m_model.setData(index, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||||
}
|
}
|
||||||
|
this->resizeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsHotkeyComponent::editEntry()
|
void CSettingsHotkeyComponent::editEntry()
|
||||||
@@ -100,6 +101,7 @@ namespace BlackGui
|
|||||||
updateHotkeyInSettings(actionHotkey, selectedActionHotkey);
|
updateHotkeyInSettings(actionHotkey, selectedActionHotkey);
|
||||||
m_model.setData(indexHotkey, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
m_model.setData(indexHotkey, QVariant::fromValue(selectedActionHotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||||
}
|
}
|
||||||
|
this->resizeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsHotkeyComponent::removeEntry()
|
void CSettingsHotkeyComponent::removeEntry()
|
||||||
@@ -111,9 +113,10 @@ namespace BlackGui
|
|||||||
removeHotkeyFromSettings(actionHotkey);
|
removeHotkeyFromSettings(actionHotkey);
|
||||||
m_model.removeRows(index.row(), 1, QModelIndex());
|
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());
|
CActionHotkeyList actionHotkeyList(m_actionHotkeys.getThreadLocal());
|
||||||
actionHotkeyList.push_back(actionHotkey);
|
actionHotkeyList.push_back(actionHotkey);
|
||||||
@@ -171,6 +174,7 @@ namespace BlackGui
|
|||||||
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
const QModelIndex index = m_model.index(position, 0, QModelIndex());
|
||||||
m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
m_model.setData(index, QVariant::fromValue(hotkey), CActionHotkeyListModel::ActionHotkeyRole);
|
||||||
}
|
}
|
||||||
|
this->resizeView();
|
||||||
}
|
}
|
||||||
|
|
||||||
CIdentifierList CSettingsHotkeyComponent::getAllIdentifiers() const
|
CIdentifierList CSettingsHotkeyComponent::getAllIdentifiers() const
|
||||||
@@ -184,6 +188,11 @@ namespace BlackGui
|
|||||||
return identifiers;
|
return identifiers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSettingsHotkeyComponent::resizeView()
|
||||||
|
{
|
||||||
|
ui->tv_Hotkeys->resizeRowsToContents();
|
||||||
|
}
|
||||||
|
|
||||||
void CSettingsHotkeyComponent::hotkeySlot(bool keyDown)
|
void CSettingsHotkeyComponent::hotkeySlot(bool keyDown)
|
||||||
{
|
{
|
||||||
if (keyDown)
|
if (keyDown)
|
||||||
|
|||||||
@@ -55,11 +55,12 @@ namespace BlackGui
|
|||||||
void editEntry();
|
void editEntry();
|
||||||
void removeEntry();
|
void removeEntry();
|
||||||
void hotkeySlot(bool keyDown);
|
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 updateHotkeyInSettings(const BlackMisc::Input::CActionHotkey &oldValue, const BlackMisc::Input::CActionHotkey &newValue);
|
||||||
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 = {});
|
||||||
BlackMisc::CIdentifierList getAllIdentifiers() const;
|
BlackMisc::CIdentifierList getAllIdentifiers() const;
|
||||||
|
void resizeView();
|
||||||
|
|
||||||
QScopedPointer<Ui::CSettingsHotkeyComponent> ui;
|
QScopedPointer<Ui::CSettingsHotkeyComponent> ui;
|
||||||
Models::CActionHotkeyListModel m_model; //!< hotkeys model
|
Models::CActionHotkeyListModel m_model; //!< hotkeys model
|
||||||
|
|||||||
@@ -43,17 +43,19 @@ namespace BlackGui
|
|||||||
|
|
||||||
if (role == Qt::DisplayRole)
|
if (role == Qt::DisplayRole)
|
||||||
{
|
{
|
||||||
if (index.column() == 0)
|
const int col = index.column();
|
||||||
|
if (col == 0)
|
||||||
{
|
{
|
||||||
const CIdentifier identifier = m_actionHotkeys[index.row()].getApplicableMachine();
|
const CIdentifier identifier = m_actionHotkeys[index.row()].getApplicableMachine();
|
||||||
return identifier.getMachineName();
|
return identifier.getMachineName();
|
||||||
}
|
}
|
||||||
if (index.column() == 1)
|
if (col == 1)
|
||||||
{
|
{
|
||||||
CHotkeyCombination combination = m_actionHotkeys[index.row()].getCombination();
|
const CHotkeyCombination combination = m_actionHotkeys[index.row()].getCombination();
|
||||||
return combination.toQString();
|
return combination.asStringWithDeviceNames();
|
||||||
|
// return combination.toQString();
|
||||||
}
|
}
|
||||||
if (index.column() == 2)
|
if (col == 2)
|
||||||
{
|
{
|
||||||
return m_actionHotkeys[index.row()].getAction();
|
return m_actionHotkeys[index.row()].getAction();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user