summary refs log tree commit diff
path: root/src/ImageOverlayDialog.cc
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@arasphere.net>2017-05-04 11:11:04 +0100
committermujx <mujx@users.noreply.github.com>2017-05-04 13:11:04 +0300
commit9cc9b623ebae8ef9021d1462dc0d58189777f65e (patch)
treef29aadf4fa82e202364f217d22aca12dc9e23442 /src/ImageOverlayDialog.cc
parentSet application attributes before QApplication (diff)
downloadnheko-9cc9b623ebae8ef9021d1462dc0d58189777f65e.tar.xz
macOS fixes (#15)
- Improve build instructions.
- Fix fullscreen image sizing.
- Remove horizontal overscroll of RoomInfoListItem.

Diffstat (limited to 'src/ImageOverlayDialog.cc')
-rw-r--r--src/ImageOverlayDialog.cc30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/ImageOverlayDialog.cc b/src/ImageOverlayDialog.cc

index 55e0df00..b23f2a34 100644 --- a/src/ImageOverlayDialog.cc +++ b/src/ImageOverlayDialog.cc
@@ -23,7 +23,7 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) : QDialog{parent} - , image_{image} + , originalImage_{image} { setMouseTracking(true); setModal(false); @@ -36,11 +36,19 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent) setWindowState(Qt::WindowFullScreen); - raise(); - connect(this, SIGNAL(closing()), this, SLOT(closeDialog())); } +void ImageOverlayDialog::reject() +{ + // needed on macOS to recover the main menu after the dialog is closed(!) + // also affects KDE/Plasma. XXX: There may be a better way of resetting the + // window state than this... + setWindowState(Qt::WindowNoState); + + QDialog::reject(); +} + void ImageOverlayDialog::closeDialog() { QTimer::singleShot(100, this, &ImageOverlayDialog::reject); @@ -49,11 +57,11 @@ void ImageOverlayDialog::closeDialog() // TODO: Move this into Utils void ImageOverlayDialog::scaleImage(int max_width, int max_height) { - if (image_.isNull()) + if (originalImage_.isNull()) return; - auto width_ratio = (double)max_width / (double)image_.width(); - auto height_ratio = (double)max_height / (double)image_.height(); + auto width_ratio = (double)max_width / (double)originalImage_.width(); + auto height_ratio = (double)max_height / (double)originalImage_.height(); auto min_aspect_ratio = std::min(width_ratio, height_ratio); @@ -61,14 +69,14 @@ void ImageOverlayDialog::scaleImage(int max_width, int max_height) int final_height = 0; if (min_aspect_ratio > 1) { - final_width = image_.width(); - final_height = image_.height(); + final_width = originalImage_.width(); + final_height = originalImage_.height(); } else { - final_width = image_.width() * min_aspect_ratio; - final_height = image_.height() * min_aspect_ratio; + final_width = originalImage_.width() * min_aspect_ratio; + final_height = originalImage_.height() * min_aspect_ratio; } - image_ = image_.scaled(final_width, final_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + image_ = originalImage_.scaled(final_width, final_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } void ImageOverlayDialog::paintEvent(QPaintEvent *event)