From d6ac72ab3fa0e7e350751c60873a925f98216b76 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Thu, 3 May 2018 15:19:28 +0300 Subject: [PATCH] Default to the first item in room selection menu - Add backwards navigation with backtab fixes #316 --- src/QuickSwitcher.cc | 17 +++++++++++------ src/SuggestionsPopup.cpp | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/QuickSwitcher.cc b/src/QuickSwitcher.cc index 3596a8c4..2aa05f3c 100644 --- a/src/QuickSwitcher.cc +++ b/src/QuickSwitcher.cc @@ -31,17 +31,22 @@ RoomSearchInput::RoomSearchInput(QWidget *parent) void RoomSearchInput::keyPressEvent(QKeyEvent *event) { - if (event->key() == Qt::Key_Tab || event->key() == Qt::Key_Down) { + switch (event->key()) { + case Qt::Key_Tab: + case Qt::Key_Down: { emit selectNextCompletion(); event->accept(); - return; - } else if (event->key() == Qt::Key_Up) { + break; + } + case Qt::Key_Backtab: + case Qt::Key_Up: { emit selectPreviousCompletion(); event->accept(); - return; + break; + } + default: + TextField::keyPressEvent(event); } - - TextField::keyPressEvent(event); } void diff --git a/src/SuggestionsPopup.cpp b/src/SuggestionsPopup.cpp index 86586c92..9ac2ef23 100644 --- a/src/SuggestionsPopup.cpp +++ b/src/SuggestionsPopup.cpp @@ -136,6 +136,8 @@ SuggestionsPopup::addRooms(const std::vector &rooms) adjustSize(); resize(geometry().width(), 40 * rooms.size()); + + selectNextSuggestion(); } void @@ -158,6 +160,8 @@ SuggestionsPopup::addUsers(const QVector &users) adjustSize(); resize(geometry().width(), 40 * users.size()); + + selectNextSuggestion(); } void