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