macOS fixes for build, fullscreen image sizing and horizontal overscroll of RoomInfoListItem
This commit is contained in:
parent
3d77438878
commit
202ad49aff
@ -42,6 +42,9 @@ $ brew update
|
|||||||
$ brew install qt5
|
$ brew install qt5
|
||||||
```
|
```
|
||||||
|
|
||||||
|
N.B. you will need to pass `-DCMAKE_PREFIX_PATH=/usr/local/opt/qt5`
|
||||||
|
to cmake to point it at your qt5 install (tweaking the path as needed)
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
|
ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
|
||||||
: QDialog{parent}
|
: QDialog{parent}
|
||||||
, image_{image}
|
, originalImage_{image}
|
||||||
{
|
{
|
||||||
setMouseTracking(true);
|
setMouseTracking(true);
|
||||||
setModal(false);
|
setModal(false);
|
||||||
@ -36,11 +36,19 @@ ImageOverlayDialog::ImageOverlayDialog(QPixmap image, QWidget *parent)
|
|||||||
|
|
||||||
setWindowState(Qt::WindowFullScreen);
|
setWindowState(Qt::WindowFullScreen);
|
||||||
|
|
||||||
raise();
|
|
||||||
|
|
||||||
connect(this, SIGNAL(closing()), this, SLOT(closeDialog()));
|
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()
|
void ImageOverlayDialog::closeDialog()
|
||||||
{
|
{
|
||||||
QTimer::singleShot(100, this, &ImageOverlayDialog::reject);
|
QTimer::singleShot(100, this, &ImageOverlayDialog::reject);
|
||||||
@ -49,11 +57,11 @@ void ImageOverlayDialog::closeDialog()
|
|||||||
// TODO: Move this into Utils
|
// TODO: Move this into Utils
|
||||||
void ImageOverlayDialog::scaleImage(int max_width, int max_height)
|
void ImageOverlayDialog::scaleImage(int max_width, int max_height)
|
||||||
{
|
{
|
||||||
if (image_.isNull())
|
if (originalImage_.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto width_ratio = (double)max_width / (double)image_.width();
|
auto width_ratio = (double)max_width / (double)originalImage_.width();
|
||||||
auto height_ratio = (double)max_height / (double)image_.height();
|
auto height_ratio = (double)max_height / (double)originalImage_.height();
|
||||||
|
|
||||||
auto min_aspect_ratio = std::min(width_ratio, height_ratio);
|
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;
|
int final_height = 0;
|
||||||
|
|
||||||
if (min_aspect_ratio > 1) {
|
if (min_aspect_ratio > 1) {
|
||||||
final_width = image_.width();
|
final_width = originalImage_.width();
|
||||||
final_height = image_.height();
|
final_height = originalImage_.height();
|
||||||
} else {
|
} else {
|
||||||
final_width = image_.width() * min_aspect_ratio;
|
final_width = originalImage_.width() * min_aspect_ratio;
|
||||||
final_height = image_.height() * 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)
|
void ImageOverlayDialog::paintEvent(QPaintEvent *event)
|
||||||
|
@ -41,7 +41,7 @@ RoomInfoListItem::RoomInfoListItem(RoomInfo info, QWidget *parent)
|
|||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
setAutoFillBackground(true);
|
setAutoFillBackground(true);
|
||||||
|
|
||||||
setMinimumSize(parent->width(), max_height_);
|
setMaximumSize(parent->width(), max_height_);
|
||||||
|
|
||||||
topLayout_ = new QHBoxLayout(this);
|
topLayout_ = new QHBoxLayout(this);
|
||||||
topLayout_->setSpacing(0);
|
topLayout_->setSpacing(0);
|
||||||
|
Loading…
Reference in New Issue
Block a user