Merge pull request #1412 from keepassxreboot/feature/exit-autotype-dialog

Quit autotype dialog with esc key
This commit is contained in:
Janek Bevendorff 2018-01-23 00:21:34 +01:00 committed by GitHub
commit 28ebdb72a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 6 deletions

View File

@ -58,6 +58,7 @@ AutoTypeSelectDialog::AutoTypeSelectDialog(QWidget* parent)
connect(m_view, SIGNAL(activated(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(m_view, SIGNAL(clicked(QModelIndex)), SLOT(emitEntryActivated(QModelIndex)));
connect(m_view, SIGNAL(rejected()), SLOT(reject()));
connect(m_view->model(), SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(entryRemoved()));
layout->addWidget(m_view);

View File

@ -17,6 +17,7 @@
#include "AutoTypeSelectView.h"
#include <QKeyEvent>
#include <QMouseEvent>
AutoTypeSelectView::AutoTypeSelectView(QWidget* parent)
@ -54,3 +55,12 @@ void AutoTypeSelectView::selectFirstEntry()
setCurrentIndex(index);
}
}
void AutoTypeSelectView::keyReleaseEvent(QKeyEvent* e)
{
if (e->key() == Qt::Key_Escape) {
emit rejected();
} else {
e->ignore();
}
}

View File

@ -31,9 +31,13 @@ public:
protected:
void mouseMoveEvent(QMouseEvent* event) override;
void keyReleaseEvent(QKeyEvent* e) override;
private slots:
void selectFirstEntry();
signals:
void rejected();
};
#endif // KEEPASSX_AUTOTYPESELECTVIEW_H

View File

@ -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();
}

View File

@ -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);
}