summary refs log tree commit diff
path: root/src/dialogs/ImageOverlay.cpp
diff options
context:
space:
mode:
authorJoseph Donofry <joedonofry@gmail.com>2020-02-28 19:10:39 -0500
committerGitHub <noreply@github.com>2020-02-28 19:10:39 -0500
commit30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606 (patch)
treeddadd16c86600ce937b47798a9b3d5ff2fdec998 /src/dialogs/ImageOverlay.cpp
parentMerge pull request #129 from nico202/master (diff)
parentMerge branch 'master' into 0.7.0-dev (diff)
downloadnheko-30cb7c5b02bb8a21a8d7257cfe5a8bd3db891606.tar.xz
Merge pull request #130 from Nheko-Reborn/0.7.0-dev
0.7.0 dev merge to master
Diffstat (limited to 'src/dialogs/ImageOverlay.cpp')
-rw-r--r--src/dialogs/ImageOverlay.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/dialogs/ImageOverlay.cpp b/src/dialogs/ImageOverlay.cpp

index dbf5bbe4..e075fb67 100644 --- a/src/dialogs/ImageOverlay.cpp +++ b/src/dialogs/ImageOverlay.cpp
@@ -17,7 +17,9 @@ #include <QApplication> #include <QDesktopWidget> +#include <QGuiApplication> #include <QPainter> +#include <QScreen> #include "dialogs/ImageOverlay.h" @@ -30,7 +32,7 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent) , originalImage_{image} { setMouseTracking(true); - setParent(0); + setParent(nullptr); setWindowFlags(windowFlags() | Qt::FramelessWindowHint); @@ -39,11 +41,6 @@ ImageOverlay::ImageOverlay(QPixmap image, QWidget *parent) setAttribute(Qt::WA_DeleteOnClose, true); setWindowState(Qt::WindowFullScreen); - screen_ = QApplication::desktop()->availableGeometry(); - - move(QApplication::desktop()->mapToGlobal(screen_.topLeft())); - resize(screen_.size()); - connect(this, SIGNAL(closing()), this, SLOT(close())); raise(); @@ -58,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_); @@ -74,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_);