From 1c7d5de01b9ff8f85cff39dd5355f5524858abe8 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Thu, 14 Aug 2025 19:26:32 -0400 Subject: [PATCH] refactor Action::ActionType => Action::Type enum class --- src/lib/gui/Action.cpp | 11 ++++++----- src/lib/gui/Action.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/lib/gui/Action.cpp b/src/lib/gui/Action.cpp index 8c256d2d9..b0a5224fd 100644 --- a/src/lib/gui/Action.cpp +++ b/src/lib/gui/Action.cpp @@ -14,7 +14,8 @@ QString Action::text() const { auto text = QString(m_actionTypeNames.at(keySequence().isMouseButton() ? type() + 6 : type())); - switch (type()) { + switch (static_cast(type())) { + using enum Type; case keyDown: case keyUp: case keystroke: { @@ -36,15 +37,15 @@ QString Action::text() const text.append(m_commandTemplate.arg(commandArgs)); } break; - case switchToScreen: + case Type::switchToScreen: text.append(m_commandTemplate.arg(m_switchScreenName)); break; - case switchInDirection: + case Type::switchInDirection: text.append(m_commandTemplate.arg(m_switchDirectionNames.at(m_switchDirection))); break; - case lockCursorToScreen: + case Type::lockCursorToScreen: text.append(m_commandTemplate.arg(m_lockCursorModeNames.at(m_lockCursorMode))); break; @@ -58,7 +59,7 @@ QString Action::text() const void Action::loadSettings(QSettings &settings) { keySequence().loadSettings(settings); - setType(settings.value(SettingsKeys::ActionType, keyDown).toInt()); + setType(settings.value(SettingsKeys::ActionType, static_cast(Type::keyDown)).toInt()); typeScreenNames().clear(); int numTypeScreens = settings.beginReadArray(SettingsKeys::ScreenNames); diff --git a/src/lib/gui/Action.h b/src/lib/gui/Action.h index a31003f42..ba2f3a2c8 100644 --- a/src/lib/gui/Action.h +++ b/src/lib/gui/Action.h @@ -35,7 +35,7 @@ class Action friend QTextStream &operator<<(QTextStream &outStream, const Action &action); public: - enum ActionType + enum class Type { keyDown, keyUp, @@ -151,7 +151,7 @@ protected: private: KeySequence m_keySequence; - int m_type = keystroke; + int m_type = static_cast(Type::keystroke); QStringList m_typeScreenNames = QStringList(); QString m_switchScreenName = QString(); int m_switchDirection = switchLeft;