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
|
* 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) 2012 - 2016 Synergy App Ltd
|
||||||
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
|
|
@ -16,6 +16,25 @@ QString Hotkey::text() const
|
||||||
: kKeystroke.arg(m_keySequence.toString());
|
: 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)
|
void Hotkey::loadSettings(QSettings &settings)
|
||||||
{
|
{
|
||||||
m_keySequence.loadSettings(settings);
|
m_keySequence.loadSettings(settings);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* 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) 2012 - 2016 Synergy App Ltd
|
||||||
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
* SPDX-FileCopyrightText: (C) 2008 Volker Lanz <vl@fidra.de>
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
|
|
@ -21,10 +21,6 @@ class QSettings;
|
||||||
|
|
||||||
class Hotkey
|
class Hotkey
|
||||||
{
|
{
|
||||||
friend class HotkeyDialog;
|
|
||||||
friend class ServerConfigDialog;
|
|
||||||
friend QTextStream &operator<<(QTextStream &outStream, const Hotkey &hotkey);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Hotkey() = default;
|
Hotkey() = default;
|
||||||
|
|
||||||
|
|
@ -33,30 +29,24 @@ public:
|
||||||
{
|
{
|
||||||
return m_keySequence;
|
return m_keySequence;
|
||||||
}
|
}
|
||||||
|
void setKeySequence(const KeySequence &seq)
|
||||||
|
{
|
||||||
|
m_keySequence = seq;
|
||||||
|
}
|
||||||
const ActionList &actions() const
|
const ActionList &actions() const
|
||||||
{
|
{
|
||||||
return m_actions;
|
return m_actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action &actionAt(int index);
|
||||||
|
void addAction(const Action &action);
|
||||||
|
void removeActionAt(int index);
|
||||||
|
|
||||||
void loadSettings(QSettings &settings);
|
void loadSettings(QSettings &settings);
|
||||||
void saveSettings(QSettings &settings) const;
|
void saveSettings(QSettings &settings) const;
|
||||||
|
|
||||||
bool operator==(const Hotkey &hk) 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:
|
private:
|
||||||
KeySequence m_keySequence = {};
|
KeySequence m_keySequence = {};
|
||||||
ActionList m_actions = {};
|
ActionList m_actions = {};
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ void ServerConfigDialog::addAction()
|
||||||
Action action;
|
Action action;
|
||||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
hotkey.actions().append(action);
|
hotkey.addAction(action);
|
||||||
ui->listActions->addItem(action.text());
|
ui->listActions->addItem(action.text());
|
||||||
setButtonBoxEnabledButtons();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +197,7 @@ void ServerConfigDialog::editAction()
|
||||||
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
|
qDebug() << "Attempt to remove out of bounds action row: " << actionRow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Action &action = hotkey.actions()[actionRow];
|
Action &action = hotkey.actionAt(actionRow);
|
||||||
|
|
||||||
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
ActionDialog dlg(this, serverConfig(), hotkey, action);
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
|
|
@ -221,7 +221,7 @@ void ServerConfigDialog::removeAction()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hotkey.actions().removeAt(actionRow);
|
hotkey.removeActionAt(actionRow);
|
||||||
delete ui->listActions->currentItem();
|
delete ui->listActions->currentItem();
|
||||||
setButtonBoxEnabledButtons();
|
setButtonBoxEnabledButtons();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue