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_
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"
42 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
51 class QAbstractSlider;
52 class QAbstractButton;
56 class VolumeClickHandler;
62 typedef enum buttonType_e
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] ={ ":/play_b", ":/stop_b", ":/eject",
116 ":/previous_b", ":/next_b", ":/slower", ":/faster", ":/fullscreen",
117 ":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
118 ":/atob_nob", ":/frame", ":/reverse", ":/skip_back", ":/skip_fw",
129 class AdvControlsWidget;
130 class AbstractController : public QFrame
132 friend class WidgetListing; /* For ToolBar Edition HACKS */
136 AbstractController( intf_thread_t *_p_i, QWidget *_parent = 0 );
139 intf_thread_t *p_intf;
141 QSignalMapper *toolbarActionsMapper;
142 QHBoxLayout *controlLayout;
143 /* Change to BoxLayout if both dir are needed */
145 AdvControlsWidget *advControls;
147 void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
149 virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
150 buttonType_e i_type, int i_option );
152 QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
154 static void setupButton( QAbstractButton * );
156 QFrame *telexFrame();
157 void applyAttributes( QToolButton *, bool b_flat, bool b_big );
159 virtual void setStatus( int );
162 void inputExists( bool ); /// This might be usefull in the IM ?
163 void inputPlaying( bool ); /// This might be usefull in the IM ?
164 void inputIsRecordable( bool ); /// same ?
165 void inputIsTrickPlayable( bool ); /// same ?
169 /* Advanced Button Bar */
170 class AdvControlsWidget : public AbstractController
174 AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
178 class InputControlsWidget : public AbstractController
182 InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
186 class ControlsWidget : public AbstractController
190 /* p_intf, advanced control visible or not, blingbling or not */
191 ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
192 QWidget *_parent = 0 );
193 virtual ~ControlsWidget();
196 friend class MainInterface;
198 bool b_advancedVisible;
201 void toggleAdvanced();
204 void advancedControlsToggled( bool );
207 /* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
208 done by trick with setting the opacity of window */
213 /* to trying transparency with fullscreen controller on windows enable that */
214 /* it can be enabled on-non windows systems,
215 but it will be transparent only with composite manager */
217 #define HAVE_TRANSPARENCY 1
219 #define HAVE_TRANSPARENCY 0
222 /* Default value of opacity for FS controller */
223 #define DEFAULT_OPACITY 0.75
225 /***********************************
226 * Fullscreen controller
227 ***********************************/
228 class FullscreenControllerWidget : public AbstractController
232 FullscreenControllerWidget( intf_thread_t * );
233 virtual ~FullscreenControllerWidget();
236 void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
237 void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
240 void setVoutList( vout_thread_t **, int );
243 friend class MainInterface;
245 virtual void mouseMoveEvent( QMouseEvent *event );
246 virtual void mousePressEvent( QMouseEvent *event );
247 virtual void mouseReleaseEvent( QMouseEvent *event );
248 virtual void enterEvent( QEvent *event );
249 virtual void leaveEvent( QEvent *event );
250 virtual void keyPressEvent( QKeyEvent *event );
257 void centerFSC( int );
260 virtual void customEvent( QEvent *event );
263 #if HAVE_TRANSPARENCY
264 QTimer *p_slowHideTimer;
265 bool b_slow_hide_begin;
266 int i_slow_hide_timeout;
269 int i_mouse_last_x, i_mouse_last_y;
278 /* List of vouts currently tracked */
279 QList<vout_thread_t *> vout;
281 /* Shared variable between FSC and VLC (protected by a lock) */
284 int i_hide_timeout; /* FSC hiding timeout, same as mouse hiding timeout */
285 int i_mouse_last_move_x;
286 int i_mouse_last_move_y;