Popup improvements
- ESC closes the popup.
- Up/Down arrows for navigation.
- BackTab for backwards navigation.
fixes #301
fixes #302
2 files changed, 16 insertions, 3 deletions
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<SearchResult> &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<SearchResult> &results);
- void cycleSuggestions();
+ void selectNextSuggestion();
+ void selectPreviousSuggestion();
void selectHoveredSuggestion();
public slots:
|