From a88c68c0a85ea7e4807d464543c720ee31f3013b Mon Sep 17 00:00:00 2001 From: kirp Date: Wed, 11 Aug 2021 01:39:27 +0300 Subject: [PATCH 1/3] add shortcut Escape button for closing images issues 672 --- src/dialogs/ImageOverlay.cpp | 2 ++ src/dialogs/ImageOverlay.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/dialogs/ImageOverlay.cpp b/src/dialogs/ImageOverlay.cpp index f38b29f5..0a3777f0 100644 --- a/src/dialogs/ImageOverlay.cpp +++ b/src/dialogs/ImageOverlay.cpp @@ -31,6 +31,8 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent) connect(this, SIGNAL(closing()), this, SLOT(close())); + close_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(close())); + raise(); } diff --git a/src/dialogs/ImageOverlay.h b/src/dialogs/ImageOverlay.h index 93b6afdc..9d4187bf 100644 --- a/src/dialogs/ImageOverlay.h +++ b/src/dialogs/ImageOverlay.h @@ -8,6 +8,7 @@ #include #include #include +#include namespace dialogs { @@ -32,5 +33,6 @@ private: QRect content_; QRect close_button_; QRect save_button_; + QShortcut *close_shortcut_; }; } // dialogs From c7295d7fd1a4732592c8fc9d2ffd7fd6ebba40eb Mon Sep 17 00:00:00 2001 From: kirp Date: Wed, 11 Aug 2021 02:26:26 +0300 Subject: [PATCH 2/3] change slot close, to signal closing --- src/dialogs/ImageOverlay.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/dialogs/ImageOverlay.cpp b/src/dialogs/ImageOverlay.cpp index 0a3777f0..50cc5564 100644 --- a/src/dialogs/ImageOverlay.cpp +++ b/src/dialogs/ImageOverlay.cpp @@ -28,10 +28,11 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent) setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_DeleteOnClose, true); setWindowState(Qt::WindowFullScreen); + close_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this); - connect(this, SIGNAL(closing()), this, SLOT(close())); + connect(close_shortcut_, &QShortcut::activated, this, &ImageOverlay::closing); + connect(this, &ImageOverlay::closing, this, &ImageOverlay::close); - close_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this, SLOT(close())); raise(); } From 5335e043e76e13b8b101eee7be1f39e444548543 Mon Sep 17 00:00:00 2001 From: kirp Date: Wed, 11 Aug 2021 02:29:36 +0300 Subject: [PATCH 3/3] linting --- src/dialogs/ImageOverlay.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dialogs/ImageOverlay.cpp b/src/dialogs/ImageOverlay.cpp index 50cc5564..12813d57 100644 --- a/src/dialogs/ImageOverlay.cpp +++ b/src/dialogs/ImageOverlay.cpp @@ -30,10 +30,9 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent) setWindowState(Qt::WindowFullScreen); close_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this); - connect(close_shortcut_, &QShortcut::activated, this, &ImageOverlay::closing); + connect(close_shortcut_, &QShortcut::activated, this, &ImageOverlay::closing); connect(this, &ImageOverlay::closing, this, &ImageOverlay::close); - raise(); }