annotate src/imagelabel.cpp @ 33:58f1b3c330af

(issue9) Show maximized by default If the Window geometry is not saved show maximized otherwise restore the Window state / geometry.
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 May 2015 15:41:42 +0200
parents 6b9b5efcd7f4
children 26e1521b9afd
rev   line source
24
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
1 /* Copyright (C) 2015 by ETH Zürich
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
2 * Software engineering by Intevation GmbH
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
3 *
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
4 * This file is Free Software under the GNU GPL (v>=2)
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY!
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
6 * See LICENSE.txt for details.
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
7 */
6b9b5efcd7f4 Add missing copyright header
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
8
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
9 #include "imagelabel.h"
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
10
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
11 ImageLabel::ImageLabel(QWidget *parent) :
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
12 QWidget(parent) {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
13 label = new QLabel(this);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
14 label->setScaledContents(true);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
15 label->setFixedSize(0,0);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
16 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
17
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
18 void ImageLabel::resizeEvent(QResizeEvent *event) {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
19 QWidget::resizeEvent(event);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
20 resizeImage();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
21 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
22
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
23 const QPixmap* ImageLabel::pixmap() const {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
24 return label->pixmap();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
25 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
26
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
27 void ImageLabel::setPixmap (const QPixmap &pixmap){
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
28 label->setPixmap(pixmap);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
29 resizeImage();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
30 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
31
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
32 void ImageLabel::resizeImage() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
33 QSize pixSize = label->pixmap()->size();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
34 pixSize.scale(size(), Qt::KeepAspectRatio);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
35 label->setFixedSize(pixSize);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
36 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)