1 /*
2     SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com>
3     SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com>
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #ifndef KTVIDEOWIDGET_H
8 #define KTVIDEOWIDGET_H
9 
10 #include <Phonon/MediaObject>
11 #include <Phonon/SeekSlider>
12 #include <Phonon/VideoWidget>
13 #include <Phonon/VolumeSlider>
14 #include <QAction>
15 #include <QWidget>
16 
17 class QAction;
18 class QLabel;
19 class KToolBar;
20 class KActionCollection;
21 
22 namespace kt
23 {
24 class VideoChunkBar;
25 class MediaPlayer;
26 class MediaFileRef;
27 
28 /**
29  * Widget to display a video
30  * @author Joris Guisson
31  */
32 class VideoWidget : public QWidget
33 {
34     Q_OBJECT
35 public:
36     VideoWidget(MediaPlayer *player, KActionCollection *ac, QWidget *parent);
37     ~VideoWidget() override;
38 
39     /**
40      * Make the widget full screen or not.
41      * @param on
42      */
43     void setFullScreen(bool on);
44 
45 protected:
46     void mouseMoveEvent(QMouseEvent *event) override;
47     bool eventFilter(QObject *dst, QEvent *event) override;
48 
49 private Q_SLOTS:
50     void play();
51     void stop();
52     void setControlsVisible(bool on);
53     void timerTick(qint64 time);
54     void playing(const MediaFileRef &mfile);
55     void enableActions(unsigned int flags);
56 
57 Q_SIGNALS:
58     void toggleFullScreen(bool on);
59 
60 private:
61     void inhibitScreenSaver(bool on);
62     QString formatTime(qint64 cur, qint64 total);
63 
64 private:
65     Phonon::VideoWidget *video;
66     MediaPlayer *player;
67     Phonon::SeekSlider *slider;
68     KToolBar *tb;
69     QAction *play_action;
70     QAction *stop_action;
71     QLabel *time_label;
72     Phonon::VolumeSlider *volume;
73     VideoChunkBar *chunk_bar;
74     bool fullscreen;
75     quint32 screensaver_cookie;
76     quint32 powermanagement_cookie;
77 };
78 
79 }
80 
81 #endif
82