Mercurial > retraceit
annotate src/pngplayer.cpp @ 43:ee696abaab99
(issue16) Fix speed slider jumpiness
The default steps were far too large which made the slider
jumpy on click.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 06 May 2015 18:20:13 +0200 |
parents | 26e1521b9afd |
children | 73e6b6b12412 |
rev | line source |
---|---|
25
64a51a42c01f
Assign copyright correctly
Andre Heinecke <andre.heinecke@intevation.de>
parents:
20
diff
changeset
|
1 /* Copyright (C) 2015 by ETH Zürich |
64a51a42c01f
Assign copyright correctly
Andre Heinecke <andre.heinecke@intevation.de>
parents:
20
diff
changeset
|
2 * Software engineering by Intevation GmbH |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
3 * |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
4 * 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
|
5 * and comes with ABSOLUTELY NO WARRANTY! |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
6 * See LICENSE.txt for details. |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
7 */ |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
8 #include "pngplayer.h" |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
9 #include "constants.h" |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
10 #include "imagelabel.h" |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
11 #include <QVBoxLayout> |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
12 #include <QPixmap> |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
13 #include <QLabel> |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
14 #include <QPushButton> |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
15 #include <QHBoxLayout> |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
16 #include <QSlider> |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
17 #include <QSettings> |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
18 #include <QApplication> |
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
19 #include <QStyle> |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
20 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
21 #include <QDebug> |
2
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 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
|
24 setupGUI(); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
25 QSettings settings; |
34
40a683d1a318
(issue15) Change picture speed setting to seconds and default to 1s
Andre Heinecke <andre.heinecke@intevation.de>
parents:
25
diff
changeset
|
26 double settingsSecs = settings.value(REPLAY_SPEED_KEY, REPLAY_SPEED_DEFAULT).toDouble(); |
40a683d1a318
(issue15) Change picture speed setting to seconds and default to 1s
Andre Heinecke <andre.heinecke@intevation.de>
parents:
25
diff
changeset
|
27 if (settingsSecs != 0) { |
40a683d1a318
(issue15) Change picture speed setting to seconds and default to 1s
Andre Heinecke <andre.heinecke@intevation.de>
parents:
25
diff
changeset
|
28 mSpeedSlider->setValue(settingsSecs * 1000 / REPLAY_SPEED_STEP_MS); |
40a683d1a318
(issue15) Change picture speed setting to seconds and default to 1s
Andre Heinecke <andre.heinecke@intevation.de>
parents:
25
diff
changeset
|
29 } |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
30 speedChanged(); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
31 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
32 |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
33 void PNGPlayer::setupGUI() { |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
34 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
|
35 mPNGLabel = new ImageLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
36 mPNGLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
38
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
37 connect(mPNGLabel, &ImageLabel::doubleClicked, this, &PNGPlayer::togglePicFullscreen); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
38 connect(mPNGLabel, &ImageLabel::closeRequested, this, &PNGPlayer::togglePicFullscreen); |
3
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 QHBoxLayout *controlArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
41 QHBoxLayout *controlBtns = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
42 controlArea->addLayout(controlBtns); |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
43 controlArea->addStretch(-1); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
44 |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
45 QPushButton *firstBtn = new QPushButton; |
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
46 firstBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
47 controlBtns->addWidget(firstBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
48 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
|
49 |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
50 QPushButton *prevBtn = new QPushButton; |
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
51 prevBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
52 controlBtns->addWidget(prevBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
53 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
|
54 |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
55 mPlayBtn = new QPushButton; |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
56 mPlayBtn->setCheckable(true); |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
57 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
58 controlBtns->addWidget(mPlayBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
59 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
|
60 |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
61 QPushButton *nextBtn = new QPushButton; |
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
62 nextBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
63 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
|
64 controlBtns->addWidget(nextBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
65 |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
66 QPushButton *lastBtn = new QPushButton; |
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
67 lastBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
68 controlBtns->addWidget(lastBtn); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
69 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
|
70 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
71 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
|
72 mSlider->setTickPosition(QSlider::TicksBelow); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
77 QVBoxLayout *speedInfoArea = new QVBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
78 QHBoxLayout *speedArea = new QHBoxLayout; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
79 speedInfoArea->addLayout(speedArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
80 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
81 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
|
82 speedArea->addWidget(speedLabel); |
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 mSpeedSlider = new QSlider(Qt::Horizontal); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
85 mSpeedSlider->setMaximum(10); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
86 mSpeedSlider->setTickInterval(1); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
87 mSpeedSlider->setTickPosition(QSlider::TicksBelow); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
88 mSpeedSlider->setTracking(false); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
89 mSpeedSlider->setInvertedAppearance(true); |
43
ee696abaab99
(issue16) Fix speed slider jumpiness
Andre Heinecke <andre.heinecke@intevation.de>
parents:
38
diff
changeset
|
90 mSpeedSlider->setSingleStep(1); |
ee696abaab99
(issue16) Fix speed slider jumpiness
Andre Heinecke <andre.heinecke@intevation.de>
parents:
38
diff
changeset
|
91 mSpeedSlider->setPageStep(1); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
92 |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
93 speedArea->addWidget(mSpeedSlider); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
94 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
|
95 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
96 mCurSpeedLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
97 speedArea->addWidget(mCurSpeedLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
98 speedArea->addStretch(-1); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
99 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
100 mPositionLabel = new QLabel; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
101 speedInfoArea->addWidget(mPositionLabel); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
102 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
103 controlArea->addLayout(speedInfoArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
104 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
105 baseLayout->addWidget(mPNGLabel); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
106 baseLayout->addLayout(controlArea); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
107 baseLayout->addWidget(mSlider); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
108 |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
109 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
|
110 setLayout(baseLayout); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
111 } |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
112 |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
113 void PNGPlayer::showPicture(const QString& fileName, int current, int max, |
37
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
114 const QDateTime& timestamp, int number) { |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
115 QPixmap pic(mBaseDir.filePath(fileName)); |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
116 /* 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
|
117 * some intelligent preloading */ |
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
118 if (pic.isNull()) { |
20
6b5e7d6bf4a2
Emit warning when a picture can not be loaded
Andre Heinecke <andre.heinecke@intevation.de>
parents:
10
diff
changeset
|
119 qWarning() << "Failed to load picture: " << fileName; |
7
c11fe56aa4a2
Disable error if an image cannot be loaded
Andre Heinecke <andre.heinecke@intevation.de>
parents:
5
diff
changeset
|
120 // emit error(tr("Failed to load picture: '%1'").arg(fileName)); |
37
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
121 QIcon errIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); |
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
122 mPNGLabel->setPixmap(errIcon.pixmap(QSize(128, 128))); |
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
123 } else { |
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
124 mPNGLabel->setPixmap(pic); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
125 } |
37
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
126 updatePositions(current, max, timestamp, number); |
2
97d2c8869c39
First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff
changeset
|
127 } |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
128 |
37
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
129 void PNGPlayer::updatePositions(int current, int max, const QDateTime& timestamp, |
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
130 int number) { |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
131 mMax = max; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
132 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
|
133 mSlider->setValue(current); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
134 mSlider->blockSignals(false); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
135 mSlider->setMaximum(max); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
136 mPositionLabel->setText("<b>" + tr("Screenshot Nr.:") + " </b>" + |
37
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
137 QString("%1 (%2)").arg(current + 1).arg(max + 1) + |
0c05958d254c
(issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents:
36
diff
changeset
|
138 "<b> " + tr("Index Nr.:") + " </b>" + QString::number(number) + " / <b>" + |
8
ac4db84f1d9d
Fix date format in player window
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7
diff
changeset
|
139 tr("Timestamp:") + " </b>" + (timestamp.isValid() ? |
ac4db84f1d9d
Fix date format in player window
Andre Heinecke <andre.heinecke@intevation.de>
parents:
7
diff
changeset
|
140 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
|
141 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
142 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
|
143 togglePlay(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
144 } |
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::setSpeed(int mSecsPerPicture) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
148 if (mSecsPerPicture == 1000) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
149 mCurSpeedLabel->setText(tr("%1 second per Picture"). |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
150 arg(mSecsPerPicture / 1000.)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
151 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
152 mCurSpeedLabel->setText(tr("%1 seconds per Picture"). |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
153 arg(mSecsPerPicture / 1000.)); |
3
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 mAdvanceTimer.setInterval(mSecsPerPicture); |
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::togglePlay() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
159 if (mAdvanceTimer.isActive()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
160 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
161 mPlayBtn->setChecked(false); |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
162 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
163 } else { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
164 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
165 mPlayBtn->setChecked(true); |
10
f290e8c4e097
Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents:
8
diff
changeset
|
166 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPause)); |
3
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
167 emit advance(); |
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 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
171 void PNGPlayer::sliderChanged() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
172 qDebug() << "Slider moved. "; |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
173 emit jumpToFrame(mSlider->value()); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
174 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
175 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
176 void PNGPlayer::sliderPressed() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
177 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
|
178 mAdvanceTimer.stop(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
179 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
180 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
181 void PNGPlayer::sliderReleased() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
182 if (mPlayBtn->isChecked()) { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
183 mAdvanceTimer.start(); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
184 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
185 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
186 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
187 void PNGPlayer::firstClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
188 emit jumpToFrame(0); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
189 } |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
190 |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
191 void PNGPlayer::lastClicked() { |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
192 emit jumpToFrame(mMax); |
248d5d1cdb38
Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents:
2
diff
changeset
|
193 } |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
194 |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
195 void PNGPlayer::speedChanged() { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
196 if (mSpeedSlider->value()) { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
197 setSpeed(mSpeedSlider->value() * REPLAY_SPEED_STEP_MS); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
198 } else { |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
199 setSpeed(REPLAY_SPEED_STEP_MS / 2); |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
200 } |
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
201 QSettings settings; |
34
40a683d1a318
(issue15) Change picture speed setting to seconds and default to 1s
Andre Heinecke <andre.heinecke@intevation.de>
parents:
25
diff
changeset
|
202 settings.setValue(REPLAY_SPEED_KEY, (mSpeedSlider->value() * REPLAY_SPEED_STEP_MS) / 1000.0); |
5
107e435cb569
Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents:
3
diff
changeset
|
203 } |
38
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
204 |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
205 void PNGPlayer::togglePicFullscreen() { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
206 qDebug() << "togglePicFullscreen"; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
207 QVBoxLayout *baseLayout = qobject_cast<QVBoxLayout*>(layout()); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
208 if (!baseLayout) { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
209 qWarning() << "Wrong layout!"; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
210 return; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
211 } |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
212 if (baseLayout->indexOf(mPNGLabel) == -1) { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
213 baseLayout->insertWidget(0, mPNGLabel); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
214 } else { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
215 baseLayout->removeWidget(mPNGLabel); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
216 mPNGLabel->setParent(NULL, Qt::Tool); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
217 mPNGLabel->showMaximized(); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
218 } |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
219 } |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
220 |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
221 void PNGPlayer::close() { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
222 QVBoxLayout *baseLayout = qobject_cast<QVBoxLayout*>(layout()); |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
223 if (!baseLayout) { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
224 qWarning() << "Wrong layout!"; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
225 return; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
226 } |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
227 if (baseLayout->indexOf(mPNGLabel) == -1) { |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
228 delete mPNGLabel; |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
229 } |
26e1521b9afd
Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents:
37
diff
changeset
|
230 } |