]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/controller.hpp
UI: prefix/namespace resources for better maintainability
[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 class QToolButton;
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 char* nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
102     N_("Previous"), N_("Next"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
103    N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
104    N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
105    N_("Step backward" ), N_("Step forward"), N_("Quit") };
106 static const char* tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
107     N_("Stop playback"), N_("Open a medium"),
108     N_("Previous media in the playlist"),
109     N_("Next media in the playlist"), N_("Slower"), N_("Faster"),
110     N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
111     N_("Show extended settings" ), N_( "Show playlist" ),
112     N_( "Take a snapshot" ), N_( "Record" ),
113     N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
114     N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit") };
115 static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
116     ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
117     ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
118     ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
119     ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
120     ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
121     ":/toolbar/skip_fw", ":/toolbar/clear" };
122
123 enum
124 {
125    WIDGET_NORMAL = 0x0,
126    WIDGET_FLAT   = 0x1,
127    WIDGET_BIG    = 0x2,
128    WIDGET_SHINY  = 0x4,
129 };
130
131 class AdvControlsWidget;
132 class AbstractController : public QFrame
133 {
134     friend class WidgetListing; /* For ToolBar Edition HACKS */
135
136     Q_OBJECT
137 public:
138     AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
139
140 protected:
141     intf_thread_t       *p_intf;
142
143     QSignalMapper       *toolbarActionsMapper;
144     QHBoxLayout         *controlLayout;
145     /* Change to BoxLayout if both dir are needed */
146
147     AdvControlsWidget   *advControls;
148
149     void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
150
151     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
152                                      buttonType_e i_type, int i_option );
153
154     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
155 private:
156     static void setupButton( QAbstractButton * );
157     QFrame *discFrame();
158     QFrame *telexFrame();
159     void applyAttributes( QToolButton *, bool b_flat, bool b_big );
160 protected slots:
161     virtual void setStatus( int );
162
163 signals:
164     void inputExists( bool ); /// This might be usefull in the IM ?
165     void inputPlaying( bool ); /// This might be usefull in the IM ?
166     void inputIsRecordable( bool ); /// same ?
167     void inputIsTrickPlayable( bool ); /// same ?
168     void sizeChanged();
169 };
170
171 /* Advanced Button Bar */
172 class AdvControlsWidget : public AbstractController
173 {
174     Q_OBJECT
175 public:
176     AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
177 };
178
179 /* Slider Bar */
180 class InputControlsWidget : public AbstractController
181 {
182     Q_OBJECT
183 public:
184     InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
185 };
186
187 /* Button Bar */
188 class ControlsWidget : public AbstractController
189 {
190     Q_OBJECT
191 public:
192     /* p_intf, advanced control visible or not, blingbling or not */
193     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
194                     QWidget *_parent = 0 );
195     virtual ~ControlsWidget();
196
197 protected:
198     friend class MainInterface;
199
200     bool                 b_advancedVisible;
201
202 protected slots:
203     void toggleAdvanced();
204
205 signals:
206     void advancedControlsToggled( bool );
207 };
208
209 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
210    done by trick with setting the opacity of window */
211 #ifdef WIN32
212     #define WIN32TRICK
213 #endif
214
215 /* to trying transparency with fullscreen controller on windows enable that */
216 /* it can be enabled on-non windows systems,
217    but it will be transparent only with composite manager */
218 #ifndef WIN32
219     #define HAVE_TRANSPARENCY 1
220 #else
221     #define HAVE_TRANSPARENCY 0
222 #endif
223
224 /* Default value of opacity for FS controller */
225 #define DEFAULT_OPACITY 0.75
226
227 /***********************************
228  * Fullscreen controller
229  ***********************************/
230 class FullscreenControllerWidget : public AbstractController
231 {
232     Q_OBJECT
233 public:
234     FullscreenControllerWidget( intf_thread_t * );
235     virtual ~FullscreenControllerWidget();
236
237     /* Vout */
238     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
239     void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
240
241 public slots:
242     void setVoutList( vout_thread_t **, int );
243
244 protected:
245     friend class MainInterface;
246
247     virtual void mouseMoveEvent( QMouseEvent *event );
248     virtual void mousePressEvent( QMouseEvent *event );
249     virtual void mouseReleaseEvent( QMouseEvent *event );
250     virtual void enterEvent( QEvent *event );
251     virtual void leaveEvent( QEvent *event );
252     virtual void keyPressEvent( QKeyEvent *event );
253
254 private slots:
255     void showFSC();
256     void planHideFSC();
257     void hideFSC();
258     void slowHideFSC();
259     void centerFSC( int );
260
261 private:
262     virtual void customEvent( QEvent *event );
263
264     QTimer *p_hideTimer;
265 #if HAVE_TRANSPARENCY
266     QTimer *p_slowHideTimer;
267     bool b_slow_hide_begin;
268     int  i_slow_hide_timeout;
269 #endif
270
271     int i_mouse_last_x, i_mouse_last_y;
272     bool b_mouse_over;
273     int i_screennumber;
274     QRect screenRes;
275
276 #ifdef WIN32TRICK
277     bool b_fscHidden;
278 #endif
279
280     /* List of vouts currently tracked */
281     QList<vout_thread_t *> vout;
282
283     /* Shared variable between FSC and VLC (protected by a lock) */
284     vlc_mutex_t lock;
285     bool        b_fullscreen;
286     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
287     int i_mouse_last_move_x;
288     int i_mouse_last_move_y;
289 };
290
291 #endif