From 21a649492f717f1285066a2881d6d93b1ac68343 Mon Sep 17 00:00:00 2001 From: salahmak Date: Sat, 20 Mar 2021 11:18:16 +0100 Subject: [PATCH 1/2] Pressing escape hides PreviewUploadOverlay --- src/dialogs/PreviewUploadOverlay.cpp | 10 ++++++++++ src/dialogs/PreviewUploadOverlay.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/dialogs/PreviewUploadOverlay.cpp b/src/dialogs/PreviewUploadOverlay.cpp index b2bef136..c0a02bdd 100644 --- a/src/dialogs/PreviewUploadOverlay.cpp +++ b/src/dialogs/PreviewUploadOverlay.cpp @@ -203,3 +203,13 @@ PreviewUploadOverlay::setPreview(const QString &path) setLabels(split[1], mime.name(), data_.size()); init(); } + +void +PreviewUploadOverlay::keyPressEvent(QKeyEvent *event) +{ + if( event->key() == Qt::Key_Escape ) + { + emit aborted(); + close(); + } +} \ No newline at end of file diff --git a/src/dialogs/PreviewUploadOverlay.h b/src/dialogs/PreviewUploadOverlay.h index 7493f67c..d23ea0ae 100644 --- a/src/dialogs/PreviewUploadOverlay.h +++ b/src/dialogs/PreviewUploadOverlay.h @@ -25,6 +25,7 @@ public: void setPreview(const QImage &src, const QString &mime); void setPreview(const QByteArray data, const QString &mime); void setPreview(const QString &path); + void keyPressEvent(QKeyEvent *event); signals: void confirmUpload(const QByteArray data, const QString &media, const QString &filename); From 2108d98c6dc336178ab7342eee9167158ee35175 Mon Sep 17 00:00:00 2001 From: salahmak Date: Sat, 20 Mar 2021 21:09:04 +0100 Subject: [PATCH 2/2] Pressing escape hides PreviewUploadOverlay --- src/dialogs/PreviewUploadOverlay.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/dialogs/PreviewUploadOverlay.cpp b/src/dialogs/PreviewUploadOverlay.cpp index c0a02bdd..66fa1b37 100644 --- a/src/dialogs/PreviewUploadOverlay.cpp +++ b/src/dialogs/PreviewUploadOverlay.cpp @@ -207,9 +207,10 @@ PreviewUploadOverlay::setPreview(const QString &path) void PreviewUploadOverlay::keyPressEvent(QKeyEvent *event) { - if( event->key() == Qt::Key_Escape ) - { - emit aborted(); - close(); + if (event->matches(QKeySequence::Cancel)) { + emit aborted(); + close(); + } else { + QWidget::keyPressEvent(event); } } \ No newline at end of file