feat: trigger completion of commands on the input of backlash / char
This commit is contained in:
@@ -29,6 +29,7 @@ add_executable(neochat
|
||||
login.cpp
|
||||
stickerevent.cpp
|
||||
chatboxhelper.cpp
|
||||
commandmodel.cpp
|
||||
../res.qrc
|
||||
)
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ QVariantMap ChatDocumentHandler::getAutocompletionInfo()
|
||||
};
|
||||
}
|
||||
|
||||
if (autoCompletePrefix.startsWith("@") || autoCompletePrefix.startsWith(":")) {
|
||||
if (autoCompletePrefix.startsWith("@") || autoCompletePrefix.startsWith(":") || autoCompletePrefix.startsWith("/")) {
|
||||
m_autoCompleteBeginPosition = textBeforeCursor.lastIndexOf(" ") + 1; // 1 == space
|
||||
|
||||
if (autoCompletePrefix.startsWith("@")) {
|
||||
@@ -159,6 +159,14 @@ QVariantMap ChatDocumentHandler::getAutocompletionInfo()
|
||||
{"type", AutoCompletionType::User},
|
||||
};
|
||||
}
|
||||
|
||||
if (autoCompletePrefix.startsWith("/")) {
|
||||
return QVariantMap{
|
||||
{"keyword", autoCompletePrefix},
|
||||
{"type", AutoCompletionType::Command},
|
||||
};
|
||||
}
|
||||
|
||||
return QVariantMap{
|
||||
{"keyword", autoCompletePrefix},
|
||||
{"type", AutoCompletionType::Emoji},
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
enum AutoCompletionType {
|
||||
User,
|
||||
Emoji,
|
||||
Command,
|
||||
None,
|
||||
Ignore,
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "chatboxhelper.h"
|
||||
#include "chatdocumenthandler.h"
|
||||
#include "clipboard.h"
|
||||
#include "commandmodel.h"
|
||||
#include "controller.h"
|
||||
#include "csapi/joining.h"
|
||||
#include "csapi/leaving.h"
|
||||
@@ -148,6 +149,11 @@ int main(int argc, char *argv[])
|
||||
Q_UNUSED(engine2);
|
||||
return new EmojiModel();
|
||||
});
|
||||
qmlRegisterSingletonType<CommandModel>("org.kde.neochat", 1, 0, "CommandModel", [](QQmlEngine *engine2, QJSEngine *scriptEngine) -> QObject * {
|
||||
Q_UNUSED(scriptEngine);
|
||||
Q_UNUSED(engine2);
|
||||
return new CommandModel();
|
||||
});
|
||||
qmlRegisterType<SortFilterRoomListModel>("org.kde.neochat", 1, 0, "SortFilterRoomListModel");
|
||||
qmlRegisterType<DevicesModel>("org.kde.neochat", 1, 0, "DevicesModel");
|
||||
qmlRegisterUncreatableType<RoomMessageEvent>("org.kde.neochat", 1, 0, "RoomMessageEvent", "ENUM");
|
||||
|
||||
Reference in New Issue
Block a user