From 8734fd2e0ccde49312956332d77f696bed65646a Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 14 Apr 2016 03:44:38 +0200 Subject: [PATCH] keyboard based picture dialog --- PictureDialog.cpp | 25 ++++++++++++++++++++++++- PictureDialog.h | 3 +++ PictureDialog.ui | 14 +++++++++++++- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/PictureDialog.cpp b/PictureDialog.cpp index c0b61f9..4dca4cc 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -34,8 +34,11 @@ #include #include #include +#include +#include #include #include +#include #include #include @@ -74,6 +77,7 @@ PictureDialog::~PictureDialog() bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) { + bool returnValue = false; if (obj == this) { if (ev->type() == QEvent::KeyPress) @@ -82,14 +86,33 @@ bool PictureDialog::eventFilter(QObject *obj, QEvent *ev) switch (keyEvent->key()){ case Qt::Key_Left: emit previousPictureRequested(); + returnValue = true; break; case Qt::Key_Right: emit nextPictureRequested(); + returnValue = true; + break; + case Qt::Key_E: case Qt::Key_S: case Qt::Key_Save: + ui->cmdExport->click(); + returnValue = true; + break; + case Qt::Key_C: case Qt::Key_Q: case Qt::Key_Exit: + ui->cmdClose->click(); + returnValue = true; + break; + case Qt::Key_Enter: case Qt::Key_Return: + on_labPicture_mouseDoubleClicked(); + returnValue = true; break; } } } - return false; + return returnValue; +} + +void PictureDialog::mousePressEvent(QMouseEvent *ev) +{ + ev->accept(); } void PictureDialog::dialogNextPictureRequested() diff --git a/PictureDialog.h b/PictureDialog.h index f52a9e1..2fe93e3 100755 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -21,7 +21,9 @@ #include "SnapmaticPicture.h" #include "ProfileDatabase.h" +#include #include +#include #include namespace Ui { @@ -61,6 +63,7 @@ signals: protected: bool eventFilter(QObject *obj, QEvent *ev); + void mousePressEvent(QMouseEvent *ev); private: ProfileDatabase *profileDB; diff --git a/PictureDialog.ui b/PictureDialog.ui index 1741933..8bfa4a9 100755 --- a/PictureDialog.ui +++ b/PictureDialog.ui @@ -87,7 +87,7 @@ true - Qt::TextBrowserInteraction + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse @@ -119,22 +119,34 @@ + + Qt::ClickFocus + Export picture &Export + + false + + + Qt::ClickFocus + Close &Close + + false +