]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/controller.hpp
Qt: Move code around and simplify the inclusion of headers.
[vlc] / modules / gui / qt4 / components / controller.hpp
1 /*****************************************************************************
2  * Controller.hpp : Controller for the main interface
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Clément Stenac <zorglub@videolan.org>
8  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *          Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
24  *****************************************************************************/
25
26 #ifndef _CONTROLLER_H_
27 #define _CONTROLLER_H_
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include "qt4.hpp"
34
35 #include <QFrame>
36 #include <QString>
37
38 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
39
40 class QPixmap;
41 class QLabel;
42
43 class QGridLayout;
44 class QHBoxLayout;
45 class QBoxLayout;
46
47 class QAbstractSlider;
48 class QAbstractButton;
49 class InputSlider;
50
51 class VolumeClickHandler;
52 class WidgetListing;
53
54 class QSignalMapper;
55 class QTimer;
56
57 typedef enum buttonType_e
58 {
59     PLAY_BUTTON,
60     STOP_BUTTON,
61     OPEN_BUTTON,
62     PREVIOUS_BUTTON,
63     NEXT_BUTTON,
64     SLOWER_BUTTON,
65     FASTER_BUTTON,
66     FULLSCREEN_BUTTON,
67     DEFULLSCREEN_BUTTON,
68     EXTENDED_BUTTON,
69     PLAYLIST_BUTTON,
70     SNAPSHOT_BUTTON,
71     RECORD_BUTTON,
72     ATOB_BUTTON,
73     FRAME_BUTTON,
74     REVERSE_BUTTON,
75     SKIP_BACK_BUTTON,
76     SKIP_FW_BUTTON,
77     BUTTON_MAX,
78
79     SPLITTER = 0x20,
80     INPUT_SLIDER,
81     VOLUME,
82     TIME_LABEL,
83     MENU_BUTTONS,
84     TELETEXT_BUTTONS,
85     ADVANCED_CONTROLLER,
86     SPECIAL_MAX,
87
88     WIDGET_SPACER = 0x40,
89     WIDGET_SPACER_EXTEND,
90     WIDGET_MAX,
91 } buttonType_e;
92
93
94 static const QString nameL[BUTTON_MAX] = { "Play", "Stop", "Open",
95     "Previous", "Next", "Slower", "Faster", "Fullscreen", "De-Fullscreen",
96     "Extended panel", "Playlist", "Snapshot", "Record", "A->B Loop",
97     "Frame By Frame", "Reverse", "Skip backward" , "Skip forward" };
98 static const QString tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
99     _("Stop playback"), _("Open a media"),
100     _("Previous media in the playlist"),
101     _("Next media in the playlist"), _("Slower"), _("Faster"),
102     _("Toggle the video in fullscreen"), _("Toggle the video out fullscreen"),
103     _("Show extended settings" ), _( "Show playlist" ), _( "Take a snapshot" ),
104     _( "Record" ), _( "Loop from point A to point B continuously." ),
105     _("Frame by frame"), _("Reverse"), _("Skip backward"), _("Skip forward") };
106 static const QString iconL[BUTTON_MAX] ={ ":/play_b", ":/stop_b", ":/eject",
107     ":/previous_b", ":/next_b", ":/slower", ":/faster", ":/fullscreen",
108     ":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
109     ":/atob_nob", ":/frame", ":/reverse", ":/skip_back", ":/skip_fw" };
110
111 typedef enum actionType_e
112 {
113     PLAY_ACTION,
114     STOP_ACTION,
115     OPEN_ACTION,
116     PREVIOUS_ACTION,
117     NEXT_ACTION,
118     SLOWER_ACTION,
119     FASTER_ACTION,
120     FULLSCREEN_ACTION,
121     EXTENDED_ACTION,
122     PLAYLIST_ACTION,
123     SNAPSHOT_ACTION,
124     RECORD_ACTION,
125     FRAME_ACTION,
126     ATOB_ACTION,
127     REVERSE_ACTION,
128     SKIP_BACK_ACTION,
129     SKIP_FW_ACTION,
130 } actionType_e;
131
132 enum
133 {
134    WIDGET_NORMAL = 0x0,
135    WIDGET_FLAT   = 0x1,
136    WIDGET_BIG    = 0x2,
137    WIDGET_SHINY  = 0x4,
138 };
139
140 class AdvControlsWidget;
141 class AbstractController : public QFrame
142 {
143     friend class WidgetListing; /* For ToolBar Edition HACKS */
144
145     Q_OBJECT
146 public:
147     AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
148
149 protected:
150     intf_thread_t       *p_intf;
151
152     QSignalMapper       *toolbarActionsMapper;
153     QHBoxLayout         *controlLayout;
154     /* Change to BoxLayout if both dir are needed */
155
156     AdvControlsWidget   *advControls;
157
158     void parseAndCreate( QString config, QBoxLayout *controlLayout );
159
160     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
161                                      buttonType_e i_type, int i_option );
162
163     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
164 private:
165     static void setupButton( QAbstractButton * );
166     QWidget *discFrame();
167     QWidget *telexFrame();
168
169 protected slots:
170     virtual void doAction( int );
171
172 protected slots:
173     void play();
174     void stop();
175     void prev();
176     void next();
177     void fullscreen();
178     void extSettings();
179     void faster();
180     void slower();
181     void reverse();
182     void playlist();
183     void snapshot();
184     void record();
185     void frame();
186
187     virtual void setStatus( int );
188
189 signals:
190     void inputExists( bool ); /// This might be usefull in the IM ?
191     void inputPlaying( bool ); /// This might be usefull in the IM ?
192     void inputIsRecordable( bool ); /// same ?
193 };
194
195 /* Advanced Button Bar */
196 class AdvControlsWidget : public AbstractController
197 {
198     Q_OBJECT
199 public:
200     AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
201 };
202
203 /* Slider Bar */
204 class InputControlsWidget : public AbstractController
205 {
206     Q_OBJECT
207 public:
208     InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
209 };
210
211 /* Button Bar */
212 class ControlsWidget : public AbstractController
213 {
214     Q_OBJECT
215 public:
216     /* p_intf, advanced control visible or not, blingbling or not */
217     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
218                     QWidget *_parent = 0 );
219     virtual ~ControlsWidget();
220
221 protected:
222     friend class MainInterface;
223
224     bool                 b_advancedVisible;
225
226 protected slots:
227     void toggleAdvanced();
228
229 signals:
230     void advancedControlsToggled( bool );
231 };
232
233 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
234    done by trick with setting the opacity of window */
235 #ifdef WIN32
236     #define WIN32TRICK
237 #endif
238
239 /* to trying transparency with fullscreen controller on windows enable that */
240 /* it can be enabled on-non windows systems,
241    but it will be transparent only with composite manager */
242 #ifndef WIN32
243     #define HAVE_TRANSPARENCY 1
244 #else
245     #define HAVE_TRANSPARENCY 0
246 #endif
247
248 /* Default value of opacity for FS controller */
249 #define DEFAULT_OPACITY 0.75
250
251 /***********************************
252  * Fullscreen controller
253  ***********************************/
254 class FullscreenControllerWidget : public AbstractController
255 {
256     Q_OBJECT
257 public:
258     FullscreenControllerWidget( intf_thread_t * );
259     virtual ~FullscreenControllerWidget();
260
261     /* Vout */
262     vout_thread_t *p_vout;
263     void attachVout( vout_thread_t *p_vout );
264     void detachVout();
265     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
266
267     int i_mouse_last_move_x;
268     int i_mouse_last_move_y;
269
270 protected:
271     friend class MainInterface;
272
273     virtual void mouseMoveEvent( QMouseEvent *event );
274     virtual void mousePressEvent( QMouseEvent *event );
275     virtual void enterEvent( QEvent *event );
276     virtual void leaveEvent( QEvent *event );
277     virtual void keyPressEvent( QKeyEvent *event );
278
279 private slots:
280     void showFSC();
281     void planHideFSC();
282     void hideFSC();
283     void slowHideFSC();
284
285 private:
286     virtual void customEvent( QEvent *event );
287
288     QTimer *p_hideTimer;
289 #if HAVE_TRANSPARENCY
290     QTimer *p_slowHideTimer;
291     bool b_slow_hide_begin;
292     int  i_slow_hide_timeout;
293 #endif
294
295     int i_mouse_last_x, i_mouse_last_y;
296     bool b_mouse_over;
297     int i_screennumber;
298
299 #ifdef WIN32TRICK
300     bool b_fscHidden;
301 #endif
302
303     /* Shared variable between FSC and VLC (protected by a lock) */
304     vlc_mutex_t lock;
305     bool        b_fullscreen;
306     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
307 };
308
309 #endif