summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorchristarazi <christarazi@users.noreply.github.com>2018-04-10 01:47:23 -0700
committermujx <mujx@users.noreply.github.com>2018-04-10 11:47:23 +0300
commit0b3029b3c48af4bf8aa302c28e66bce771213c94 (patch)
tree18835fdce3a88f58c898224c6eb30703fb9b7d63 /include
parentHide emoji panel if it's not under the mouse cursor (diff)
downloadnheko-0b3029b3c48af4bf8aa302c28e66bce771213c94.tar.xz
Implement pressing tab to navigate auto completion (#294)
Fixes #287

* Fix pop-up not showing when less than max 

* Select suggestion by pressing Enter
Diffstat (limited to 'include')
-rw-r--r--include/SuggestionsPopup.hpp13
-rw-r--r--include/TextInputWidget.h2
2 files changed, 15 insertions, 0 deletions
diff --git a/include/SuggestionsPopup.hpp b/include/SuggestionsPopup.hpp

index 23549124..80f28466 100644 --- a/include/SuggestionsPopup.hpp +++ b/include/SuggestionsPopup.hpp
@@ -21,13 +21,18 @@ class PopupItem : public QWidget Q_OBJECT Q_PROPERTY(QColor hoverColor READ hoverColor WRITE setHoverColor) + Q_PROPERTY(bool hovering READ hovering WRITE setHovering) public: PopupItem(QWidget *parent, const QString &user_id); + QString user() const { return user_id_; } QColor hoverColor() const { return hoverColor_; } void setHoverColor(QColor &color) { hoverColor_ = color; } + bool hovering() const { return hovering_; } + void setHovering(const bool hover) { hovering_ = hover; }; + protected: void paintEvent(QPaintEvent *event) override; void mousePressEvent(QMouseEvent *event) override; @@ -43,6 +48,9 @@ private: QString user_id_; QColor hoverColor_; + + //! Set if the item is currently being hovered during tab completion (cycling). + bool hovering_; }; class SuggestionsPopup : public QWidget @@ -54,10 +62,15 @@ public: public slots: void addUsers(const QVector<SearchResult> &users); + void cycleThroughSuggestions(); + void selectHoveredSuggestion(); signals: void itemSelected(const QString &user); private: QVBoxLayout *layout_; + + //! Counter for tab completion (cycling). + int tab_clicks_; }; diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h
index 927187dd..89eb5947 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h
@@ -73,6 +73,8 @@ signals: //! Trigger the suggestion popup. void showSuggestions(const QString &query); void resultsRetrieved(const QVector<SearchResult> &results); + void cycleSuggestions(); + void selectHoveredSuggestion(); public slots: void showResults(const QVector<SearchResult> &results);