]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/controller.hpp
f7a046b12f73e2814ae2652ff1762c4d0ee0fbc9
[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     RANDOM_BUTTON,
84     BUTTON_MAX,
85
86     SPLITTER = 0x20,
87     INPUT_SLIDER,
88     TIME_LABEL,
89     VOLUME,
90     VOLUME_SPECIAL,
91     MENU_BUTTONS,
92     TELETEXT_BUTTONS,
93     ADVANCED_CONTROLLER,
94     SPECIAL_MAX,
95
96     WIDGET_SPACER = 0x40,
97     WIDGET_SPACER_EXTEND,
98     WIDGET_MAX,
99 } buttonType_e;
100
101
102 static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
103     N_("Previous"), N_("Next"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
104    N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
105    N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
106    N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random") };
107 static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
108     N_("Stop playback"), N_("Open a medium"),
109     N_("Previous media in the playlist"),
110     N_("Next media in the playlist"), N_("Slower"), N_("Faster"),
111     N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
112     N_("Show extended settings" ), N_( "Show playlist" ),
113     N_( "Take a snapshot" ), N_( "Record" ),
114     N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
115     N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
116     N_("Random") };
117 static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
118     ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
119     ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
120     ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
121     ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
122     ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
123     ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on" };
124
125 enum
126 {
127    WIDGET_NORMAL = 0x0,
128    WIDGET_FLAT   = 0x1,
129    WIDGET_BIG    = 0x2,
130    WIDGET_SHINY  = 0x4,
131 };
132
133 class AdvControlsWidget;
134 class AbstractController : public QFrame
135 {
136     friend class WidgetListing; /* For ToolBar Edition HACKS */
137
138     Q_OBJECT
139 public:
140     AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
141
142 protected:
143     intf_thread_t       *p_intf;
144
145     QSignalMapper       *toolbarActionsMapper;
146     QHBoxLayout         *controlLayout;
147     /* Change to BoxLayout if both dir are needed */
148
149     AdvControlsWidget   *advControls;
150
151     void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
152
153     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
154                                      buttonType_e i_type, int i_option );
155
156     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
157 private:
158     static void setupButton( QAbstractButton * );
159     QFrame *discFrame();
160     QFrame *telexFrame();
161     void applyAttributes( QToolButton *, bool b_flat, bool b_big );
162 protected slots:
163     virtual void setStatus( int );
164
165 signals:
166     void inputExists( bool ); /// This might be usefull in the IM ?
167     void inputPlaying( bool ); /// This might be usefull in the IM ?
168     void inputIsRecordable( bool ); /// same ?
169     void inputIsTrickPlayable( bool ); /// same ?
170     void sizeChanged();
171 };
172
173 /* Advanced Button Bar */
174 class AdvControlsWidget : public AbstractController
175 {
176     Q_OBJECT
177 public:
178     AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
179 };
180
181 /* Slider Bar */
182 class InputControlsWidget : public AbstractController
183 {
184     Q_OBJECT
185 public:
186     InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
187 };
188
189 /* Button Bar */
190 class ControlsWidget : public AbstractController
191 {
192     Q_OBJECT
193 public:
194     /* p_intf, advanced control visible or not, blingbling or not */
195     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
196                     QWidget *_parent = 0 );
197     virtual ~ControlsWidget();
198
199 protected:
200     friend class MainInterface;
201
202     bool                 b_advancedVisible;
203
204 protected slots:
205     void toggleAdvanced();
206
207 signals:
208     void advancedControlsToggled( bool );
209 };
210
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 #define HAVE_TRANSPARENCY 1
216
217 /* Default value of opacity for FS controller */
218 #define DEFAULT_OPACITY 0.70
219
220 /***********************************
221  * Fullscreen controller
222  ***********************************/
223 class FullscreenControllerWidget : public AbstractController
224 {
225     Q_OBJECT
226 public:
227     FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0  );
228     virtual ~FullscreenControllerWidget();
229
230     /* Vout */
231     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
232     void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
233
234 signals:
235     void keyPressed( QKeyEvent * );
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 mouseReleaseEvent( 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() { hide(); }
254     void slowHideFSC();
255     void centerFSC( int );
256
257 private:
258     virtual void customEvent( QEvent *event );
259
260     QTimer *p_hideTimer;
261 #if HAVE_TRANSPARENCY
262     QTimer *p_slowHideTimer;
263     bool b_slow_hide_begin;
264     int  i_slow_hide_timeout;
265 #endif
266
267     int i_mouse_last_x, i_mouse_last_y;
268     bool b_mouse_over;
269     int i_screennumber;
270     QRect screenRes;
271
272     /* List of vouts currently tracked */
273     QList<vout_thread_t *> vout;
274
275     /* Shared variable between FSC and VLC (protected by a lock) */
276     vlc_mutex_t lock;
277     bool        b_fullscreen;
278     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
279     int i_mouse_last_move_x;
280     int i_mouse_last_move_y;
281 };
282
283 #endif