1 /*****************************************************************************
2 * Controller.hpp : Controller for the main interface
3 ****************************************************************************
4 * Copyright (C) 2006-2008 the VideoLAN team
7 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
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.
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.
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 *****************************************************************************/
24 #ifndef QVLC_CONTROLLER_H_
25 #define QVLC_CONTROLLER_H_
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 "5-1;15-1;33;6-1"
41 #define FSC_TB_DEFAULT "0-2;64;3;1;4;64;37;64;38;64;8;65;25;35-4;34"
43 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
52 class QAbstractSlider;
53 class QAbstractButton;
57 class VolumeClickHandler;
63 typedef enum buttonType_e
104 WIDGET_SPACER = 0x40,
105 WIDGET_SPACER_EXTEND,
110 static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
111 N_("Previous/Backward"), N_("Next/Forward"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
112 N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
113 N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
114 N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random"),
115 N_("Loop/Repeat mode"), N_("Information"), N_("Previous"), N_("Next"),
116 N_("Open subtitles file"), N_("Fullscreen controller width toggle")
118 static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
119 N_("Stop playback"), N_("Open a medium"),
120 N_("Previous media in the playlist, skip backward when keep-pressed"),
121 N_("Next media in the playlist, skip forward when keep-pressed"), N_("Slower"), N_("Faster"),
122 N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
123 N_("Show extended settings" ), N_( "Show playlist" ),
124 N_( "Take a snapshot" ), N_( "Record" ),
125 N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
126 N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
127 N_("Random"), N_("Change the loop and repeat modes"), N_("Information"),
128 N_("Previous media in the playlist"), N_("Next media in the playlist"),
129 N_("Open subtitles file"),
130 N_("Dock/undock fullscreen controller to/from bottom of screen")
132 static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
133 ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
134 ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
135 ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
136 ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
137 ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
138 ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on",
139 ":/buttons/playlist/repeat_all", ":/menu/info",
140 ":/toolbar/previous_b", ":/toolbar/next_b", "", ":/toolbar/space"
151 class AdvControlsWidget;
152 class AbstractController : public QFrame
154 friend class WidgetListing; /* For ToolBar Edition HACKS */
158 AbstractController( intf_thread_t *_p_i, QWidget *_parent = 0 );
161 intf_thread_t *p_intf;
163 QSignalMapper *toolbarActionsMapper;
164 QHBoxLayout *controlLayout;
165 /* Change to BoxLayout if both dir are needed */
167 AdvControlsWidget *advControls;
169 void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
171 virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
172 buttonType_e i_type, int i_option );
174 QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
176 static void setupButton( QAbstractButton * );
178 QFrame *telexFrame();
179 void applyAttributes( QToolButton *, bool b_flat, bool b_big );
181 QHBoxLayout *buttonGroupLayout;
183 virtual void setStatus( int );
186 void inputExists( bool ); /// This might be useful in the IM ?
187 void inputPlaying( bool ); /// This might be useful in the IM ?
188 void inputIsRecordable( bool ); /// same ?
189 void inputIsTrickPlayable( bool ); /// same ?
192 /* Advanced Button Bar */
193 class AdvControlsWidget : public AbstractController
197 AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
201 class InputControlsWidget : public AbstractController
205 InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
209 class ControlsWidget : public AbstractController
213 /* p_intf, advanced control visible or not, blingbling or not */
214 ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
215 QWidget *_parent = 0 );
217 void setGripVisible( bool b_visible )
218 { grip->setVisible( b_visible ); }
221 friend class MainInterface;
223 bool b_advancedVisible;
229 void toggleAdvanced();
232 void advancedControlsToggled( bool );
236 /* to trying transparency with fullscreen controller on windows enable that */
237 /* it can be enabled on-non windows systems,
238 but it will be transparent only with composite manager */
239 #define HAVE_TRANSPARENCY 1
241 /* Default value of opacity for FS controller */
242 #define DEFAULT_OPACITY 0.70
244 /***********************************
245 * Fullscreen controller
246 ***********************************/
247 class FullscreenControllerWidget : public AbstractController
251 FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0 );
252 virtual ~FullscreenControllerWidget();
255 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
256 void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
257 void toggleFullwidth();
260 void keyPressed( QKeyEvent * );
263 void setVoutList( vout_thread_t **, int );
266 friend class MainInterface;
268 virtual void mouseMoveEvent( QMouseEvent *event );
269 virtual void mousePressEvent( QMouseEvent *event );
270 virtual void mouseReleaseEvent( QMouseEvent *event );
271 virtual void enterEvent( QEvent *event );
272 virtual void leaveEvent( QEvent *event );
273 virtual void keyPressEvent( QKeyEvent *event );
275 virtual void customEvent( QEvent *event );
280 void hideFSC() { hide(); }
282 void centerFSC( int );
286 #if HAVE_TRANSPARENCY
287 QTimer *p_slowHideTimer;
288 bool b_slow_hide_begin;
289 int i_slow_hide_timeout;
293 int i_mouse_last_x, i_mouse_last_y;
298 /* List of vouts currently tracked */
299 QList<vout_thread_t *> vout;
301 /* Shared variable between FSC and VLC (protected by a lock) */
304 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
305 int i_mouse_last_move_x;
306 int i_mouse_last_move_y;