refactor(Hotkey): remove protected and friends add accessors for needed Action items
This commit is contained in:
parent
b06975850a
commit
1892690c14
3 changed files with 32 additions and 23 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-FileCopyrightText: (C) 2025 - 2026 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Synergy App Ltd
|
||||
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
|
|
@ -16,6 +16,25 @@ QString Hotkey::text() const
|
|||
: kKeystroke.arg(m_keySequence.toString());
|
||||
}
|
||||
|
||||
Action &Hotkey::actionAt(int index)
|
||||
{
|
||||
return m_actions[index];
|
||||
}
|
||||
|
||||
void Hotkey::addAction(const Action &action)
|
||||
{
|
||||
if (m_actions.contains(action))
|
||||
return;
|
||||
m_actions.append(action);
|
||||
}
|
||||
|
||||
void Hotkey::removeActionAt(int index)
|
||||
{
|
||||
if (index < 0 || index >= m_actions.size())
|
||||
return;
|
||||
m_actions.removeAt(index);
|
||||
}
|
||||
|
||||
void Hotkey::loadSettings(QSettings &settings)
|
||||
{
|
||||
m_keySequence.loadSettings(settings);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-FileCopyrightText: (C) 2025 - 2026 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* SPDX-FileCopyrightText: (C) 2012 - 2016 Synergy App Ltd
|
||||
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
|
|
@ -21,10 +21,6 @@ class QSettings;
|
|||
|
||||
class Hotkey
|
||||
{
|
||||
friend class HotkeyDialog;
|
||||
friend class ServerConfigDialog;
|
||||
friend QTextStream &operator<<(QTextStream &outStream, const Hotkey &hotkey);
|
||||
|
||||
public:
|
||||
Hotkey() = default;
|
||||
|
||||
|
|
@ -33,30 +29,24 @@ public:
|
|||
{
|
||||
return m_keySequence;
|
||||
}
|
||||
void setKeySequence(const KeySequence &seq)
|
||||
{
|
||||
m_keySequence = seq;
|
||||
}
|
||||
const ActionList &actions() const
|
||||
{
|
||||
return m_actions;
|
||||
}
|
||||
|
||||
Action &actionAt(int index);
|
||||
void addAction(const Action &action);
|
||||
void removeActionAt(int index);
|
||||
|
||||
void loadSettings(QSettings &settings);
|
||||
void saveSettings(QSettings &settings) const;
|
||||
|
||||
bool operator==(const Hotkey &hk) const;
|
||||
|
||||
protected:
|
||||
KeySequence &keySequence()
|
||||
{
|
||||
return m_keySequence;
|
||||
}
|
||||
void setKeySequence(const KeySequence &seq)
|
||||
{
|
||||
m_keySequence = seq;
|
||||
}
|
||||
ActionList &actions()
|
||||
{
|
||||
return m_actions;
|
||||
}
|
||||
|
||||
private:
|
||||
KeySequence m_keySequence = {};
|
||||
ActionList m_actions = {};
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ void ServerConfigDialog::addAction()
|
|||
Action action;
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
hotkey.actions().append(action);
|
||||
hotkey.addAction(action);
|
||||
ui->listActions->addItem(action.text());
|
||||
setButtonBoxEnabledButtons();
|
||||
}
|
||||
|
|
@ -197,7 +197,7 @@ void ServerConfigDialog::editAction()
|
|||
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
|
||||
return;
|
||||
}
|
||||
Action &action = hotkey.actions()[actionRow];
|
||||
Action &action = hotkey.actionAt(actionRow);
|
||||
|
||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
|
|
@ -221,7 +221,7 @@ void ServerConfigDialog::removeAction()
|
|||
return;
|
||||
}
|
||||
|
||||
hotkey.actions().removeAt(actionRow);
|
||||
hotkey.removeActionAt(actionRow);
|
||||
delete ui->listActions->currentItem();
|
||||
setButtonBoxEnabledButtons();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue