Skip to content
Snippets Groups Projects
Unverified Commit 3c54d60e authored by Nicolas Werner's avatar Nicolas Werner Committed by GitHub
Browse files

Merge pull request #114 from adasauce/image-overlay-fix

Fix image overlay appearing on the wrong screen.

thanks adasauce!
parents 284fc8ea a2566b87
No related branches found
No related tags found
No related merge requests found
......@@ -41,11 +41,6 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent)
setAttribute(Qt::WA_DeleteOnClose, true);
setWindowState(Qt::WindowFullScreen);
screen_ = QGuiApplication::primaryScreen()->availableGeometry();
move(QApplication::desktop()->mapToGlobal(screen_.topLeft()));
resize(screen_.size());
connect(this, SIGNAL(closing()), this, SLOT(close()));
raise();
......@@ -60,15 +55,15 @@ ImageOverlay::paintEvent(QPaintEvent *event)
painter.setRenderHint(QPainter::Antialiasing);
// Full screen overlay.
painter.fillRect(QRect(0, 0, screen_.width(), screen_.height()), QColor(55, 55, 55, 170));
painter.fillRect(QRect(0, 0, width(), height()), QColor(55, 55, 55, 170));
// Left and Right margins
int outer_margin = screen_.width() * 0.12;
int outer_margin = width() * 0.12;
int buttonSize = 36;
int margin = outer_margin * 0.1;
int max_width = screen_.width() - 2 * outer_margin;
int max_height = screen_.height();
int max_width = width() - 2 * outer_margin;
int max_height = height();
image_ = utils::scaleDown(max_width, max_height, originalImage_);
......@@ -76,10 +71,9 @@ ImageOverlay::paintEvent(QPaintEvent *event)
int diff_y = max_height - image_.height();
content_ = QRect(outer_margin + diff_x / 2, diff_y / 2, image_.width(), image_.height());
close_button_ =
QRect(screen_.width() - margin - buttonSize, margin, buttonSize, buttonSize);
close_button_ = QRect(width() - margin - buttonSize, margin, buttonSize, buttonSize);
save_button_ =
QRect(screen_.width() - (2 * margin) - (2 * buttonSize), margin, buttonSize, buttonSize);
QRect(width() - (2 * margin) - (2 * buttonSize), margin, buttonSize, buttonSize);
// Draw main content_.
painter.drawPixmap(content_, image_);
......
......@@ -44,6 +44,5 @@ private:
QRect content_;
QRect close_button_;
QRect save_button_;
QRect screen_;
};
} // dialogs
......@@ -158,7 +158,7 @@ TimelineViewManager::openImageOverlay(QString mxcUrl, QString eventId) const
auto pixmap = QPixmap::fromImage(imgResponse->textureFactory()->image());
auto imgDialog = new dialogs::ImageOverlay(pixmap);
imgDialog->show();
imgDialog->showFullScreen();
connect(imgDialog, &dialogs::ImageOverlay::saving, timeline_, [this, eventId]() {
timeline_->saveMedia(eventId);
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment