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
|
login.cpp
|
||||||
stickerevent.cpp
|
stickerevent.cpp
|
||||||
chatboxhelper.cpp
|
chatboxhelper.cpp
|
||||||
|
commandmodel.cpp
|
||||||
../res.qrc
|
../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
|
m_autoCompleteBeginPosition = textBeforeCursor.lastIndexOf(" ") + 1; // 1 == space
|
||||||
|
|
||||||
if (autoCompletePrefix.startsWith("@")) {
|
if (autoCompletePrefix.startsWith("@")) {
|
||||||
@@ -159,6 +159,14 @@ QVariantMap ChatDocumentHandler::getAutocompletionInfo()
|
|||||||
{"type", AutoCompletionType::User},
|
{"type", AutoCompletionType::User},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (autoCompletePrefix.startsWith("/")) {
|
||||||
|
return QVariantMap{
|
||||||
|
{"keyword", autoCompletePrefix},
|
||||||
|
{"type", AutoCompletionType::Command},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return QVariantMap{
|
return QVariantMap{
|
||||||
{"keyword", autoCompletePrefix},
|
{"keyword", autoCompletePrefix},
|
||||||
{"type", AutoCompletionType::Emoji},
|
{"type", AutoCompletionType::Emoji},
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
enum AutoCompletionType {
|
enum AutoCompletionType {
|
||||||
User,
|
User,
|
||||||
Emoji,
|
Emoji,
|
||||||
|
Command,
|
||||||
None,
|
None,
|
||||||
Ignore,
|
Ignore,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "chatboxhelper.h"
|
#include "chatboxhelper.h"
|
||||||
#include "chatdocumenthandler.h"
|
#include "chatdocumenthandler.h"
|
||||||
#include "clipboard.h"
|
#include "clipboard.h"
|
||||||
|
#include "commandmodel.h"
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "csapi/joining.h"
|
#include "csapi/joining.h"
|
||||||
#include "csapi/leaving.h"
|
#include "csapi/leaving.h"
|
||||||
@@ -148,6 +149,11 @@ int main(int argc, char *argv[])
|
|||||||
Q_UNUSED(engine2);
|
Q_UNUSED(engine2);
|
||||||
return new EmojiModel();
|
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<SortFilterRoomListModel>("org.kde.neochat", 1, 0, "SortFilterRoomListModel");
|
||||||
qmlRegisterType<DevicesModel>("org.kde.neochat", 1, 0, "DevicesModel");
|
qmlRegisterType<DevicesModel>("org.kde.neochat", 1, 0, "DevicesModel");
|
||||||
qmlRegisterUncreatableType<RoomMessageEvent>("org.kde.neochat", 1, 0, "RoomMessageEvent", "ENUM");
|
qmlRegisterUncreatableType<RoomMessageEvent>("org.kde.neochat", 1, 0, "RoomMessageEvent", "ENUM");
|
||||||
|
|||||||
Reference in New Issue
Block a user