Mercurial > retraceit
annotate src/pngplayer.cpp @ 8:ac4db84f1d9d
Fix date format in player window
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 14:25:21 +0100 |
parents | c11fe56aa4a2 |
children | f290e8c4e097 |
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> |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
16 #include <QSettings> |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
17 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
18 #include <QDebug> |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
19 |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
20 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
|
21 setupGUI(); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
22 QSettings settings; |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
23 mSpeedSlider->setValue(settings.value(REPLAY_SPEED_KEY, REPLAY_SPEED_DEFAULT).toInt()); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
24 speedChanged(); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
25 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
26 |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
27 void PNGPlayer::setupGUI() { |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
28 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
|
29 mPNGLabel = new ImageLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
30 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
|
31 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
32 QHBoxLayout *controlArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
33 QHBoxLayout *controlBtns = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
34 controlArea->addLayout(controlBtns); |
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 *firstBtn = new QPushButton("First"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
37 controlBtns->addWidget(firstBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
38 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
|
39 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
40 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
|
41 controlBtns->addWidget(prevBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
42 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
|
43 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
44 mPlayBtn = new QPushButton("Play"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
45 mPlayBtn->setCheckable(true); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
46 controlBtns->addWidget(mPlayBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
47 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
|
48 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
49 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
|
50 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
|
51 controlBtns->addWidget(nextBtn); |
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 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
|
54 controlBtns->addWidget(lastBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
55 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
|
56 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
57 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
|
58 mSlider->setTickPosition(QSlider::TicksBelow); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
59 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
|
60 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
|
61 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
|
62 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
63 QVBoxLayout *speedInfoArea = new QVBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
64 QHBoxLayout *speedArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
65 speedInfoArea->addLayout(speedArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
66 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
67 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
|
68 speedArea->addWidget(speedLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
69 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
70 mSpeedSlider = new QSlider(Qt::Horizontal); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
71 mSpeedSlider->setMaximum(10); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
72 mSpeedSlider->setTickInterval(1); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
73 mSpeedSlider->setTickPosition(QSlider::TicksBelow); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
74 mSpeedSlider->setTracking(false); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
75 mSpeedSlider->setInvertedAppearance(true); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
76 |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
77 speedArea->addWidget(mSpeedSlider); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
78 connect(mSpeedSlider, &QSlider::valueChanged, this, &PNGPlayer::speedChanged); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
79 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
80 mCurSpeedLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
81 speedArea->addWidget(mCurSpeedLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
82 speedArea->addStretch(-1); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
83 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
84 mPositionLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
85 speedInfoArea->addWidget(mPositionLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
86 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
87 controlArea->addLayout(speedInfoArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
88 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
89 baseLayout->addWidget(mPNGLabel); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
90 baseLayout->addLayout(controlArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
91 baseLayout->addWidget(mSlider); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
92 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
93 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
|
94 setLayout(baseLayout); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
95 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
96 |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
97 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
|
98 const QDateTime& timestamp) { |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
99 QPixmap pic(mBaseDir.filePath(fileName)); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
100 /* 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
|
101 * some intelligent preloading */ |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
102 if (pic.isNull()) { |
7
c11fe56aa4a2
Disable error if an image cannot be loaded
Andre Heinecke <andre.heinecke@intevation.de>
parents:
5
diff
changeset
|
103 // emit error(tr("Failed to load picture: '%1'").arg(fileName)); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
104 return; |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
105 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
106 mPNGLabel->setPixmap(pic); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
107 updatePositions(current, max, timestamp); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
108 } |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
109 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
110 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
|
111 mMax = max; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
112 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
|
113 mSlider->setValue(current); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
114 mSlider->blockSignals(false); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
115 mSlider->setMaximum(max); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
116 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
|
117 QString("%1 (%2)").arg(current).arg(max) + " / <b>" + |
8
ac4db84f1d9d
Fix date format in player window
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7
diff
changeset
|
118 tr("Timestamp:") + " </b>" + (timestamp.isValid() ? |
ac4db84f1d9d
Fix date format in player window
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7
diff
changeset
|
119 timestamp.toString(LONG_DATE_FORMAT) : tr("Unknown"))); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
120 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
121 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
|
122 togglePlay(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
123 } |
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 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
126 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
|
127 if (mSecsPerPicture == 1000) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
128 mCurSpeedLabel->setText(tr("%1 second per Picture"). |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
129 arg(mSecsPerPicture / 1000.)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
130 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
131 mCurSpeedLabel->setText(tr("%1 seconds per Picture"). |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
132 arg(mSecsPerPicture / 1000.)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
133 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
134 mAdvanceTimer.setInterval(mSecsPerPicture); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
135 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
136 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
137 void PNGPlayer::togglePlay() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
138 if (mAdvanceTimer.isActive()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
139 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
140 mPlayBtn->setText("Play"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
141 mPlayBtn->setChecked(false); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
142 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
143 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
144 mPlayBtn->setText("Pause"); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
145 mPlayBtn->setChecked(true); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
146 emit advance(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
147 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
148 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
149 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
150 void PNGPlayer::sliderChanged() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
151 qDebug() << "Slider moved. "; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
152 emit jumpToFrame(mSlider->value()); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
153 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
154 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
155 void PNGPlayer::sliderPressed() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
156 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
|
157 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
158 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
159 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
160 void PNGPlayer::sliderReleased() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
161 if (mPlayBtn->isChecked()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
162 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
163 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
164 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
165 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
166 void PNGPlayer::firstClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
167 emit jumpToFrame(0); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
168 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
169 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
170 void PNGPlayer::lastClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
171 emit jumpToFrame(mMax); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
172 } |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
173 |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
174 void PNGPlayer::speedChanged() { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
175 if (mSpeedSlider->value()) { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
176 setSpeed(mSpeedSlider->value() * REPLAY_SPEED_STEP_MS); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
177 } else { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
178 setSpeed(REPLAY_SPEED_STEP_MS / 2); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
179 } |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
180 QSettings settings; |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
181 settings.setValue(REPLAY_SPEED_KEY, mSpeedSlider->value()); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
182 } |