From 745d255808b41b216484be0b42875c87ae8f491e Mon Sep 17 00:00:00 2001 From: thez3ro Date: Mon, 22 Jan 2018 21:51:09 +0100 Subject: [PATCH] add cyclic arrowkey navigation for entryview --- src/autotype/AutoTypeSelectView.cpp | 11 ++--------- src/gui/PasswordGeneratorWidget.cpp | 8 ++------ src/gui/entry/EntryView.cpp | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/autotype/AutoTypeSelectView.cpp b/src/autotype/AutoTypeSelectView.cpp index 76d57ec6..7d9db413 100644 --- a/src/autotype/AutoTypeSelectView.cpp +++ b/src/autotype/AutoTypeSelectView.cpp @@ -19,7 +19,6 @@ #include #include -#include AutoTypeSelectView::AutoTypeSelectView(QWidget* parent) : EntryView(parent) @@ -59,14 +58,8 @@ void AutoTypeSelectView::selectFirstEntry() void AutoTypeSelectView::keyReleaseEvent(QKeyEvent* e) { - qDebug() << e->key(); - - if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { - if (e->key() == Qt::Key_Escape) { - emit rejected(); - } else { - e->ignore(); - } + if (e->key() == Qt::Key_Escape) { + emit rejected(); } else { e->ignore(); } diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index 08228ea1..c9c10aa5 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -153,12 +153,8 @@ void PasswordGeneratorWidget::setStandaloneMode(bool standalone) void PasswordGeneratorWidget::keyPressEvent(QKeyEvent* e) { - if (!e->modifiers() || (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) { - if (e->key() == Qt::Key_Escape && m_standalone == true) { - emit dialogTerminated(); - } else { - e->ignore(); - } + if (e->key() == Qt::Key_Escape && m_standalone == true) { + emit dialogTerminated(); } else { e->ignore(); } diff --git a/src/gui/entry/EntryView.cpp b/src/gui/entry/EntryView.cpp index ceb3c64a..36d60ced 100644 --- a/src/gui/entry/EntryView.cpp +++ b/src/gui/entry/EntryView.cpp @@ -121,6 +121,20 @@ void EntryView::keyPressEvent(QKeyEvent* event) #endif } + int last = m_model->rowCount() - 1; + + if (event->key() == Qt::Key_Up && currentIndex().row() == 0) { + QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(last, 0)); + setCurrentEntry(m_model->entryFromIndex(index)); + return; + } + + if (event->key() == Qt::Key_Down && currentIndex().row() == last) { + QModelIndex index = m_sortModel->mapToSource(m_sortModel->index(0, 0)); + setCurrentEntry(m_model->entryFromIndex(index)); + return; + } + QTreeView::keyPressEvent(event); }