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->labPicCustomRes->setVisible(false); | ||||
| 
 | ||||
|     QRect desktopResolution = QApplication::desktop()->screenGeometry(); | ||||
|     QRect desktopResolution = QApplication::desktop()->screenGeometry(parent); | ||||
|     int desktopSizeWidth = desktopResolution.width(); | ||||
|     int desktopSizeHeight = desktopResolution.height(); | ||||
|     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(previousPictureRequested()), this, SLOT(dialogPreviousPictureRequested())); | ||||
| 
 | ||||
|         pictureWidget->setMinimumSize(desktopRect.width(), desktopRect.height()); | ||||
|         pictureWidget->setMaximumSize(desktopRect.width(), desktopRect.height()); | ||||
|         pictureWidget->move(desktopRect.x(), desktopRect.y()); | ||||
|         pictureWidget->resize(desktopRect.width(), desktopRect.height()); | ||||
|         pictureWidget->showFullScreen(); | ||||
|         pictureWidget->setFocus(); | ||||
|         pictureWidget->raise(); | ||||
|  |  | |||
|  | @ -19,6 +19,8 @@ | |||
| #include "PictureDialog.h" | ||||
| #include "PictureWidget.h" | ||||
| #include "UiModLabel.h" | ||||
| #include <QDesktopWidget> | ||||
| #include <QApplication> | ||||
| #include <QHBoxLayout> | ||||
| #include <QKeyEvent> | ||||
| #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(customContextMenuRequested(QPoint)), parent, SLOT(exportCustomContextMenuRequested(QPoint))); | ||||
|     QObject::connect(QApplication::desktop(), SIGNAL(resized(int)), this, SLOT(updateWindowSize(int))); | ||||
| 
 | ||||
|     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))); | ||||
| } | ||||
| 
 | ||||
| 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))); | ||||
| } | ||||
| 
 | ||||
| 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: | ||||
|     QHBoxLayout *widgetLayout; | ||||
|     UiModLabel *pictureLabel; | ||||
|     QImage image; | ||||
| 
 | ||||
| private slots: | ||||
|     void pictureDoubleClicked(Qt::MouseButton button); | ||||
|     void updateWindowSize(int screenID); | ||||
| 
 | ||||
| signals: | ||||
|     void nextPictureRequested(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue