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$
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 _MENUS_H_
00026 #define _MENUS_H_
00027 
00028 #include "qt4.hpp"
00029 
00030 #include <QObject>
00031 #include <QAction>
00032 #include <vector>
00033 
00034 /* Folder vs. Directory */
00035 #if defined( WIN32 ) || defined(__APPLE__)
00036 #define I_OPEN_FOLDER N_("Open &Folder...")
00037 #else
00038 #define I_OPEN_FOLDER N_("Open D&irectory...")
00039 #endif //WIN32
00040 
00041 using namespace std;
00042 
00043 class QMenu;
00044 class QMenuBar;
00045 class QSystemTrayIcon;
00046 
00047 class MenuItemData : public QObject
00048 {
00049 
00050 Q_OBJECT
00051 
00052 public:
00053     MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
00054     {
00055         i_object_id = i_id;
00056         i_val_type = _i_type;
00057         val = _val;
00058         psz_var = strdup( _var );
00059     }
00060     virtual ~MenuItemData()
00061     {
00062         free( psz_var );
00063         if( ( i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
00064             free( val.psz_string );
00065     }
00066     int i_object_id;
00067     int i_val_type;
00068     vlc_value_t val;
00069     char *psz_var;
00070 };
00071 
00072 class QVLCMenu : public QObject
00073 {
00074     Q_OBJECT;
00075 public:
00076     static void createMenuBar( MainInterface *mi, intf_thread_t *, bool );
00077 
00078     /* Menus */
00079     static QMenu *FileMenu();
00080     static QMenu *SDMenu( intf_thread_t * );
00081     static QMenu *PlaylistMenu( intf_thread_t *, MainInterface * );
00082     static QMenu *ToolsMenu( intf_thread_t *, QMenu *, MainInterface *,
00083                              bool, bool with = true );
00084     static QMenu *NavigMenu( intf_thread_t *, QMenu * );
00085     static QMenu *VideoMenu( intf_thread_t *, QMenu * );
00086     static QMenu *AudioMenu( intf_thread_t *, QMenu * );
00087     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
00088     static QMenu *HelpMenu( QMenu * );
00089 
00090     /* Popups Menus */
00091     static void AudioPopupMenu( intf_thread_t * );
00092     static void VideoPopupMenu( intf_thread_t * );
00093     static void MiscPopupMenu( intf_thread_t * );
00094     static void PopupMenu( intf_thread_t *, bool );
00095     static void PopupMenuStaticEntries( intf_thread_t *p_intf, QMenu *menu );
00096     static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
00097                                          input_thread_t *p_input );
00098     /* Systray */
00099     static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
00100                                    bool b_force_visible = false);
00101 
00102     /* Actions */
00103     static void DoAction( intf_thread_t *, QObject * );
00104 
00105     /* HACK for minimalView */
00106     static QAction *minimalViewAction;
00107 private:
00108     /* Generic automenu methods */
00109     static QMenu * Populate( intf_thread_t *, QMenu *current,
00110                              vector<const char*>&, vector<int>&,
00111                              bool append = false );
00112 
00113     static void CreateAndConnect( QMenu *, const char *, QString, QString,
00114                                   int, int, vlc_value_t, int, bool c = false );
00115     static void UpdateItem( intf_thread_t *, QMenu *, const char *,
00116                             vlc_object_t *, bool );
00117     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
00118 };
00119 
00120 class MenuFunc : public QObject
00121 {
00122     Q_OBJECT
00123 
00124 public:
00125     MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
00126     void doFunc( intf_thread_t *p_intf)
00127     {
00128         switch( id )
00129         {
00130         case 1: QVLCMenu::AudioMenu( p_intf, menu ); break;
00131         case 2: QVLCMenu::VideoMenu( p_intf, menu ); break;
00132         case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
00133         case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
00134         }
00135     };
00136     int id;
00137     QMenu *menu;
00138 };
00139 
00140 #endif

Generated on Wed Aug 13 08:02:38 2008 for VLC by  doxygen 1.5.1