Merge pull request #679 from Kirillpt/iss_672

add shortcut Escape button for closing images. issue #672
This commit is contained in:
DeepBlueV7.X 2021-08-11 00:09:16 +00:00 committed by GitHub
commit d84c1f59a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -28,8 +28,10 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent)
setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_TranslucentBackground, true);
setAttribute(Qt::WA_DeleteOnClose, true); setAttribute(Qt::WA_DeleteOnClose, true);
setWindowState(Qt::WindowFullScreen); 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);
raise(); raise();
} }

View file

@ -8,6 +8,7 @@
#include <QDialog> #include <QDialog>
#include <QMouseEvent> #include <QMouseEvent>
#include <QPixmap> #include <QPixmap>
#include <QShortcut>
namespace dialogs { namespace dialogs {
@ -32,5 +33,6 @@ private:
QRect content_; QRect content_;
QRect close_button_; QRect close_button_;
QRect save_button_; QRect save_button_;
QShortcut *close_shortcut_;
}; };
} // dialogs } // dialogs