menus.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * menus.hpp : Menus handling
00003  ****************************************************************************
00004  * Copyright (C) 2006 the VideoLAN team
00005  * $Id: f553679ba91f187ff45c64e5f9f51443a44fe768 $
00006  *
00007  * Authors: Clément Stenac <zorglub@videolan.org>
00008  *          Jean-Baptiste Kempf <jb@videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef QVLC_MENUS_H_
00026 #define QVLC_MENUS_H_
00027 
00028 #include "qt4.hpp"
00029 
00030 #include <QObject>
00031 #include <QAction>
00032 #include <vector>
00033 
00034 using namespace std;
00035 
00036 class QMenu;
00037 class QMenuBar;
00038 class QSystemTrayIcon;
00039 
00040 class MenuItemData : public QObject
00041 {
00042     Q_OBJECT
00043 
00044 public:
00045     MenuItemData( QObject* parent, vlc_object_t *_p_obj, int _i_type,
00046                   vlc_value_t _val, const char *_var ) : QObject( parent )
00047     {
00048         p_obj = _p_obj;
00049         if( p_obj )
00050             vlc_object_hold( p_obj );
00051         i_val_type = _i_type;
00052         val = _val;
00053         psz_var = strdup( _var );
00054     }
00055     virtual ~MenuItemData()
00056     {
00057         free( psz_var );
00058         if( ( i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
00059             free( val.psz_string );
00060         if( p_obj )
00061             vlc_object_release( p_obj );
00062     }
00063 
00064     vlc_object_t *p_obj;
00065     vlc_value_t val;
00066     char *psz_var;
00067 
00068 private:
00069     int i_val_type;
00070 };
00071 
00072 class QVLCMenu : public QObject
00073 {
00074     Q_OBJECT
00075     friend class MenuFunc;
00076 
00077 public:
00078     /* Main bar creation */
00079     static void createMenuBar( MainInterface *mi, intf_thread_t * );
00080 
00081     /* Popups Menus */
00082     static void PopupMenu( intf_thread_t *, bool );
00083     static void AudioPopupMenu( intf_thread_t *, bool );
00084     static void VideoPopupMenu( intf_thread_t *, bool );
00085     static void MiscPopupMenu( intf_thread_t *, bool );
00086 
00087     /* Systray */
00088     static void updateSystrayMenu( MainInterface *, intf_thread_t  *,
00089                                    bool b_force_visible = false);
00090 
00091     /* Actions */
00092     static void DoAction( QObject * );
00093 
00094 private:
00095     /* All main Menus */
00096     static QMenu *FileMenu( intf_thread_t *, QWidget * );
00097     static QMenu *SDMenu( intf_thread_t *, QWidget * );
00098 
00099     static QMenu *ToolsMenu( QMenu * );
00100     static QMenu *ToolsMenu( QWidget * );
00101 
00102     static QMenu *ViewMenu( intf_thread_t *, QWidget * );
00103     static QMenu *ViewMenu( intf_thread_t *, QMenu *, MainInterface * mi = NULL );
00104 
00105     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
00106     static void ExtensionsMenu( intf_thread_t *p_intf, QMenu * );
00107 
00108     static QMenu *NavigMenu( intf_thread_t *, QMenu * );
00109     static QMenu *NavigMenu( intf_thread_t *, QWidget * );
00110     static QMenu *RebuildNavigMenu( intf_thread_t *, QMenu *);
00111 
00112     static QMenu *VideoMenu( intf_thread_t *, QMenu * );
00113     static QMenu *VideoMenu( intf_thread_t *, QWidget * );
00114 
00115     static QMenu *AudioMenu( intf_thread_t *, QMenu * );
00116     static QMenu *AudioMenu( intf_thread_t *, QWidget * );
00117 
00118     static QMenu *HelpMenu( QWidget * );
00119 
00120     /* Popups Menus */
00121     static void PopupMenuStaticEntries( QMenu *menu );
00122     static void PopupPlayEntries( QMenu *menu, intf_thread_t *p_intf,
00123                                          input_thread_t *p_input );
00124     static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf );
00125     static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf );
00126 
00127     /* Generic automenu methods */
00128     static QMenu * Populate( intf_thread_t *, QMenu *current,
00129                              vector<const char*>&, vector<vlc_object_t *>& );
00130 
00131     static void CreateAndConnect( QMenu *, const char *, const QString&,
00132                                   const QString&, int, vlc_object_t *,
00133                                   vlc_value_t, int, bool c = false );
00134     static void UpdateItem( intf_thread_t *, QMenu *, const char *,
00135                             vlc_object_t *, bool );
00136     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
00137 
00138     /* recentMRL menu */
00139     static QMenu *recentsMenu;
00140 
00141 public slots:
00142     static void updateRecents( intf_thread_t * );
00143 };
00144 
00145 class MenuFunc : public QObject
00146 {
00147     Q_OBJECT
00148 
00149 public:
00150     MenuFunc( QMenu *_menu, int _id ) : QObject( (QObject *)_menu ),
00151                                         menu( _menu ), id( _id ){}
00152 
00153     void doFunc( intf_thread_t *p_intf)
00154     {
00155         switch( id )
00156         {
00157             case 1: QVLCMenu::AudioMenu( p_intf, menu ); break;
00158             case 2: QVLCMenu::VideoMenu( p_intf, menu ); break;
00159             case 3: QVLCMenu::RebuildNavigMenu( p_intf, menu ); break;
00160             case 4: QVLCMenu::ViewMenu( p_intf, menu ); break;
00161         }
00162     }
00163 private:
00164     QMenu *menu;
00165     int id;
00166 };
00167 
00168 #endif

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