refactor: Action use QStringLists in place of char * arrays
This commit is contained in:
parent
261d85b423
commit
1a35a8bdf7
2 changed files with 18 additions and 14 deletions
|
|
@ -21,17 +21,9 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
const char *Action::m_actionTypeNames[] = {
|
|
||||||
"keyDown", "keyUp", "keystroke", "switchToScreen", "switchInDirection", "lockCursorToScreen",
|
|
||||||
"restartServer", "mouseDown", "mouseUp", "mousebutton"
|
|
||||||
};
|
|
||||||
|
|
||||||
const char *Action::m_switchDirectionNames[] = {"left", "right", "up", "down"};
|
|
||||||
const char *Action::m_lockCursorModeNames[] = {"toggle", "on", "off"};
|
|
||||||
|
|
||||||
QString Action::text() const
|
QString Action::text() const
|
||||||
{
|
{
|
||||||
QString text = QString(m_actionTypeNames[keySequence().isMouseButton() ? type() + 6 : type()]);
|
QString text = QString(m_actionTypeNames.at(keySequence().isMouseButton() ? type() + 6 : type()));
|
||||||
|
|
||||||
switch (type()) {
|
switch (type()) {
|
||||||
case keyDown:
|
case keyDown:
|
||||||
|
|
@ -60,11 +52,11 @@ QString Action::text() const
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchInDirection:
|
case switchInDirection:
|
||||||
text.append(m_commandTemplate.arg(m_switchDirectionNames[m_switchDirection]));
|
text.append(m_commandTemplate.arg(m_switchDirectionNames.at(m_switchDirection)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lockCursorToScreen:
|
case lockCursorToScreen:
|
||||||
text.append(m_commandTemplate.arg(m_lockCursorModeNames[m_lockCursorMode]));
|
text.append(m_commandTemplate.arg(m_lockCursorModeNames.at(m_lockCursorMode)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
|
|
@ -172,10 +172,22 @@ private:
|
||||||
bool m_hasScreens = false;
|
bool m_hasScreens = false;
|
||||||
bool m_restartServer;
|
bool m_restartServer;
|
||||||
|
|
||||||
static const char *m_actionTypeNames[];
|
|
||||||
static const char *m_switchDirectionNames[];
|
|
||||||
static const char *m_lockCursorModeNames[];
|
|
||||||
inline static const QString m_commandTemplate = QStringLiteral("(%1)");
|
inline static const QString m_commandTemplate = QStringLiteral("(%1)");
|
||||||
|
inline static const QStringList m_actionTypeNames{
|
||||||
|
QStringLiteral("keyDown"), QStringLiteral("keyUp"),
|
||||||
|
QStringLiteral("keystroke"), QStringLiteral("switchToScreen"),
|
||||||
|
QStringLiteral("switchInDirection"), QStringLiteral("lockCursorToScreen"),
|
||||||
|
QStringLiteral("restartServer"), QStringLiteral("mouseDown"),
|
||||||
|
QStringLiteral("mouseUp"), QStringLiteral("mousebutton")
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static const QStringList m_switchDirectionNames{
|
||||||
|
QStringLiteral("left"), QStringLiteral("right"), QStringLiteral("up"), QStringLiteral("down")
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static const QStringList m_lockCursorModeNames{
|
||||||
|
QStringLiteral("toggle"), QStringLiteral("on"), QStringLiteral("off")
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
using ActionList = QList<Action>;
|
using ActionList = QList<Action>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue