1 /**
2  * Copyright (C) 2005 by Koos Vriezen <koos ! vriezen ? gmail ! com>
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License version 2 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Library General Public License
14  *  along with this library; see the file COPYING.LIB.  If not, write to
15  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
16  *  Boston, MA 02110-1301, USA.
17  **/
18 
19 #ifndef KMPLAYER_CONTROLPANEL_H
20 #define KMPLAYER_CONTROLPANEL_H
21 
22 #include "config-kmplayer.h"
23 
24 #include <qwidget.h>
25 #include <qmenu.h>
26 #include <qpushbutton.h>
27 
28 class QSlider;
29 //class QPushButton;
30 class QAction;
31 class QWidgetAction;
32 class QBoxLayout;
33 class QStringList;
34 
35 namespace KMPlayer {
36 
37 class View;
38 
39 /*
40  * A button from the controlpanel
41  */
42 class KMPLAYER_NO_EXPORT KMPlayerMenuButton : public QPushButton {
43     Q_OBJECT
44 public:
45     KMPlayerMenuButton (QWidget *, QBoxLayout *, const char **, int = 0);
~KMPlayerMenuButton()46     KDE_NO_CDTOR_EXPORT ~KMPlayerMenuButton () {}
47 signals:
48     void mouseEntered ();
49 protected:
50     void enterEvent (QEvent *);
51 };
52 
53 /*
54  * The pop down menu from the controlpanel
55  */
56 class KMPLAYER_EXPORT KMPlayerPopupMenu : public QMenu {
57     Q_OBJECT
58 public:
59     KMPlayerPopupMenu(QWidget*, const QString& title) KDE_NO_CDTOR_EXPORT;
~KMPlayerPopupMenu()60     KDE_NO_CDTOR_EXPORT ~KMPlayerPopupMenu () {}
61 signals:
62     void mouseLeft ();
63 protected:
64     void leaveEvent(QEvent*) KDE_NO_EXPORT;
65 };
66 
67 /*
68  * The volume bar from the controlpanel
69  */
70 class KMPLAYER_EXPORT VolumeBar : public QWidget {
71     Q_OBJECT
72 public:
73     VolumeBar(QWidget* parent, View* view) KDE_NO_CDTOR_EXPORT;
74     ~VolumeBar() KDE_NO_CDTOR_EXPORT;
value()75     KDE_NO_EXPORT int value () const { return m_value; }
76     void setValue (int v);
77 signals:
78     void volumeChanged (int); // 0 - 100
79 protected:
80     void wheelEvent(QWheelEvent* e) KDE_NO_EXPORT;
81     void paintEvent(QPaintEvent*) KDE_NO_EXPORT;
82     void mousePressEvent(QMouseEvent* e) KDE_NO_EXPORT;
83     void mouseMoveEvent(QMouseEvent* e) KDE_NO_EXPORT;
84 private:
85     View * m_view;
86     int m_value;
87 };
88 
89 /*
90  * The controlpanel GUI
91  */
92 class KMPLAYER_EXPORT ControlPanel : public QWidget {
93     Q_OBJECT
94 public:
95     enum Button {
96         button_config = 0, button_playlist,
97         button_back, button_play, button_forward,
98         button_stop, button_pause, button_record,
99         button_broadcast, button_language,
100         button_red, button_green, button_yellow, button_blue,
101         button_last
102     };
103     ControlPanel(QWidget* parent, View* view) KDE_NO_CDTOR_EXPORT;
~ControlPanel()104     KDE_NO_CDTOR_EXPORT ~ControlPanel () {}
105     void showPositionSlider (bool show);
106     void enableSeekButtons (bool enable);
107     void enableRecordButtons (bool enable);
108     void enableFullscreenButton(bool enable);
109     void setPlaying (bool play);
110     void setRecording (bool record) KDE_NO_EXPORT;
111     void setAutoControls (bool b);
112     void setPalette (const QPalette &) KDE_NO_EXPORT;
113     int preferredHeight () KDE_NO_EXPORT;
autoControls()114     KDE_NO_EXPORT bool autoControls () const { return m_auto_controls; }
positionSlider()115     KDE_NO_EXPORT QSlider * positionSlider () const { return m_posSlider; }
contrastSlider()116     KDE_NO_EXPORT QSlider * contrastSlider () const { return m_contrastSlider; }
brightnessSlider()117     KDE_NO_EXPORT QSlider * brightnessSlider () const { return m_brightnessSlider; }
hueSlider()118     KDE_NO_EXPORT QSlider * hueSlider () const { return m_hueSlider; }
saturationSlider()119     KDE_NO_EXPORT QSlider * saturationSlider () const { return m_saturationSlider; }
button(Button b)120     QPushButton * button (Button b) const { return m_buttons [(int) b]; }
broadcastButton()121     KDE_NO_EXPORT QPushButton * broadcastButton () const { return m_buttons[button_broadcast]; }
volumeBar()122     KDE_NO_EXPORT VolumeBar * volumeBar () const { return m_volume; }
view()123     KDE_NO_EXPORT View * view () const { return m_view; }
124     QAction *playersAction;
125     QAction *videoConsoleAction;
126     QAction *playlistAction;
127     QAction *zoomAction;
128     QAction *zoom50Action;
129     QAction *zoom100Action;
130     QAction *zoom150Action;
131     QAction *fullscreenAction;
132     QAction *colorAction;
133     QAction *configureAction;
134     QAction *bookmarkAction;
135     QAction *languageAction;
136     QWidgetAction *scaleLabelAction;
137     QWidgetAction *scaleAction;
138     QSlider *scale_slider;
139     KMPlayerPopupMenu *popupMenu;
140     KMPlayerPopupMenu *bookmarkMenu;
141     KMPlayerPopupMenu *zoomMenu;
142     KMPlayerPopupMenu *playerMenu;
143     KMPlayerPopupMenu *colorMenu;
144     KMPlayerPopupMenu *languageMenu;
145     KMPlayerPopupMenu *audioMenu;
146     KMPlayerPopupMenu *subtitleMenu;
147 public slots:
148     void setLanguages(const QStringList& al, const QStringList& sl) KDE_NO_EXPORT;
149     void actionToggled(QAction*) KDE_NO_EXPORT;
150     void showPopupMenu() KDE_NO_EXPORT;
151     void showLanguageMenu() KDE_NO_EXPORT;
152     void setPlayingProgress(int position, int length) KDE_NO_EXPORT;
153     void setLoadingProgress(int pos) KDE_NO_EXPORT;
154 protected:
155     void timerEvent(QTimerEvent* e) KDE_NO_EXPORT;
156     void setupPositionSlider(bool show) KDE_NO_EXPORT;
157 private slots:
158     void buttonMouseEntered() KDE_NO_EXPORT;
159     void buttonClicked() KDE_NO_EXPORT;
160     void menuMouseLeft() KDE_NO_EXPORT;
161 private:
162     enum { progress_loading, progress_playing } m_progress_mode;
163     int m_progress_length;
164     int m_popup_timer;
165     int m_popdown_timer;
166     int m_button_monitored;
167     View * m_view;
168     QBoxLayout * m_buttonbox;
169     QSlider * m_posSlider;
170     QSlider * m_contrastSlider;
171     QSlider * m_brightnessSlider;
172     QSlider * m_hueSlider;
173     QSlider * m_saturationSlider;
174     QPushButton * m_buttons [button_last];
175     VolumeBar * m_volume;
176     bool m_auto_controls; // depending on source caps
177     bool m_popup_clicked;
178 };
179 
180 }
181 
182 #endif // KMPLAYER_CONTROLPANEL_H
183