Fix MainWindow being out of focus when the fullscreen overlay is closed

That was probably a Linux specific issue or my mouse is buggy.
This commit is contained in:
Konstantinos Sideris 2017-04-30 13:00:11 +03:00
parent 41f6dbe053
commit e6fd80f87f
2 changed files with 16 additions and 3 deletions

View file

@ -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);

View file

@ -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();
}