fullscreen picture viewer adapt when screen size changed
This commit is contained in:
parent
3138a8e1ca
commit
cb009c0f6e
4 changed files with 25 additions and 5 deletions
|
@ -41,7 +41,7 @@ OptionsDialog::OptionsDialog(ProfileDatabase *profileDB, QWidget *parent) :
|
||||||
ui->tabWidget->setCurrentIndex(0);
|
ui->tabWidget->setCurrentIndex(0);
|
||||||
ui->labPicCustomRes->setVisible(false);
|
ui->labPicCustomRes->setVisible(false);
|
||||||
|
|
||||||
QRect desktopResolution = QApplication::desktop()->screenGeometry();
|
QRect desktopResolution = QApplication::desktop()->screenGeometry(parent);
|
||||||
int desktopSizeWidth = desktopResolution.width();
|
int desktopSizeWidth = desktopResolution.width();
|
||||||
int desktopSizeHeight = desktopResolution.height();
|
int desktopSizeHeight = desktopResolution.height();
|
||||||
aspectRatio = Qt::KeepAspectRatio;
|
aspectRatio = Qt::KeepAspectRatio;
|
||||||
|
|
|
@ -400,8 +400,8 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
|
||||||
QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested()));
|
QObject::connect(pictureWidget, SIGNAL(nextPictureRequested()), this, SLOT(dialogNextPictureRequested()));
|
||||||
QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
|
QObject::connect(pictureWidget, SIGNAL(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested()));
|
||||||
|
|
||||||
pictureWidget->setMinimumSize(desktopRect.width(), desktopRect.height());
|
pictureWidget->move(desktopRect.x(), desktopRect.y());
|
||||||
pictureWidget->setMaximumSize(desktopRect.width(), desktopRect.height());
|
pictureWidget->resize(desktopRect.width(), desktopRect.height());
|
||||||
pictureWidget->showFullScreen();
|
pictureWidget->showFullScreen();
|
||||||
pictureWidget->setFocus();
|
pictureWidget->setFocus();
|
||||||
pictureWidget->raise();
|
pictureWidget->raise();
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "PictureDialog.h"
|
#include "PictureDialog.h"
|
||||||
#include "PictureWidget.h"
|
#include "PictureWidget.h"
|
||||||
#include "UiModLabel.h"
|
#include "UiModLabel.h"
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QApplication>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
@ -42,6 +44,7 @@ PictureWidget::PictureWidget(QWidget *parent) : QDialog(parent)
|
||||||
|
|
||||||
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton)));
|
QObject::connect(pictureLabel, SIGNAL(mouseDoubleClicked(Qt::MouseButton)), this, SLOT(pictureDoubleClicked(Qt::MouseButton)));
|
||||||
QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint)));
|
QObject::connect(pictureLabel, SIGNAL(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint)));
|
||||||
|
QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(updateWindowSize(int)));
|
||||||
|
|
||||||
setLayout(widgetLayout);
|
setLayout(widgetLayout);
|
||||||
}
|
}
|
||||||
|
@ -81,12 +84,27 @@ void PictureWidget::pictureDoubleClicked(Qt::MouseButton button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureWidget::setImage(QImage image, QRect rec)
|
void PictureWidget::setImage(QImage image_, QRect rec)
|
||||||
{
|
{
|
||||||
|
image = image_;
|
||||||
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(rec.width(), rec.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureWidget::setImage(QImage image)
|
void PictureWidget::setImage(QImage image_)
|
||||||
{
|
{
|
||||||
|
image = image_;
|
||||||
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(geometry().width(), geometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(geometry().width(), geometry().height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PictureWidget::updateWindowSize(int screenID)
|
||||||
|
{
|
||||||
|
if (screenID = QApplication::desktop()->screenNumber(this))
|
||||||
|
{
|
||||||
|
QRect desktopRect = QApplication::desktop()->screenGeometry(this);
|
||||||
|
this->move(desktopRect.x(), desktopRect.y());
|
||||||
|
this->resize(desktopRect.width(), desktopRect.height());
|
||||||
|
this->showFullScreen();
|
||||||
|
pictureLabel->setPixmap(QPixmap::fromImage(image.scaled(desktopRect.width(), desktopRect.height(), Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -42,9 +42,11 @@ protected:
|
||||||
private:
|
private:
|
||||||
QHBoxLayout *widgetLayout;
|
QHBoxLayout *widgetLayout;
|
||||||
UiModLabel *pictureLabel;
|
UiModLabel *pictureLabel;
|
||||||
|
QImage image;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void pictureDoubleClicked(Qt::MouseButton button);
|
void pictureDoubleClicked(Qt::MouseButton button);
|
||||||
|
void updateWindowSize(int screenID);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nextPictureRequested();
|
void nextPictureRequested();
|
||||||
|
|
Loading…
Reference in a new issue