Qt, menus: remove unneeded function
[vlc/vlc-skelet.git] / modules / gui / qt4 / menus.hpp
blobf264d6d8511271f34fb92fb59090a5781a5e8018
1 /*****************************************************************************
2 * menus.hpp : Menus handling
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
5 * $Id$
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 *****************************************************************************/
25 #ifndef QVLC_MENUS_H_
26 #define QVLC_MENUS_H_
28 #include "qt4.hpp"
30 #include <QObject>
31 #include <QAction>
32 #include <QMenu>
33 #include <vector>
35 using namespace std;
37 class QMenuBar;
38 class QSystemTrayIcon;
40 class MenuItemData : public QObject
42 Q_OBJECT
44 public:
45 MenuItemData( QObject* parent, vlc_object_t *_p_obj, int _i_type,
46 vlc_value_t _val, const char *_var ) : QObject( parent )
48 p_obj = _p_obj;
49 if( p_obj )
50 vlc_object_hold( p_obj );
51 i_val_type = _i_type;
52 val = _val;
53 psz_var = strdup( _var );
55 virtual ~MenuItemData()
57 free( psz_var );
58 if( ( i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING )
59 free( val.psz_string );
60 if( p_obj )
61 vlc_object_release( p_obj );
64 vlc_object_t *p_obj;
65 vlc_value_t val;
66 char *psz_var;
68 private:
69 int i_val_type;
72 class QVLCMenu : public QObject
74 Q_OBJECT
75 friend class MenuFunc;
77 public:
78 /* Main bar creation */
79 static void createMenuBar( MainInterface *mi, intf_thread_t * );
81 /* Popups Menus */
82 static void PopupMenu( intf_thread_t *, bool );
83 static void AudioPopupMenu( intf_thread_t *, bool );
84 static void VideoPopupMenu( intf_thread_t *, bool );
85 static void MiscPopupMenu( intf_thread_t *, bool );
87 /* Systray */
88 static void updateSystrayMenu( MainInterface *, intf_thread_t *,
89 bool b_force_visible = false);
91 /* Actions */
92 static void DoAction( QObject * );
94 private:
95 /* All main Menus */
96 static QMenu *FileMenu( intf_thread_t *, QWidget * );
98 static QMenu *ToolsMenu( QMenu * );
99 static QMenu *ToolsMenu( QWidget *parent ) { return ToolsMenu( new QMenu( parent ) ); }
101 static QMenu *ViewMenu( intf_thread_t *, QMenu *, MainInterface * mi = NULL );
103 static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
104 static void ExtensionsMenu( intf_thread_t *p_intf, QMenu * );
106 static QMenu *NavigMenu( intf_thread_t *, QMenu * );
107 static QMenu *NavigMenu( intf_thread_t *p_intf, QWidget *parent ) {
108 return NavigMenu( p_intf, new QMenu( parent ) );
110 static QMenu *RebuildNavigMenu( intf_thread_t *, QMenu *);
112 static QMenu *VideoMenu( intf_thread_t *, QMenu * );
113 static QMenu *VideoMenu( intf_thread_t *p_intf, QWidget *parent ) {
114 return VideoMenu( p_intf, new QMenu( parent ) );
117 static QMenu *AudioMenu( intf_thread_t *, QMenu * );
118 static QMenu *AudioMenu( intf_thread_t *p_intf, QWidget *parent ) {
119 return AudioMenu( p_intf, new QMenu( parent ) );
122 static QMenu *HelpMenu( QWidget * );
124 /* Popups Menus */
125 static void PopupMenuStaticEntries( QMenu *menu );
126 static void PopupPlayEntries( QMenu *menu, intf_thread_t *p_intf,
127 input_thread_t *p_input );
128 static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf );
129 static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf );
131 /* Generic automenu methods */
132 static QMenu * Populate( intf_thread_t *, QMenu *current,
133 vector<const char*>&, vector<vlc_object_t *>& );
135 static void CreateAndConnect( QMenu *, const char *, const QString&,
136 const QString&, int, vlc_object_t *,
137 vlc_value_t, int, bool c = false );
138 static void UpdateItem( intf_thread_t *, QMenu *, const char *,
139 vlc_object_t *, bool );
140 static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
142 /* recentMRL menu */
143 static QMenu *recentsMenu;
145 public slots:
146 static void updateRecents( intf_thread_t * );
149 class MenuFunc : public QObject
151 Q_OBJECT
153 public:
154 MenuFunc( QMenu *_menu, int _id ) : QObject( (QObject *)_menu ),
155 menu( _menu ), id( _id ){}
157 void doFunc( intf_thread_t *p_intf)
159 switch( id )
161 case 1: QVLCMenu::AudioMenu( p_intf, menu ); break;
162 case 2: QVLCMenu::VideoMenu( p_intf, menu ); break;
163 case 3: QVLCMenu::RebuildNavigMenu( p_intf, menu ); break;
164 case 4: QVLCMenu::ViewMenu( p_intf, menu ); break;
167 private:
168 QMenu *menu;
169 int id;
172 #endif