Mercurial > retraceit
annotate src/pngplayer.cpp @ 3:248d5d1cdb38
Add functionalty to control buttons and make picture resizable
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Mon, 23 Mar 2015 19:10:01 +0100 |
parents | 97d2c8869c39 |
children | 107e435cb569 |
rev | line source |
---|---|
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
1 /* Copyright (C) 2014 by Intevation GmbH |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
2 * |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 * This file is Free Software under the GNU GPL (v>=2) |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 * and comes with ABSOLUTELY NO WARRANTY! |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
5 * See LICENSE.txt for details. |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 */ |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 #include "pngplayer.h" |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
8 #include "constants.h" |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
9 #include "imagelabel.h" |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
10 #include <QVBoxLayout> |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 #include <QPixmap> |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QLabel> |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
13 #include <QPushButton> |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
14 #include <QHBoxLayout> |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
15 #include <QSlider> |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
16 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
17 #include <QDebug> |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
18 |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 PNGPlayer::PNGPlayer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 setupGUI(); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
21 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
22 |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
23 void PNGPlayer::setupGUI() { |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
24 QVBoxLayout *baseLayout = new QVBoxLayout; |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
25 mPNGLabel = new ImageLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
26 mPNGLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
27 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
28 QHBoxLayout *controlArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
29 QHBoxLayout *controlBtns = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
30 controlArea->addLayout(controlBtns); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
31 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
32 QPushButton *firstBtn = new QPushButton("First"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
33 controlBtns->addWidget(firstBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
34 connect(firstBtn, &QPushButton::clicked, this, &PNGPlayer::firstClicked); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
35 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
36 QPushButton *prevBtn = new QPushButton("Prev"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
37 controlBtns->addWidget(prevBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
38 connect(prevBtn, &QPushButton::clicked, this, &PNGPlayer::back); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
39 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
40 mPlayBtn = new QPushButton("Play"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
41 mPlayBtn->setCheckable(true); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
42 controlBtns->addWidget(mPlayBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
43 connect(mPlayBtn, &QPushButton::clicked, this, &PNGPlayer::togglePlay); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
44 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
45 QPushButton *nextBtn = new QPushButton("Next"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
46 connect(nextBtn, &QPushButton::clicked, this, &PNGPlayer::advance); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
47 controlBtns->addWidget(nextBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
48 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
49 QPushButton *lastBtn = new QPushButton("Last"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
50 controlBtns->addWidget(lastBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
51 connect(lastBtn, &QPushButton::clicked, this, &PNGPlayer::lastClicked); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
52 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
53 mSlider = new QSlider(Qt::Horizontal); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
54 mSlider->setTickPosition(QSlider::TicksBelow); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
55 connect(mSlider, &QSlider::valueChanged, this, &PNGPlayer::sliderChanged); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
56 connect(mSlider, &QSlider::sliderPressed, this, &PNGPlayer::sliderPressed); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
57 connect(mSlider, &QSlider::sliderReleased, this, &PNGPlayer::sliderReleased); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
58 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
59 QVBoxLayout *speedInfoArea = new QVBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
60 QHBoxLayout *speedArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
61 speedInfoArea->addLayout(speedArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
62 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
63 QLabel *speedLabel = new QLabel(tr("Speed:")); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
64 speedArea->addWidget(speedLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
65 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
66 mSpeedSlider = new QSlider(Qt::Horizontal); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
67 mSpeedSlider->setMaximum(10000); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
68 mSpeedSlider->setTickInterval(500); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
69 mSpeedSlider->setTickPosition(QSlider::TicksBelow); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
70 speedArea->addWidget(mSpeedSlider); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
71 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
72 mCurSpeedLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
73 speedArea->addWidget(mCurSpeedLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
74 speedArea->addStretch(-1); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
75 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
76 mPositionLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
77 speedInfoArea->addWidget(mPositionLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
78 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
79 controlArea->addLayout(speedInfoArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
80 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
81 baseLayout->addWidget(mPNGLabel); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
82 baseLayout->addLayout(controlArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
83 baseLayout->addWidget(mSlider); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
84 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
85 connect(&mAdvanceTimer, SIGNAL(timeout()), this, SIGNAL(advance())); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
86 setLayout(baseLayout); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
87 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
88 |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
89 void PNGPlayer::showPicture(const QString& fileName, int current, int max, |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
90 const QDateTime& timestamp) { |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
91 QPixmap pic(mBaseDir.filePath(fileName)); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
92 /* If this is too slow we could use a pixmap cache here and do |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
93 * some intelligent preloading */ |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
94 if (pic.isNull()) { |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
95 emit error(tr("Failed to load picture: '%1'").arg(fileName)); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
96 return; |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
97 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
98 mPNGLabel->setPixmap(pic); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
99 updatePositions(current, max, timestamp); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
100 } |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
101 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
102 void PNGPlayer::updatePositions(int current, int max, const QDateTime& timestamp) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
103 mMax = max; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
104 mSlider->blockSignals(true); /* We only want user generated changes */ |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
105 mSlider->setValue(current); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
106 mSlider->blockSignals(false); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
107 mSlider->setMaximum(max); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
108 mPositionLabel->setText("<b>" + tr("Screenshot Nr.:") + " </b>" + |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
109 QString("%1 (%2)").arg(current).arg(max) + " / <b>" + |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
110 tr("Timestamp:") + " </b>" + timestamp.toString(LONG_DATE_FORMAT)); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
111 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
112 if (mMax == current && mAdvanceTimer.isActive()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
113 togglePlay(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
114 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
115 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
116 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
117 void PNGPlayer::setSpeed(int mSecsPerPicture) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
118 if (mSecsPerPicture == 1000) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
119 mCurSpeedLabel->setText(tr("%1 second per Picture"). |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
120 arg(mSecsPerPicture / 1000)); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
121 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
122 mCurSpeedLabel->setText(tr("%1 seconds per Picture"). |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
123 arg(mSecsPerPicture / 1000)); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
124 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
125 mSpeedSlider->setValue(mSecsPerPicture); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
126 mAdvanceTimer.setInterval(mSecsPerPicture); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
127 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
128 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
129 void PNGPlayer::togglePlay() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
130 if (mAdvanceTimer.isActive()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
131 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
132 mPlayBtn->setText("Play"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
133 mPlayBtn->setChecked(false); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
134 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
135 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
136 mPlayBtn->setText("Pause"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
137 mPlayBtn->setChecked(true); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
138 emit advance(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
139 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
140 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
141 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
142 void PNGPlayer::sliderChanged() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
143 qDebug() << "Slider moved. "; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
144 emit jumpToFrame(mSlider->value()); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
145 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
146 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
147 void PNGPlayer::sliderPressed() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
148 qDebug() << "Slider pressed. Deactivating timer. "; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
149 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
150 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
151 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
152 void PNGPlayer::sliderReleased() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
153 if (mPlayBtn->isChecked()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
154 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
155 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
156 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
157 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
158 void PNGPlayer::firstClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
159 emit jumpToFrame(0); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
160 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
161 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
162 void PNGPlayer::lastClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
163 emit jumpToFrame(mMax); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
164 } |