annotate src/pngplayer.cpp @ 38:26e1521b9afd

Add the possibility to detach the picture label on doubleclick
author Andre Heinecke <andre.heinecke@intevation.de>
date Wed, 06 May 2015 18:09:34 +0200
parents 0c05958d254c
children ee696abaab99
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);
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
90
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
91 speedArea->addWidget(mSpeedSlider);
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
92 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
93
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
94 mCurSpeedLabel = new QLabel;
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
95 speedArea->addWidget(mCurSpeedLabel);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
96 speedArea->addStretch(-1);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
97
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
98 mPositionLabel = new QLabel;
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
99 speedInfoArea->addWidget(mPositionLabel);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
100
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
101 controlArea->addLayout(speedInfoArea);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
102
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
103 baseLayout->addWidget(mPNGLabel);
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
104 baseLayout->addLayout(controlArea);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
105 baseLayout->addWidget(mSlider);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
106
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
107 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
108 setLayout(baseLayout);
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
109 }
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
110
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
111 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
112 const QDateTime& timestamp, int number) {
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
113 QPixmap pic(mBaseDir.filePath(fileName));
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
114 /* 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
115 * some intelligent preloading */
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
116 if (pic.isNull()) {
20
6b5e7d6bf4a2 Emit warning when a picture can not be loaded
Andre Heinecke <andre.heinecke@intevation.de>
parents: 10
diff changeset
117 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
118 // 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
119 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
120 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
121 } else {
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(pic);
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
123 }
37
0c05958d254c (issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents: 36
diff changeset
124 updatePositions(current, max, timestamp, number);
2
97d2c8869c39 First prototype implementation of table view and player
Andre Heinecke <andre.heinecke@intevation.de>
parents:
diff changeset
125 }
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
126
37
0c05958d254c (issue 13, 6) Add constant index number column to data and view
Andre Heinecke <andre.heinecke@intevation.de>
parents: 36
diff changeset
127 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
128 int number) {
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
129 mMax = max;
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
130 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
131 mSlider->setValue(current);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
132 mSlider->blockSignals(false);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
133 mSlider->setMaximum(max);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
134 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
135 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
136 "<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
137 tr("Timestamp:") + " </b>" + (timestamp.isValid() ?
ac4db84f1d9d Fix date format in player window
Andre Heinecke <andre.heinecke@intevation.de>
parents: 7
diff changeset
138 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
139
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
140 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
141 togglePlay();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
142 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
143 }
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 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
146 if (mSecsPerPicture == 1000) {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
147 mCurSpeedLabel->setText(tr("%1 second per Picture").
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
148 arg(mSecsPerPicture / 1000.));
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
149 } else {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
150 mCurSpeedLabel->setText(tr("%1 seconds per Picture").
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
151 arg(mSecsPerPicture / 1000.));
3
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
152 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
153 mAdvanceTimer.setInterval(mSecsPerPicture);
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
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
156 void PNGPlayer::togglePlay() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
157 if (mAdvanceTimer.isActive()) {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
158 mAdvanceTimer.stop();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
159 mPlayBtn->setChecked(false);
10
f290e8c4e097 Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8
diff changeset
160 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
161 } else {
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 mPlayBtn->setChecked(true);
10
f290e8c4e097 Add media icons to player widget
Andre Heinecke <andre.heinecke@intevation.de>
parents: 8
diff changeset
164 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
165 emit advance();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
166 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
167 }
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 void PNGPlayer::sliderChanged() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
170 qDebug() << "Slider moved. ";
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
171 emit jumpToFrame(mSlider->value());
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
172 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
173
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
174 void PNGPlayer::sliderPressed() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
175 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
176 mAdvanceTimer.stop();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
177 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
178
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
179 void PNGPlayer::sliderReleased() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
180 if (mPlayBtn->isChecked()) {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
181 mAdvanceTimer.start();
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
182 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
183 }
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 void PNGPlayer::firstClicked() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
186 emit jumpToFrame(0);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
187 }
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
188
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
189 void PNGPlayer::lastClicked() {
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
190 emit jumpToFrame(mMax);
248d5d1cdb38 Add functionalty to control buttons and make picture resizable
Andre Heinecke <andre.heinecke@intevation.de>
parents: 2
diff changeset
191 }
5
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
192
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
193 void PNGPlayer::speedChanged() {
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
194 if (mSpeedSlider->value()) {
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
195 setSpeed(mSpeedSlider->value() * REPLAY_SPEED_STEP_MS);
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
196 } else {
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
197 setSpeed(REPLAY_SPEED_STEP_MS / 2);
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
198 }
107e435cb569 Enable speed slider in pngplayer
Andre Heinecke <andre.heinecke@intevation.de>
parents: 3
diff changeset
199 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
200 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
201 }
38
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
202
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
203 void PNGPlayer::togglePicFullscreen() {
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
204 qDebug() << "togglePicFullscreen";
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
205 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
206 if (!baseLayout) {
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
207 qWarning() << "Wrong layout!";
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
208 return;
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
209 }
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
210 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
211 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
212 } else {
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
213 baseLayout->removeWidget(mPNGLabel);
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
214 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
215 mPNGLabel->showMaximized();
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
216 }
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
217 }
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 void PNGPlayer::close() {
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
220 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
221 if (!baseLayout) {
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
222 qWarning() << "Wrong layout!";
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
223 return;
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
224 }
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
225 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
226 delete mPNGLabel;
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
227 }
26e1521b9afd Add the possibility to detach the picture label on doubleclick
Andre Heinecke <andre.heinecke@intevation.de>
parents: 37
diff changeset
228 }
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)