summaryrefslogtreecommitdiffstats
path: root/viewer.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2022-07-02 21:14:23 +0200
committerArno <arno@disconnect.de>2022-07-02 21:14:23 +0200
commit3f14c4198dd29b3428e37befe5aec5fa8c5bcf68 (patch)
tree88aeb8a644da487cfaaa9b8c71550faebd5c3b7d /viewer.cpp
parente47954d9333c329b47a35ebbf63ee2a65e40d055 (diff)
downloadSheMov-3f14c4198dd29b3428e37befe5aec5fa8c5bcf68.tar.gz
SheMov-3f14c4198dd29b3428e37befe5aec5fa8c5bcf68.tar.bz2
SheMov-3f14c4198dd29b3428e37befe5aec5fa8c5bcf68.zip
Set fixed size for viewer.cpp
While adding new pictures to my collection, I realized that the simple viewer didn't obey it's size restrictions and grew out of proportions. So make the maximum size configurable.
Diffstat (limited to 'viewer.cpp')
-rw-r--r--viewer.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/viewer.cpp b/viewer.cpp
index cba6314..e11a02f 100644
--- a/viewer.cpp
+++ b/viewer.cpp
@@ -5,6 +5,7 @@
#include <QMimeDatabase>
#include <QDir>
#include <QWheelEvent>
+#include <QSettings>
#include "helper.h"
#include "viewer.h"
@@ -14,6 +15,10 @@ Viewer::Viewer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), mCurInd
setBackgroundRole(QPalette::AlternateBase);
mLabel = new QLabel;
mLabel->setAlignment(Qt::AlignCenter);
+ QSettings s;
+ int maxHeight = s.value("ui/maxheight").toInt();
+ int maxWidth = s.value("ui/maxwidth").toInt();
+ mMaxSize = QSize(maxWidth, maxHeight);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(mLabel);
setLayout(mainLayout);
@@ -92,8 +97,8 @@ void Viewer::displayFile(int index){
setBackgroundRole(QPalette::AlternateBase);
}
QPixmap pm(mFiles.at(mCurIndex));
- if((pm.height() > height()) || (pm.width() > width())){
- pm = pm.scaled(QSize(width() - 20, height() - 20), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ if(pm.height() > mMaxSize.height() || pm.width() > mMaxSize.width()){
+ pm = pm.scaled(mMaxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
}
mLabel->setPixmap(pm);
QString winTitle = QString(tr("%1 Viewer [%2]")).arg(qApp->applicationName(), mFiles.at(mCurIndex));