controller.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * Controller.hpp : Controller for the main interface
00003  ****************************************************************************
00004  * Copyright (C) 2006-2008 the VideoLAN team
00005  * $Id: f987226a497c9f917f5c16c1f853fc2a28acc074 $
00006  *
00007  * Authors: Jean-Baptiste Kempf <jb@videolan.org>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef QVLC_CONTROLLER_H_
00025 #define QVLC_CONTROLLER_H_
00026 
00027 #ifdef HAVE_CONFIG_H
00028 # include "config.h"
00029 #endif
00030 
00031 #include "qt4.hpp"
00032 
00033 #include <QFrame>
00034 #include <QString>
00035 
00036 #define MAIN_TB1_DEFAULT "64;39;64;38;65"
00037 #define MAIN_TB2_DEFAULT "0-2;64;3;1;4;64;7;10;9;64-4;20;19;64-4;37;65;35-4"
00038 #define ADV_TB_DEFAULT "12;11;13;14"
00039 #define INPT_TB_DEFAULT "5-1;15-1;33;6-1"
00040 #define FSC_TB_DEFAULT "0-2;64;3;1;4;64;37;64;38;64;8;65;35-4;34"
00041 
00042 #define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
00043 
00044 class QPixmap;
00045 class QLabel;
00046 
00047 class QGridLayout;
00048 class QHBoxLayout;
00049 class QBoxLayout;
00050 
00051 class QAbstractSlider;
00052 class QAbstractButton;
00053 class InputSlider;
00054 class QToolButton;
00055 
00056 class VolumeClickHandler;
00057 class WidgetListing;
00058 
00059 class QSignalMapper;
00060 class QTimer;
00061 
00062 typedef enum buttonType_e
00063 {
00064     PLAY_BUTTON,
00065     STOP_BUTTON,
00066     OPEN_BUTTON,
00067     PREVIOUS_BUTTON,
00068     NEXT_BUTTON,
00069     SLOWER_BUTTON,
00070     FASTER_BUTTON,
00071     FULLSCREEN_BUTTON,
00072     DEFULLSCREEN_BUTTON,
00073     EXTENDED_BUTTON,
00074     PLAYLIST_BUTTON,
00075     SNAPSHOT_BUTTON,
00076     RECORD_BUTTON,
00077     ATOB_BUTTON,
00078     FRAME_BUTTON,
00079     REVERSE_BUTTON,
00080     SKIP_BACK_BUTTON,
00081     SKIP_FW_BUTTON,
00082     QUIT_BUTTON,
00083     RANDOM_BUTTON,
00084     LOOP_BUTTON,
00085     INFO_BUTTON,
00086     BUTTON_MAX,
00087 
00088     SPLITTER = 0x20,
00089     INPUT_SLIDER,
00090     TIME_LABEL,
00091     VOLUME,
00092     VOLUME_SPECIAL,
00093     MENU_BUTTONS,
00094     TELETEXT_BUTTONS,
00095     ADVANCED_CONTROLLER,
00096     SPECIAL_MAX,
00097 
00098     WIDGET_SPACER = 0x40,
00099     WIDGET_SPACER_EXTEND,
00100     WIDGET_MAX,
00101 } buttonType_e;
00102 
00103 
00104 static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
00105     N_("Previous"), N_("Next"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
00106    N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
00107    N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
00108    N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random"),
00109    N_("Loop/Repeat mode"), N_("Information") };
00110 static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
00111     N_("Stop playback"), N_("Open a medium"),
00112     N_("Previous media in the playlist"),
00113     N_("Next media in the playlist"), N_("Slower"), N_("Faster"),
00114     N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
00115     N_("Show extended settings" ), N_( "Show playlist" ),
00116     N_( "Take a snapshot" ), N_( "Record" ),
00117     N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
00118     N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
00119     N_("Random"), N_("Change the loop and repeat modes"), N_("Information") };
00120 static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
00121     ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
00122     ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
00123     ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
00124     ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
00125     ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
00126     ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on",
00127     ":/buttons/playlist/repeat_all", ":/menu/info" };
00128 
00129 enum
00130 {
00131    WIDGET_NORMAL = 0x0,
00132    WIDGET_FLAT   = 0x1,
00133    WIDGET_BIG    = 0x2,
00134    WIDGET_SHINY  = 0x4,
00135 };
00136 
00137 class AdvControlsWidget;
00138 class AbstractController : public QFrame
00139 {
00140     friend class WidgetListing; /* For ToolBar Edition HACKS */
00141 
00142     Q_OBJECT
00143 public:
00144     AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
00145 
00146 protected:
00147     intf_thread_t       *p_intf;
00148 
00149     QSignalMapper       *toolbarActionsMapper;
00150     QHBoxLayout         *controlLayout;
00151     /* Change to BoxLayout if both dir are needed */
00152 
00153     AdvControlsWidget   *advControls;
00154 
00155     void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
00156 
00157     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
00158                                      buttonType_e i_type, int i_option );
00159 
00160     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
00161 private:
00162     static void setupButton( QAbstractButton * );
00163     QFrame *discFrame();
00164     QFrame *telexFrame();
00165     void applyAttributes( QToolButton *, bool b_flat, bool b_big );
00166 protected slots:
00167     virtual void setStatus( int );
00168 
00169 signals:
00170     void inputExists( bool ); /// This might be usefull in the IM ?
00171     void inputPlaying( bool ); /// This might be usefull in the IM ?
00172     void inputIsRecordable( bool ); /// same ?
00173     void inputIsTrickPlayable( bool ); /// same ?
00174 };
00175 
00176 /* Advanced Button Bar */
00177 class AdvControlsWidget : public AbstractController
00178 {
00179     Q_OBJECT
00180 public:
00181     AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
00182 };
00183 
00184 /* Slider Bar */
00185 class InputControlsWidget : public AbstractController
00186 {
00187     Q_OBJECT
00188 public:
00189     InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
00190 };
00191 
00192 /* Button Bar */
00193 class ControlsWidget : public AbstractController
00194 {
00195     Q_OBJECT
00196 public:
00197     /* p_intf, advanced control visible or not, blingbling or not */
00198     ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
00199                     QWidget *_parent = 0 );
00200     virtual ~ControlsWidget();
00201 
00202 protected:
00203     friend class MainInterface;
00204 
00205     bool b_advancedVisible;
00206 
00207 protected slots:
00208     void toggleAdvanced();
00209 
00210 signals:
00211     void advancedControlsToggled( bool );
00212 };
00213 
00214 
00215 /* to trying transparency with fullscreen controller on windows enable that */
00216 /* it can be enabled on-non windows systems,
00217    but it will be transparent only with composite manager */
00218 #define HAVE_TRANSPARENCY 1
00219 
00220 /* Default value of opacity for FS controller */
00221 #define DEFAULT_OPACITY 0.70
00222 
00223 /***********************************
00224  * Fullscreen controller
00225  ***********************************/
00226 class FullscreenControllerWidget : public AbstractController
00227 {
00228     Q_OBJECT
00229 public:
00230     FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0  );
00231     virtual ~FullscreenControllerWidget();
00232 
00233     /* Vout */
00234     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
00235     void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
00236 
00237 signals:
00238     void keyPressed( QKeyEvent * );
00239 
00240 public slots:
00241     void setVoutList( vout_thread_t **, int );
00242 
00243 protected:
00244     friend class MainInterface;
00245 
00246     virtual void mouseMoveEvent( QMouseEvent *event );
00247     virtual void mousePressEvent( QMouseEvent *event );
00248     virtual void mouseReleaseEvent( QMouseEvent *event );
00249     virtual void enterEvent( QEvent *event );
00250     virtual void leaveEvent( QEvent *event );
00251     virtual void keyPressEvent( QKeyEvent *event );
00252 
00253 private slots:
00254     void showFSC();
00255     void planHideFSC();
00256     void hideFSC() { hide(); }
00257     void slowHideFSC();
00258     void centerFSC( int );
00259 
00260 private:
00261     virtual void customEvent( QEvent *event );
00262 
00263     QTimer *p_hideTimer;
00264 #if HAVE_TRANSPARENCY
00265     QTimer *p_slowHideTimer;
00266     bool b_slow_hide_begin;
00267     int  i_slow_hide_timeout;
00268 #endif
00269 
00270     int i_mouse_last_x, i_mouse_last_y;
00271     bool b_mouse_over;
00272     int i_screennumber;
00273     QRect screenRes;
00274 
00275     /* List of vouts currently tracked */
00276     QList<vout_thread_t *> vout;
00277 
00278     /* Shared variable between FSC and VLC (protected by a lock) */
00279     vlc_mutex_t lock;
00280     bool        b_fullscreen;
00281     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
00282     int i_mouse_last_move_x;
00283     int i_mouse_last_move_y;
00284 };
00285 
00286 #endif

Generated on Tue May 25 08:04:57 2010 for VLC by  doxygen 1.5.6