summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--viewer.cpp9
-rw-r--r--viewer.h1
2 files changed, 3 insertions, 7 deletions
diff --git a/viewer.cpp b/viewer.cpp
index d0077f7..6a4f634 100644
--- a/viewer.cpp
+++ b/viewer.cpp
@@ -1,6 +1,5 @@
#include <QLabel>
#include <QHBoxLayout>
-#include <QDesktopWidget>
#include <QApplication>
#include <QFileInfo>
#include <QMimeDatabase>
@@ -11,14 +10,10 @@
#include "viewer.h"
Viewer::Viewer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f), mCurIndex(-1) {
- QDesktopWidget *dw = qApp->desktop();
setAutoFillBackground(true);
setBackgroundRole(QPalette::AlternateBase);
mLabel = new QLabel;
mLabel->setAlignment(Qt::AlignCenter);
- mMaxSize = dw->size();
- //90 is an arbitrary value, but it works :)
- mMaxSize.setHeight(mMaxSize.height() - 90);
QHBoxLayout *mainLayout = new QHBoxLayout;
mainLayout->addWidget(mLabel);
setLayout(mainLayout);
@@ -97,7 +92,9 @@ void Viewer::displayFile(int index){
setBackgroundRole(QPalette::AlternateBase);
}
QPixmap pm(mFiles.at(mCurIndex));
- pm = pm.scaled(mMaxSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ if((pm.height() > height()) || (pm.width() > width())){
+ pm = pm.scaled(QSize(width() - 20, height() - 20), Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ }
mLabel->setPixmap(pm);
QString winTitle = QString(tr("%1 Viewer [%2]")).arg(qApp->applicationName()).arg(mFiles.at(mCurIndex));
setWindowTitle(winTitle);
diff --git a/viewer.h b/viewer.h
index 0bbb7ea..196a2dd 100644
--- a/viewer.h
+++ b/viewer.h
@@ -22,7 +22,6 @@ class Viewer : public QWidget {
int mCurIndex;
QLabel *mLabel;
QStringList mFiles;
- QSize mMaxSize;
};
#endif // VIEWER_H