quit autotype dialog with esc key

This commit is contained in:
thez3ro 2018-01-22 15:44:42 +01:00
parent 9c641ddf6b
commit e4088d5e6c
No known key found for this signature in database
GPG Key ID: F628F9E41DD7C073
3 changed files with 22 additions and 0 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,7 +17,9 @@
#include "AutoTypeSelectView.h"
#include <QKeyEvent>
#include <QMouseEvent>
#include <QDebug>
AutoTypeSelectView::AutoTypeSelectView(QWidget* parent)
: EntryView(parent)
@ -54,3 +56,18 @@ void AutoTypeSelectView::selectFirstEntry()
setCurrentIndex(index);
}
}
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();
}
} 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