From b0852bfda5b570edace419976344833ec09a4de4 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 5 Jan 2025 16:48:41 -0500 Subject: [PATCH] refactor: Hotkey, use internal actionlist in place of function call --- src/apps/deskflow-gui/Hotkey.cpp | 13 +++++++------ src/apps/deskflow-gui/Hotkey.h | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/apps/deskflow-gui/Hotkey.cpp b/src/apps/deskflow-gui/Hotkey.cpp index 27871a62a..28a5cfa91 100644 --- a/src/apps/deskflow-gui/Hotkey.cpp +++ b/src/apps/deskflow-gui/Hotkey.cpp @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * Copyright (C) 2025 Chris Rizzitello * Copyright (C) 2012-2016 Symless Ltd. * Copyright (C) 2008 Volker Lanz (vl@fidra.de) * @@ -20,7 +21,7 @@ #include -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) diff --git a/src/apps/deskflow-gui/Hotkey.h b/src/apps/deskflow-gui/Hotkey.h index cb45dcabb..79851834c 100644 --- a/src/apps/deskflow-gui/Hotkey.h +++ b/src/apps/deskflow-gui/Hotkey.h @@ -1,5 +1,6 @@ /* * Deskflow -- mouse and keyboard sharing utility + * Copyright (C) 2025 Chris Rizzitello * 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)");