summary refs log tree commit diff
path: root/src/timeline/InputBar.h
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2023-02-27 18:06:24 -0500
committerLoren Burkholder <computersemiexpert@outlook.com>2023-02-28 20:10:25 -0500
commit22ac5d861e487ff39749f5d2bdda9113689e4b63 (patch)
tree8031235b2d798b37d0d9add9e6f8ddfb7e4531a6 /src/timeline/InputBar.h
parentShow warning when invalid command is entered (diff)
downloadnheko-22ac5d861e487ff39749f5d2bdda9113689e4b63.tar.xz
Move command calculation logic into InputBar
Diffstat (limited to 'src/timeline/InputBar.h')
-rw-r--r--src/timeline/InputBar.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/timeline/InputBar.h b/src/timeline/InputBar.h
index 80ad7f47..7385d272 100644
--- a/src/timeline/InputBar.h
+++ b/src/timeline/InputBar.h
@@ -173,6 +173,9 @@ 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(QString currentCommand READ currentCommand NOTIFY currentCommandChanged)
     Q_PROPERTY(QString text READ text NOTIFY textChanged)
     Q_PROPERTY(QVariantList uploads READ uploads NOTIFY uploadsChanged)
 
@@ -198,6 +201,8 @@ public slots:
     void setText(const QString &newText);
 
     [[nodiscard]] bool containsAtRoom() const { return containsAtRoom_; }
+    bool containsInvalidCommand() const { return containsInvalidCommand_; }
+    QString currentCommand() const { return currentCommand_; }
 
     void send();
     bool tryPasteAttachment(bool fromMouse);
@@ -225,6 +230,8 @@ signals:
     void textChanged(QString newText);
     void uploadingChanged(bool value);
     void containsAtRoomChanged();
+    void containsInvalidCommandChanged();
+    void currentCommandChanged();
     void uploadsChanged();
 
 private:
@@ -267,6 +274,7 @@ private:
                const QSize &thumbnailDimensions,
                const QString &blurhash);
 
+    QPair<QString, QString> getCommandAndArgs() const;
     mtx::common::Relations generateRelations() const;
 
     void startUploadFromPath(const QString &path);
@@ -280,7 +288,7 @@ private:
         }
     }
 
-    void updateAtRoom(const QString &t);
+    void updateTextContentProperties(const QString &t);
 
     QTimer typingRefresh_;
     QTimer typingTimeout_;
@@ -288,8 +296,10 @@ 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;
+    QString currentCommand_;
 
     using UploadHandle = std::unique_ptr<MediaUpload, DeleteLaterDeleter>;
     std::vector<UploadHandle> unconfirmedUploads;