feat: improve commands() method of ActionHandler to use Command type
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
#include "actionshandler.h"
|
#include "actionshandler.h"
|
||||||
|
#include "commandmodel.h"
|
||||||
|
|
||||||
#include "csapi/joining.h"
|
#include "csapi/joining.h"
|
||||||
|
|
||||||
@@ -56,86 +57,66 @@ void ActionsHandler::setConnection(Connection *connection)
|
|||||||
Q_EMIT connectionChanged();
|
Q_EMIT connectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList ActionsHandler::commands() const
|
QVariantList ActionsHandler::commands()
|
||||||
{
|
{
|
||||||
QVariantList commands;
|
QVariantList commands;
|
||||||
|
|
||||||
// Messages commands
|
// Messages commands
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/shrug "),
|
QStringLiteral("/me "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Displays action")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/lenny "),
|
QStringLiteral("/shrug "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Prepends ¯\\_(ツ)_/¯ to a plain-text message")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/plain "),
|
QStringLiteral("/lenny "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Prepends ( ͡° ͜ʖ ͡°) to a plain-text message")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Sends a message as plain text, without interpreting it as markdown")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/html "),
|
QStringLiteral("/plain "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Sends a message as plain text, without interpreting it as markdown")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Sends a message as html, without interpreting it as markdown")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/rainbow "),
|
QStringLiteral("/html "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Sends a message as html, without interpreting it as markdown")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Sends the given message coloured as a rainbow")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/rainbowme "),
|
QStringLiteral("/rainbow "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<message>"),
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
i18n("Sends the given message coloured as a rainbow")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Sends the given emote coloured as a rainbow")});
|
commands.append(QVariant::fromValue(Command{
|
||||||
|
QStringLiteral("/rainbowme "),
|
||||||
|
QStringLiteral("<message>"),
|
||||||
|
i18n("Sends the given emote coloured as a rainbow")}));
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
|
||||||
QStringLiteral("/me "),
|
|
||||||
QStringLiteral("parameter"),
|
|
||||||
i18nc("@label Parameter of a command", "<message>"),
|
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Displays action")});
|
|
||||||
|
|
||||||
// Actions commands
|
// Actions commands
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/join "),
|
QStringLiteral("/join "), QStringLiteral("<room-address>"),
|
||||||
QStringLiteral("parameter"),
|
i18n("Joins room with given address")}));
|
||||||
i18nc("@label Parameter of a command", "<room-address>"),
|
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Joins room with given address")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/part "),
|
QStringLiteral("/part "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("[<room-address>]"),
|
||||||
i18nc("@label Parameter of a command", "[<room-address>]"),
|
i18n("Leave room")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Leave room")});
|
|
||||||
|
|
||||||
commands.append({QStringLiteral("prefix"),
|
commands.append(QVariant::fromValue(Command{
|
||||||
QStringLiteral("/invite "),
|
QStringLiteral("/invite "),
|
||||||
QStringLiteral("parameter"),
|
QStringLiteral("<user-id>"),
|
||||||
i18nc("@label Parameter of a command", "<user-id>"),
|
i18n("Invites user with given id to current room")}));
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("Invites user with given id to current room")});
|
commands.append(QVariant::fromValue(Command{
|
||||||
commands.append({QStringLiteral("prefix"),
|
QStringLiteral("/react "),
|
||||||
QStringLiteral("/react "),
|
QStringLiteral("<reaction text>"),
|
||||||
QStringLiteral("parameter"),
|
i18n("React to this message with a text")}));
|
||||||
i18nc("@label Parameter of a command", "<reaction text>"),
|
|
||||||
QStringLiteral("help"),
|
|
||||||
i18n("React to this message with a text")});
|
|
||||||
|
|
||||||
// TODO more see elements /help action
|
// TODO more see elements /help action
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
explicit ActionsHandler(QObject *parent = nullptr);
|
explicit ActionsHandler(QObject *parent = nullptr);
|
||||||
~ActionsHandler();
|
~ActionsHandler();
|
||||||
|
|
||||||
QVariantList commands() const;
|
static QVariantList commands();
|
||||||
|
|
||||||
[[nodiscard]] Connection *connection() const;
|
[[nodiscard]] Connection *connection() const;
|
||||||
void setConnection(Connection *connection);
|
void setConnection(Connection *connection);
|
||||||
|
|||||||
Reference in New Issue
Block a user