From e6fd80f87f31d15c2a1ec73a22ba3e76647151f0 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sun, 30 Apr 2017 13:00:11 +0300 Subject: [PATCH] Fix MainWindow being out of focus when the fullscreen overlay is closed That was probably a Linux specific issue or my mouse is buggy. --- include/ImageOverlayDialog.h | 6 ++++++ src/ImageOverlayDialog.cc | 13 ++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/ImageOverlayDialog.h b/include/ImageOverlayDialog.h index 21f59d12..e9eed0c1 100644 --- a/include/ImageOverlayDialog.h +++ b/include/ImageOverlayDialog.h @@ -32,6 +32,12 @@ protected: void mousePressEvent(QMouseEvent *event) override; void paintEvent(QPaintEvent *event) override; +signals: + void closing(); + +private slots: + void closeDialog(); + private: void scaleImage(int width, int height); diff --git a/src/ImageOverlayDialog.cc b/src/ImageOverlayDialog.cc index 04bda711..55e0df00 100644 --- a/src/ImageOverlayDialog.cc +++ b/src/ImageOverlayDialog.cc @@ -17,6 +17,7 @@ #include #include +#include #include "ImageOverlayDialog.h" @@ -36,6 +37,13 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) setWindowState(Qt::WindowFullScreen); raise(); + + connect(this, SIGNAL(closing()), this, SLOT(closeDialog())); +} + +void ImageOverlayDialog::closeDialog() +{ + QTimer::singleShot(100, this, &ImageOverlayDialog::reject); } // TODO: Move this into Utils @@ -110,9 +118,8 @@ void ImageOverlayDialog::mousePressEvent(QMouseEvent *event) if (event->button() != Qt::LeftButton) return; - // FIXME: The main window needs double click to regain focus. if (close_button_.contains(event->pos())) - close(); + emit closing(); else if (!content_.contains(event->pos())) - close(); + emit closing(); }