Fix MainWindow being out of focus when the fullscreen overlay is closed
That was probably a Linux specific issue or my mouse is buggy.
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 <QDebug>
#include <QPainter>
+#include <QTimer>
#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();
}
|