1 /*****************************************************************************
2 * menus.hpp : Menus handling
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
34 /* Folder vs. Directory */
35 #if defined( WIN32 ) || defined(__APPLE__)
36 #define I_OPEN_FOLDER N_("Open &Folder...")
38 #define I_OPEN_FOLDER N_("Open D&irectory...")
45 class QSystemTrayIcon;
47 class MenuItemData : public QObject
52 MenuItemData( QObject* parent, vlc_object_t *_p_obj, int _i_type,
53 vlc_value_t _val, const char *_var ) : QObject( parent )
58 psz_var = strdup( _var );
60 virtual ~MenuItemData()
63 if( ( i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
64 free( val.psz_string );
75 class QVLCMenu : public QObject
78 friend class MenuFunc;
81 /* Main bar creation */
82 static void createMenuBar( MainInterface *mi, intf_thread_t * );
85 static void PopupMenu( intf_thread_t *, bool );
86 static void AudioPopupMenu( intf_thread_t * );
87 static void VideoPopupMenu( intf_thread_t * );
88 static void MiscPopupMenu( intf_thread_t * );
91 static void updateSystrayMenu( MainInterface *,intf_thread_t *,
92 bool b_force_visible = false);
95 static void DoAction( QObject * );
99 static QMenu *FileMenu( intf_thread_t *, QWidget * );
100 static QMenu *SDMenu( intf_thread_t *, QWidget * );
102 static QMenu *ToolsMenu( QMenu * );
103 static QMenu *ToolsMenu( QWidget * );
105 static QMenu *ViewMenu( intf_thread_t *, MainInterface *,
107 static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
109 static QMenu *NavigMenu( intf_thread_t *, QMenu * );
110 static QMenu *NavigMenu( intf_thread_t *, QWidget * );
111 static QMenu *RebuildNavigMenu( intf_thread_t *, QMenu *);
113 static QMenu *VideoMenu( intf_thread_t *, QMenu * );
114 static QMenu *VideoMenu( intf_thread_t *, QWidget * );
116 static QMenu *AudioMenu( intf_thread_t *, QMenu * );
117 static QMenu *AudioMenu( intf_thread_t *, QWidget * );
119 static QMenu *HelpMenu( QWidget * );
122 static void PopupMenuStaticEntries( QMenu *menu );
123 static void PopupPlayEntries( QMenu *menu, intf_thread_t *p_intf,
124 input_thread_t *p_input );
125 static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf );
126 static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf );
128 /* Generic automenu methods */
129 static QMenu * Populate( intf_thread_t *, QMenu *current,
130 vector<const char*>&, vector<vlc_object_t *>& );
132 static void CreateAndConnect( QMenu *, const char *, QString, QString,
133 int, vlc_object_t *, vlc_value_t, int,
135 static void UpdateItem( intf_thread_t *, QMenu *, const char *,
136 vlc_object_t *, bool );
137 static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
140 static QMenu *recentsMenu;
143 static void updateRecents( intf_thread_t * );
146 class MenuFunc : public QObject
151 MenuFunc( QMenu *_menu, int _id ) : QObject( (QObject *)_menu ),
152 menu( _menu ), id( _id ){}
154 void doFunc( intf_thread_t *p_intf)
158 case 1: QVLCMenu::AudioMenu( p_intf, menu ); break;
159 case 2: QVLCMenu::VideoMenu( p_intf, menu ); break;
160 case 3: QVLCMenu::RebuildNavigMenu( p_intf, menu ); break;
161 case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;