refactor: Action, dont use concatantaion, instead append
This commit is contained in:
parent
112c665480
commit
fcc8c3d344
2 changed files with 12 additions and 15 deletions
|
|
@ -31,51 +31,47 @@ 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[keySequence().isMouseButton() ? type() + 6 : type()]);
|
||||||
|
|
||||||
switch (type()) {
|
switch (type()) {
|
||||||
case keyDown:
|
case keyDown:
|
||||||
case keyUp:
|
case keyUp:
|
||||||
case keystroke: {
|
case keystroke: {
|
||||||
text += keySequence().toString();
|
QString commandArgs = keySequence().toString();
|
||||||
|
|
||||||
if (!keySequence().isMouseButton()) {
|
if (!keySequence().isMouseButton()) {
|
||||||
const QStringList &screens = typeScreenNames();
|
const QStringList &screens = typeScreenNames();
|
||||||
if (haveScreens() && !screens.isEmpty()) {
|
if (haveScreens() && !screens.isEmpty()) {
|
||||||
text += ",";
|
QString screenList;
|
||||||
|
|
||||||
for (int i = 0; i < screens.size(); i++) {
|
for (int i = 0; i < screens.size(); i++) {
|
||||||
text += screens[i];
|
screenList.append(screens[i]);
|
||||||
if (i != screens.size() - 1)
|
if (i != screens.size() - 1)
|
||||||
text += ":";
|
screenList.append(QStringLiteral(":"));
|
||||||
}
|
}
|
||||||
|
commandArgs.append(QStringLiteral(",%1").arg(screenList));
|
||||||
} else
|
} else
|
||||||
text += ",*";
|
commandArgs.append(QStringLiteral(",*"));
|
||||||
}
|
}
|
||||||
|
text.append(m_commandTemplate.arg(commandArgs));
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case switchToScreen:
|
case switchToScreen:
|
||||||
text += switchScreenName();
|
text.append(m_commandTemplate.arg(m_switchScreenName));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case switchInDirection:
|
case switchInDirection:
|
||||||
text += m_switchDirectionNames[m_switchDirection];
|
text.append(m_commandTemplate.arg(m_switchDirectionNames[m_switchDirection]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case lockCursorToScreen:
|
case lockCursorToScreen:
|
||||||
text += m_lockCursorModeNames[m_lockCursorMode];
|
text.append(m_commandTemplate.arg(m_lockCursorModeNames[m_lockCursorMode]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case restartAllConnections:
|
|
||||||
text += "restart";
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(0);
|
Q_ASSERT(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
text += ")";
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,7 @@ private:
|
||||||
static const char *m_actionTypeNames[];
|
static const char *m_actionTypeNames[];
|
||||||
static const char *m_switchDirectionNames[];
|
static const char *m_switchDirectionNames[];
|
||||||
static const char *m_lockCursorModeNames[];
|
static const char *m_lockCursorModeNames[];
|
||||||
|
inline static const QString m_commandTemplate = QStringLiteral("(%1)");
|
||||||
};
|
};
|
||||||
|
|
||||||
using ActionList = QList<Action>;
|
using ActionList = QList<Action>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue