comparison src/pngplayer.cpp @ 10:f290e8c4e097

Add media icons to player widget
author Andre Heinecke <andre.heinecke@intevation.de>
date Thu, 26 Mar 2015 16:41:08 +0100
parents ac4db84f1d9d
children 6b5e7d6bf4a2
comparison
equal deleted inserted replaced
9:e3c8f61e45a9 10:f290e8c4e097
12 #include <QLabel> 12 #include <QLabel>
13 #include <QPushButton> 13 #include <QPushButton>
14 #include <QHBoxLayout> 14 #include <QHBoxLayout>
15 #include <QSlider> 15 #include <QSlider>
16 #include <QSettings> 16 #include <QSettings>
17 #include <QApplication>
18 #include <QStyle>
17 19
18 #include <QDebug> 20 #include <QDebug>
19 21
20 PNGPlayer::PNGPlayer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { 22 PNGPlayer::PNGPlayer(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) {
21 setupGUI(); 23 setupGUI();
30 mPNGLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); 32 mPNGLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
31 33
32 QHBoxLayout *controlArea = new QHBoxLayout; 34 QHBoxLayout *controlArea = new QHBoxLayout;
33 QHBoxLayout *controlBtns = new QHBoxLayout; 35 QHBoxLayout *controlBtns = new QHBoxLayout;
34 controlArea->addLayout(controlBtns); 36 controlArea->addLayout(controlBtns);
37 controlArea->addStretch(-1);
35 38
36 QPushButton *firstBtn = new QPushButton("First"); 39 QPushButton *firstBtn = new QPushButton;
40 firstBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipBackward));
37 controlBtns->addWidget(firstBtn); 41 controlBtns->addWidget(firstBtn);
38 connect(firstBtn, &QPushButton::clicked, this, &PNGPlayer::firstClicked); 42 connect(firstBtn, &QPushButton::clicked, this, &PNGPlayer::firstClicked);
39 43
40 QPushButton *prevBtn = new QPushButton("Prev"); 44 QPushButton *prevBtn = new QPushButton;
45 prevBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekBackward));
41 controlBtns->addWidget(prevBtn); 46 controlBtns->addWidget(prevBtn);
42 connect(prevBtn, &QPushButton::clicked, this, &PNGPlayer::back); 47 connect(prevBtn, &QPushButton::clicked, this, &PNGPlayer::back);
43 48
44 mPlayBtn = new QPushButton("Play"); 49 mPlayBtn = new QPushButton;
45 mPlayBtn->setCheckable(true); 50 mPlayBtn->setCheckable(true);
51 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
46 controlBtns->addWidget(mPlayBtn); 52 controlBtns->addWidget(mPlayBtn);
47 connect(mPlayBtn, &QPushButton::clicked, this, &PNGPlayer::togglePlay); 53 connect(mPlayBtn, &QPushButton::clicked, this, &PNGPlayer::togglePlay);
48 54
49 QPushButton *nextBtn = new QPushButton("Next"); 55 QPushButton *nextBtn = new QPushButton;
56 nextBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSeekForward));
50 connect(nextBtn, &QPushButton::clicked, this, &PNGPlayer::advance); 57 connect(nextBtn, &QPushButton::clicked, this, &PNGPlayer::advance);
51 controlBtns->addWidget(nextBtn); 58 controlBtns->addWidget(nextBtn);
52 59
53 QPushButton *lastBtn = new QPushButton("Last"); 60 QPushButton *lastBtn = new QPushButton;
61 lastBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaSkipForward));
54 controlBtns->addWidget(lastBtn); 62 controlBtns->addWidget(lastBtn);
55 connect(lastBtn, &QPushButton::clicked, this, &PNGPlayer::lastClicked); 63 connect(lastBtn, &QPushButton::clicked, this, &PNGPlayer::lastClicked);
56 64
57 mSlider = new QSlider(Qt::Horizontal); 65 mSlider = new QSlider(Qt::Horizontal);
58 mSlider->setTickPosition(QSlider::TicksBelow); 66 mSlider->setTickPosition(QSlider::TicksBelow);
135 } 143 }
136 144
137 void PNGPlayer::togglePlay() { 145 void PNGPlayer::togglePlay() {
138 if (mAdvanceTimer.isActive()) { 146 if (mAdvanceTimer.isActive()) {
139 mAdvanceTimer.stop(); 147 mAdvanceTimer.stop();
140 mPlayBtn->setText("Play");
141 mPlayBtn->setChecked(false); 148 mPlayBtn->setChecked(false);
149 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPlay));
142 } else { 150 } else {
143 mAdvanceTimer.start(); 151 mAdvanceTimer.start();
144 mPlayBtn->setText("Pause");
145 mPlayBtn->setChecked(true); 152 mPlayBtn->setChecked(true);
153 mPlayBtn->setIcon(QApplication::style()->standardIcon(QStyle::SP_MediaPause));
146 emit advance(); 154 emit advance();
147 } 155 }
148 } 156 }
149 157
150 void PNGPlayer::sliderChanged() { 158 void PNGPlayer::sliderChanged() {
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)