]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/controller.hpp
Qt: StandardPanel: Add spinner on network SD nodes.
[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 #include <QSizeGrip>
36
37 #define MAIN_TB1_DEFAULT "64;39;64;38;65"
38 #define MAIN_TB2_DEFAULT "0-2;64;3;1;4;64;7;9;64;10;20;19;64-4;37;65;35-4"
39 #define ADV_TB_DEFAULT "12;11;13;14"
40 #define INPT_TB_DEFAULT "43;33-4;44"
41 #define FSC_TB_DEFAULT "0-2;64;3;1;4;64;37;64;38;64;8;65;25;35-4;34"
42
43 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
44
45 class QPixmap;
46 class QLabel;
47
48 class QGridLayout;
49 class QBoxLayout;
50 class QHBoxLayout;
51 class QVBoxLayout;
52
53 class QAbstractSlider;
54 class QAbstractButton;
55 class SeekSlider;
56 class QToolButton;
57
58 class VolumeClickHandler;
59 class WidgetListing;
60
61 class QSignalMapper;
62 class QTimer;
63
64 typedef enum buttonType_e
65 {
66     PLAY_BUTTON,
67     STOP_BUTTON,
68     OPEN_BUTTON,
69     PREV_SLOW_BUTTON,
70     NEXT_FAST_BUTTON,
71     SLOWER_BUTTON,
72     FASTER_BUTTON,
73     FULLSCREEN_BUTTON,
74     DEFULLSCREEN_BUTTON,
75     EXTENDED_BUTTON,
76     PLAYLIST_BUTTON,
77     SNAPSHOT_BUTTON,
78     RECORD_BUTTON,
79     ATOB_BUTTON,
80     FRAME_BUTTON,
81     REVERSE_BUTTON,
82     SKIP_BACK_BUTTON,
83     SKIP_FW_BUTTON,
84     QUIT_BUTTON,
85     RANDOM_BUTTON,
86     LOOP_BUTTON,
87     INFO_BUTTON,
88     PREVIOUS_BUTTON,
89     NEXT_BUTTON,
90     OPEN_SUB_BUTTON,
91     FULLWIDTH_BUTTON,
92     BUTTON_MAX,
93
94     SPLITTER = 0x20,
95     INPUT_SLIDER,
96     TIME_LABEL,
97     VOLUME,
98     VOLUME_SPECIAL,
99     MENU_BUTTONS,
100     TELETEXT_BUTTONS,
101     ADVANCED_CONTROLLER,
102     PLAYBACK_BUTTONS,
103     ASPECT_RATIO_COMBOBOX,
104     SPEED_LABEL,
105     TIME_LABEL_ELAPSED,
106     TIME_LABEL_REMAINING,
107     SPECIAL_MAX,
108
109     WIDGET_SPACER = 0x40,
110     WIDGET_SPACER_EXTEND,
111     WIDGET_MAX,
112 } buttonType_e;
113
114
115 static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
116     N_("Previous / Backward"), N_("Next / Forward"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
117     N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
118     N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
119     N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random"),
120     N_("Loop / Repeat"), N_("Information"), N_("Previous"), N_("Next"),
121     N_("Open subtitles"), N_("Dock fullscreen controller")
122 };
123 static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
124     N_("Stop playback"), N_("Open a medium"),
125     N_("Previous media in the playlist, skip backward when keep-pressed"),
126     N_("Next media in the playlist, skip forward when keep-pressed"), N_("Slower"), N_("Faster"),
127     N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
128     N_("Show extended settings" ), N_( "Toggle playlist" ),
129     N_( "Take a snapshot" ), N_( "Record" ),
130     N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
131     N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
132     N_("Random"), N_("Change the loop and repeat modes"), N_("Information"),
133     N_("Previous media in the playlist"), N_("Next media in the playlist"),
134     N_("Open subtitles file"),
135     N_("Dock/undock fullscreen controller to/from bottom of screen")
136 };
137 static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
138     ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
139     ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
140     ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
141     ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
142     ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
143     ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on",
144     ":/buttons/playlist/repeat_all", ":/menu/info",
145     ":/toolbar/previous_b", ":/toolbar/next_b", ":/toolbar/eject", ":/toolbar/space"
146 };
147
148 enum
149 {
150    WIDGET_NORMAL = 0x0,
151    WIDGET_FLAT   = 0x1,
152    WIDGET_BIG    = 0x2,
153    WIDGET_SHINY  = 0x4,
154 };
155
156 class AdvControlsWidget;
157 class AbstractController : public QFrame
158 {
159     friend class WidgetListing; /* For ToolBar Edition HACKS */
160
161     Q_OBJECT
162 public:
163     AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
164
165 protected:
166     intf_thread_t       *p_intf;
167
168     QSignalMapper       *toolbarActionsMapper;
169     QBoxLayout          *controlLayout;
170     /* Change to BoxLayout if both dir are needed */
171
172     AdvControlsWidget   *advControls;
173
174     void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
175
176     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
177                                      buttonType_e i_type, int i_option );
178
179     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
180 private:
181     static void setupButton( QAbstractButton * );
182     QFrame *discFrame();
183     QFrame *telexFrame();
184     void applyAttributes( QToolButton *, bool b_flat, bool b_big );
185
186     QHBoxLayout         *buttonGroupLayout;
187 protected slots:
188     virtual void setStatus( int );
189
190 signals:
191     void inputExists( bool ); /// This might be useful in the IM ?
192     void inputPlaying( bool ); /// This might be useful in the IM ?
193     void inputIsRecordable( bool ); /// same ?
194     void inputIsTrickPlayable( bool ); /// same ?
195 };
196
197 /* Advanced Button Bar */
198 class AdvControlsWidget : public AbstractController
199 {
200     Q_OBJECT
201 public:
202     AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
203 };
204
205 /* Slider Bar */
206 class InputControlsWidget : public AbstractController
207 {
208     Q_OBJECT
209 public:
210     InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
211 };
212
213 /* Button Bar */
214 class ControlsWidget : public AbstractController
215 {
216     Q_OBJECT
217 public:
218     /* p_intf, advanced control visible or not, blingbling or not */
219     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
220                     QWidget *_parent = 0 );
221
222     void setGripVisible( bool b_visible )
223     { grip->setVisible( b_visible ); }
224
225 protected:
226     friend class MainInterface;
227
228     bool b_advancedVisible;
229
230 private:
231     QSizeGrip *grip;
232
233 protected slots:
234     void toggleAdvanced();
235
236 signals:
237     void advancedControlsToggled( bool );
238 };
239
240
241 /* to trying transparency with fullscreen controller on windows enable that */
242 /* it can be enabled on-non windows systems,
243    but it will be transparent only with composite manager */
244 #define HAVE_TRANSPARENCY 1
245
246 /* Default value of opacity for FS controller */
247 #define DEFAULT_OPACITY 0.70
248
249 /* Used to restore the minimum width after a full-width switch */
250 #define FSC_WIDTH 800
251
252 #define FSC_HEIGHT 72
253
254 /***********************************
255  * Fullscreen controller
256  ***********************************/
257 class FullscreenControllerWidget : public AbstractController
258 {
259     Q_OBJECT
260 public:
261     FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0  );
262     virtual ~FullscreenControllerWidget();
263
264     /* Vout */
265     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
266     void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
267     void toggleFullwidth();
268     void updateFullwidthGeometry( int number );
269     int targetScreen();
270
271 signals:
272     void keyPressed( QKeyEvent * );
273
274 public slots:
275     void setVoutList( vout_thread_t **, int );
276
277 protected:
278     friend class MainInterface;
279
280     virtual void mouseMoveEvent( QMouseEvent *event );
281     virtual void mousePressEvent( QMouseEvent *event );
282     virtual void mouseReleaseEvent( QMouseEvent *event );
283     virtual void enterEvent( QEvent *event );
284     virtual void leaveEvent( QEvent *event );
285     virtual void keyPressEvent( QKeyEvent *event );
286
287     virtual void customEvent( QEvent *event );
288
289 private slots:
290     void showFSC();
291     void planHideFSC();
292     void hideFSC() { hide(); }
293     void slowHideFSC();
294     void restoreFSC();
295     void centerFSC( int );
296
297 private:
298     QTimer *p_hideTimer;
299 #if HAVE_TRANSPARENCY
300     QTimer *p_slowHideTimer;
301     bool b_slow_hide_begin;
302     int  i_slow_hide_timeout;
303     float f_opacity;
304 #endif
305
306     int i_mouse_last_x, i_mouse_last_y;
307     bool b_mouse_over;
308     int i_screennumber;
309     QRect screenRes;
310     QRect previousScreenRes;
311     QPoint previousPosition;
312
313     /* List of vouts currently tracked */
314     QList<vout_thread_t *> vout;
315
316     /* Shared variable between FSC and VLC (protected by a lock) */
317     vlc_mutex_t lock;
318     bool        b_fullscreen;
319     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
320     int i_mouse_last_move_x;
321     int i_mouse_last_move_y;
322
323     bool isWideFSC;
324 };
325
326 #endif