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 "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"
43 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
53 class QAbstractSlider;
54 class QAbstractButton;
58 class VolumeClickHandler;
64 typedef enum buttonType_e
103 ASPECT_RATIO_COMBOBOX,
106 TIME_LABEL_REMAINING,
109 WIDGET_SPACER = 0x40,
110 WIDGET_SPACER_EXTEND,
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")
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 held"),
126 N_("Next media in the playlist, skip forward when held"), 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")
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"
156 class AdvControlsWidget;
157 class AbstractController : public QFrame
159 friend class WidgetListing; /* For ToolBar Edition HACKS */
163 AbstractController( intf_thread_t *_p_i, QWidget *_parent = 0 );
166 intf_thread_t *p_intf;
168 QSignalMapper *toolbarActionsMapper;
169 QBoxLayout *controlLayout;
170 /* Change to BoxLayout if both dir are needed */
172 AdvControlsWidget *advControls;
174 void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
176 virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
177 buttonType_e i_type, int i_option );
179 QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
181 static void setupButton( QAbstractButton * );
183 QFrame *telexFrame();
184 void applyAttributes( QToolButton *, bool b_flat, bool b_big );
186 QHBoxLayout *buttonGroupLayout;
188 virtual void setStatus( int );
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 ?
197 /* Advanced Button Bar */
198 class AdvControlsWidget : public AbstractController
202 AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
206 class InputControlsWidget : public AbstractController
210 InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
214 class ControlsWidget : public AbstractController
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 );
222 void setGripVisible( bool b_visible )
223 { grip->setVisible( b_visible ); }
226 friend class MainInterface;
228 bool b_advancedVisible;
234 void toggleAdvanced();
237 void advancedControlsToggled( bool );
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
246 /* Default value of opacity for FS controller */
247 #define DEFAULT_OPACITY 0.70
249 /* Used to restore the minimum width after a full-width switch */
250 #define FSC_WIDTH 800
252 #define FSC_HEIGHT 72
254 /***********************************
255 * Fullscreen controller
256 ***********************************/
257 class FullscreenControllerWidget : public AbstractController
261 FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0 );
262 virtual ~FullscreenControllerWidget();
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 );
272 void keyPressed( QKeyEvent * );
275 void setVoutList( vout_thread_t **, int );
278 friend class MainInterface;
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 );
287 virtual void customEvent( QEvent *event );
292 void hideFSC() { hide(); }
295 void centerFSC( int );
299 #if HAVE_TRANSPARENCY
300 QTimer *p_slowHideTimer;
301 bool b_slow_hide_begin;
302 int i_slow_hide_timeout;
306 int i_mouse_last_x, i_mouse_last_y;
310 QRect previousScreenRes;
311 QPoint previousPosition;
313 /* List of vouts currently tracked */
314 QList<vout_thread_t *> vout;
316 /* Shared variable between FSC and VLC (protected by a lock) */
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;