mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-23 11:02:21 +03:00
gui: Make access to hotkey actions explicit
This commit is contained in:
parent
016393fb67
commit
a691b31b8e
@ -34,7 +34,6 @@ class QSettings;
|
||||
class Hotkey
|
||||
{
|
||||
friend class HotkeyDialog;
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream& operator<<(QTextStream& outStream, const Hotkey& hotkey);
|
||||
|
||||
public:
|
||||
@ -45,13 +44,15 @@ class Hotkey
|
||||
const KeySequence& keySequence() const { return m_KeySequence; }
|
||||
const ActionList& actions() const { return m_Actions; }
|
||||
|
||||
void appendAction(const Action& action) { m_Actions.append(action); }
|
||||
void setAction(int index, const Action& action) { m_Actions[index] = action; }
|
||||
void removeAction(int index) { m_Actions.removeAt(index); }
|
||||
|
||||
void loadSettings(QSettings& settings);
|
||||
void saveSettings(QSettings& settings) const;
|
||||
|
||||
protected:
|
||||
void setKeySequence(const KeySequence& seq) { m_KeySequence = seq; }
|
||||
ActionList& actions() { return m_Actions; }
|
||||
|
||||
|
||||
private:
|
||||
KeySequence m_KeySequence;
|
||||
|
@ -183,7 +183,7 @@ void ServerConfigDialog::on_m_pButtonNewAction_clicked()
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
{
|
||||
hotkey.actions().append(action);
|
||||
hotkey.appendAction(action);
|
||||
m_pListActions->addItem(action.text());
|
||||
}
|
||||
}
|
||||
@ -196,11 +196,13 @@ void ServerConfigDialog::on_m_pButtonEditAction_clicked()
|
||||
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
Action& action = hotkey.actions()[idxAction];
|
||||
Action action = hotkey.actions()[idxAction];
|
||||
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted)
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
hotkey.setAction(idxAction, action);
|
||||
m_pListActions->currentItem()->setText(action.text());
|
||||
}
|
||||
}
|
||||
|
||||
void ServerConfigDialog::on_m_pButtonRemoveAction_clicked()
|
||||
@ -212,7 +214,7 @@ void ServerConfigDialog::on_m_pButtonRemoveAction_clicked()
|
||||
int idxAction = m_pListActions->currentRow();
|
||||
Q_ASSERT(idxAction >= 0 && idxAction < hotkey.actions().size());
|
||||
|
||||
hotkey.actions().removeAt(idxAction);
|
||||
hotkey.removeAction(idxAction);
|
||||
delete m_pListActions->currentItem();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user