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