]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.hpp
qt4 - Include cleanup.
[vlc] / modules / gui / qt4 / menus.hpp
1 /*****************************************************************************
2  * menus.hpp : Menus handling
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
22
23 #ifndef _MENUS_H_
24 #define _MENUS_H_
25
26 #include "qt4.hpp"
27
28 #include <QObject>
29 #include <vector>
30
31 using namespace std;
32
33 class QMenu;
34 class QMenuBar;
35 class QSystemTrayIcon;
36
37 class MenuItemData : public QObject
38 {
39
40 Q_OBJECT
41
42 public:
43     MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
44     {
45         i_object_id = i_id;
46         i_val_type = _i_type;
47         val = _val;
48         psz_var = strdup( _var );
49     }
50     virtual ~MenuItemData()
51     {
52         if( psz_var ) free( psz_var );
53         if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
54             && val.psz_string ) free( val.psz_string );
55     }
56     int i_object_id;
57     int i_val_type;
58     vlc_value_t val;
59     char *psz_var;
60 };
61
62 class QVLCMenu : public QObject
63 {
64     Q_OBJECT;
65 public:
66     static void createMenuBar( MainInterface *mi, intf_thread_t *,
67                                bool, bool, bool );
68
69     /* Menus */
70     static QMenu *FileMenu();
71     static QMenu *SDMenu( intf_thread_t * );
72     static QMenu *PlaylistMenu( MainInterface *, intf_thread_t *);
73     static QMenu *ToolsMenu( intf_thread_t *, MainInterface *, bool, bool,
74                              bool with = true );
75     static QMenu *NavigMenu( intf_thread_t * , QMenu * );
76     static QMenu *VideoMenu( intf_thread_t * , QMenu * );
77     static QMenu *AudioMenu( intf_thread_t * , QMenu * );
78     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
79     static QMenu *HelpMenu();
80
81     /* Popups Menus */
82     static void AudioPopupMenu( intf_thread_t * );
83     static void VideoPopupMenu( intf_thread_t * );
84     static void MiscPopupMenu( intf_thread_t * );
85     static void PopupMenu( intf_thread_t *, bool );
86
87     /* Systray */
88     static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
89                                    bool b_force_visible = false);
90
91     /* Actions */
92     static void DoAction( intf_thread_t *, QObject * );
93 private:
94     /* Generic automenu methods */
95     static QMenu * Populate( intf_thread_t *, QMenu *current,
96                              vector<const char*>&, vector<int>&,
97                              bool append = false );
98
99     static void CreateAndConnect( QMenu *, const char *, QString, QString,
100                                   int, int, vlc_value_t, int, bool c = false );
101     static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
102     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
103 };
104
105 class MenuFunc : public QObject
106 {
107 Q_OBJECT
108
109 public:
110     MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
111     void doFunc( intf_thread_t *p_intf)
112     {
113         switch( id )
114         {
115         case 1: QVLCMenu::VideoMenu( p_intf, menu ); break;
116         case 2: QVLCMenu::AudioMenu( p_intf, menu ); break;
117         case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
118         case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
119         }
120     };
121     int id; QMenu *menu;
122 };
123
124 #endif