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