Auto-Type: PageUp/PageDown scrolling for entries

Fixes #4530
This commit is contained in:
Toni Spets
2021-04-03 08:21:41 +03:00
committed by Jonathan White
parent 9b8feed3ed
commit 31aa5e12e5
4 changed files with 22 additions and 33 deletions

View File

@@ -147,33 +147,6 @@ void AutoTypeSelectDialog::performSearch()
m_ui->view->setMatchList(matches, !m_ui->search->text().isEmpty());
}
void AutoTypeSelectDialog::moveSelectionUp()
{
auto current = m_ui->view->currentIndex();
auto previous = current.sibling(current.row() - 1, 0);
if (previous.isValid()) {
m_ui->view->setCurrentIndex(previous);
}
}
void AutoTypeSelectDialog::moveSelectionDown()
{
auto current = m_ui->view->currentIndex();
// special case where we have no default selection (empty search)
if (!current.isValid()) {
m_ui->view->setCurrentIndex(m_ui->view->indexAt({0, 0}));
return;
}
auto next = current.sibling(current.row() + 1, 0);
if (next.isValid()) {
m_ui->view->setCurrentIndex(next);
}
}
void AutoTypeSelectDialog::activateCurrentMatch()
{
submitAutoTypeMatch(m_ui->view->currentMatch());
@@ -217,10 +190,16 @@ bool AutoTypeSelectDialog::eventFilter(QObject* obj, QEvent* event)
auto* keyEvent = static_cast<QKeyEvent*>(event);
switch (keyEvent->key()) {
case Qt::Key_Up:
moveSelectionUp();
m_ui->view->moveSelection(-1);
return true;
case Qt::Key_Down:
moveSelectionDown();
m_ui->view->moveSelection(1);
return true;
case Qt::Key_PageUp:
m_ui->view->moveSelection(-5);
return true;
case Qt::Key_PageDown:
m_ui->view->moveSelection(5);
return true;
case Qt::Key_Escape:
if (m_ui->search->text().isEmpty()) {