Mercurial > retraceit
annotate src/imagelabel.cpp @ 19:45553ac1eef8
Auto update translations
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 14 Apr 2015 18:56:31 +0200 |
parents | 248d5d1cdb38 |
children | 6b9b5efcd7f4 |
rev | line source |
---|---|
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 #include "imagelabel.h" |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 ImageLabel::ImageLabel(QWidget *parent) : |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 QWidget(parent) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 label = new QLabel(this); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 label->setScaledContents(true); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 label->setFixedSize(0,0); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
9 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 void ImageLabel::resizeEvent(QResizeEvent *event) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 QWidget::resizeEvent(event); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 resizeImage(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
14 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
15 const QPixmap* ImageLabel::pixmap() const { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
16 return label->pixmap(); |
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 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 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
|
20 label->setPixmap(pixmap); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 resizeImage(); |
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 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 void ImageLabel::resizeImage() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 QSize pixSize = label->pixmap()->size(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 pixSize.scale(size(), Qt::KeepAspectRatio); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 label->setFixedSize(pixSize); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 } |