From ca66940ec39047eada21f7900bf0e49d61cb45fb Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 14 Apr 2018 14:12:36 +0300 Subject: Popup improvements - ESC closes the popup. - Up/Down arrows for navigation. - BackTab for backwards navigation. fixes #301 fixes #302 --- include/SuggestionsPopup.hpp | 16 ++++++++++++++-- include/TextInputWidget.h | 3 ++- 2 files changed, 16 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/SuggestionsPopup.hpp b/include/SuggestionsPopup.hpp index 80f28466..dcbe52fa 100644 --- a/include/SuggestionsPopup.hpp +++ b/include/SuggestionsPopup.hpp @@ -62,15 +62,27 @@ public: public slots: void addUsers(const QVector &users); - void cycleThroughSuggestions(); void selectHoveredSuggestion(); + //! Move to the next available suggestion item. + void selectNextSuggestion(); + //! Move to the previous available suggestion item. + void selectPreviousSuggestion(); + //! Remove hovering from all items. + void resetHovering(); + //! Set hovering to the item in the given layout position. + void setHovering(int pos); signals: void itemSelected(const QString &user); private: + void hoverSelection(); + void resetSelection() { selectedItem_ = -1; } + void selectFirstItem() { selectedItem_ = 0; } + void selectLastItem() { selectedItem_ = layout_->count() - 1; } + QVBoxLayout *layout_; //! Counter for tab completion (cycling). - int tab_clicks_; + int selectedItem_ = -1; }; diff --git a/include/TextInputWidget.h b/include/TextInputWidget.h index 89eb5947..7a52ea77 100644 --- a/include/TextInputWidget.h +++ b/include/TextInputWidget.h @@ -73,7 +73,8 @@ signals: //! Trigger the suggestion popup. void showSuggestions(const QString &query); void resultsRetrieved(const QVector &results); - void cycleSuggestions(); + void selectNextSuggestion(); + void selectPreviousSuggestion(); void selectHoveredSuggestion(); public slots: -- cgit 1.5.1