summary refs log tree commit diff
path: root/src/timeline/InputBar.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/timeline/InputBar.h')
-rw-r--r--src/timeline/InputBar.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h

index 80ad7f47..acafd964 100644 --- a/src/timeline/InputBar.h +++ b/src/timeline/InputBar.h
@@ -173,6 +173,11 @@ class InputBar final : public QObject Q_OBJECT Q_PROPERTY(bool uploading READ uploading NOTIFY uploadingChanged) Q_PROPERTY(bool containsAtRoom READ containsAtRoom NOTIFY containsAtRoomChanged) + Q_PROPERTY( + bool containsInvalidCommand READ containsInvalidCommand NOTIFY containsInvalidCommandChanged) + Q_PROPERTY(bool containsIncompleteCommand READ containsIncompleteCommand NOTIFY + containsIncompleteCommandChanged) + Q_PROPERTY(QString currentCommand READ currentCommand NOTIFY currentCommandChanged) Q_PROPERTY(QString text READ text NOTIFY textChanged) Q_PROPERTY(QVariantList uploads READ uploads NOTIFY uploadsChanged) @@ -198,6 +203,9 @@ public slots: void setText(const QString &newText); [[nodiscard]] bool containsAtRoom() const { return containsAtRoom_; } + bool containsInvalidCommand() const { return containsInvalidCommand_; } + bool containsIncompleteCommand() const { return containsIncompleteCommand_; } + QString currentCommand() const { return currentCommand_; } void send(); bool tryPasteAttachment(bool fromMouse); @@ -225,13 +233,16 @@ signals: void textChanged(QString newText); void uploadingChanged(bool value); void containsAtRoomChanged(); + void containsInvalidCommandChanged(); + void containsIncompleteCommandChanged(); + void currentCommandChanged(); void uploadsChanged(); private: void emote(const QString &body, bool rainbowify); void notice(const QString &body, bool rainbowify); void confetti(const QString &body, bool rainbowify); - void command(const QString &name, QString args); + bool command(const QString &name, QString args); void image(const QString &filename, const std::optional<mtx::crypto::EncryptedFile> &file, const QString &url, @@ -267,6 +278,8 @@ private: const QSize &thumbnailDimensions, const QString &blurhash); + QPair<QString, QString> getCommandAndArgs() const { return getCommandAndArgs(text()); } + QPair<QString, QString> getCommandAndArgs(const QString &currentText) const; mtx::common::Relations generateRelations() const; void startUploadFromPath(const QString &path); @@ -280,7 +293,7 @@ private: } } - void updateAtRoom(const QString &t); + void updateTextContentProperties(const QString &t); QTimer typingRefresh_; QTimer typingTimeout_; @@ -288,8 +301,11 @@ private: std::deque<QString> history_; std::size_t history_index_ = 0; int selectionStart = 0, selectionEnd = 0, cursorPosition = 0; - bool uploading_ = false; - bool containsAtRoom_ = false; + bool uploading_ = false; + bool containsAtRoom_ = false; + bool containsInvalidCommand_ = false; + bool containsIncompleteCommand_ = false; + QString currentCommand_; using UploadHandle = std::unique_ptr<MediaUpload, DeleteLaterDeleter>; std::vector<UploadHandle> unconfirmedUploads;