]> cloud.milkyroute.net Git - dolphin.git/blob - src/panels/information/phononwidget.h
Allow dolphin to auto-play previewed media file, click on preview to play/pause video...
[dolphin.git] / src / panels / information / phononwidget.h
1 /* This file is part of the KDE project
2 Copyright (C) 2007 Matthias Kretz <kretz@kde.org>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of
7 the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 02110-1301, USA.
18
19 */
20
21 #ifndef PHONONWIDGET_H
22 #define PHONONWIDGET_H
23
24 #include <Phonon/Global>
25
26 #include <QSize>
27 #include <QUrl>
28 #include <QWidget>
29
30 namespace Phonon
31 {
32 class AudioOutput;
33 class MediaObject;
34 class SeekSlider;
35 class VideoPlayer;
36 } // namespace Phonon
37
38 class EmbeddedVideoPlayer;
39 class QToolButton;
40 class QVBoxLayout;
41
42 class PhononWidget : public QWidget
43 {
44 Q_OBJECT
45 public:
46
47 enum MediaKind {
48 Video,
49 Audio
50 };
51
52 explicit PhononWidget(QWidget *parent = nullptr);
53
54 void setUrl(const QUrl &url, MediaKind kind);
55 QUrl url() const;
56
57 void setVideoSize(const QSize& size);
58 QSize videoSize() const;
59
60 void setAutoPlay(bool autoPlay);
61
62 signals:
63 /**
64 * Is emitted whenever the video-state
65 * has changed: If true is returned, a video
66 * including control-buttons will be shown.
67 * If false is returned, no video is shown
68 * and the control-buttons are available for
69 * audio only.
70 */
71 void hasVideoChanged(bool hasVideo);
72
73 public slots:
74 void play();
75
76 protected:
77 void showEvent(QShowEvent *event) override;
78 void hideEvent(QHideEvent *event) override;
79
80 private slots:
81 void stateChanged(Phonon::State newstate);
82 void stop();
83 void finished();
84
85 private:
86 void applyVideoSize();
87
88 private:
89 QUrl m_url;
90 QSize m_videoSize;
91
92 QToolButton *m_playButton;
93 QToolButton *m_stopButton;
94
95 QVBoxLayout *m_topLayout;
96 Phonon::MediaObject *m_media;
97 Phonon::SeekSlider *m_seekSlider;
98 Phonon::AudioOutput *m_audioOutput;
99 EmbeddedVideoPlayer *m_videoPlayer;
100 bool m_autoPlay;
101 bool m_isVideo;
102 };
103
104 #endif // PHONONWIDGET_H