refactor: Hotkey, use internal actionlist in place of function call
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||
*
|
||||
@ -20,7 +21,7 @@
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
Hotkey::Hotkey() : m_keySequence{}, m_Actions()
|
||||
Hotkey::Hotkey() : m_keySequence{}, m_actions{}
|
||||
{
|
||||
}
|
||||
|
||||
@ -34,13 +35,13 @@ void Hotkey::loadSettings(QSettings &settings)
|
||||
{
|
||||
m_keySequence.loadSettings(settings);
|
||||
|
||||
actions().clear();
|
||||
m_actions.clear();
|
||||
int num = settings.beginReadArray(kSectionActions);
|
||||
for (int i = 0; i < num; i++) {
|
||||
settings.setArrayIndex(i);
|
||||
Action a;
|
||||
a.loadSettings(settings);
|
||||
actions().append(a);
|
||||
m_actions.append(a);
|
||||
}
|
||||
|
||||
settings.endArray();
|
||||
@ -51,16 +52,16 @@ void Hotkey::saveSettings(QSettings &settings) const
|
||||
m_keySequence.saveSettings(settings);
|
||||
|
||||
settings.beginWriteArray(kSectionActions);
|
||||
for (int i = 0; i < actions().size(); i++) {
|
||||
for (int i = 0; i < m_actions.size(); i++) {
|
||||
settings.setArrayIndex(i);
|
||||
actions()[i].saveSettings(settings);
|
||||
m_actions.at(i).saveSettings(settings);
|
||||
}
|
||||
settings.endArray();
|
||||
}
|
||||
|
||||
bool Hotkey::operator==(const Hotkey &hk) const
|
||||
{
|
||||
return m_keySequence == hk.keySequence() && m_Actions == hk.m_Actions;
|
||||
return m_keySequence == hk.keySequence() && m_actions == hk.actions();
|
||||
}
|
||||
|
||||
QTextStream &operator<<(QTextStream &outStream, const Hotkey &hotkey)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* Copyright (C) 2025 Chris Rizzitello <sithlord48@gmail.com>
|
||||
* Copyright (C) 2012-2016 Symless Ltd.
|
||||
* Copyright (C) 2008 Volker Lanz (vl@fidra.de)
|
||||
*
|
||||
@ -45,7 +46,7 @@ public:
|
||||
}
|
||||
const ActionList &actions() const
|
||||
{
|
||||
return m_Actions;
|
||||
return m_actions;
|
||||
}
|
||||
|
||||
void loadSettings(QSettings &settings);
|
||||
@ -64,12 +65,12 @@ protected:
|
||||
}
|
||||
ActionList &actions()
|
||||
{
|
||||
return m_Actions;
|
||||
return m_actions;
|
||||
}
|
||||
|
||||
private:
|
||||
KeySequence m_keySequence;
|
||||
ActionList m_Actions;
|
||||
ActionList m_actions;
|
||||
inline static const QString kSectionActions = QStringLiteral("actions");
|
||||
inline static const QString kMousebutton = QStringLiteral("mousebutton(%1)");
|
||||
inline static const QString kKeystroke = QStringLiteral("keystroke(%1)");
|
||||
|
||||
Reference in New Issue
Block a user