]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.hpp
f7c15918fec1860a3d3f6b5bb6436a40a359f06e
[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  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
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.
14  *
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.
19  *
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
24 #ifndef _MENUS_H_
25 #define _MENUS_H_
26
27 #include "qt4.hpp"
28
29 #include <QObject>
30 #include <vector>
31
32 /* Folder vs. Directory */
33 #ifdef WIN32
34 #define I_OPEN_FOLDER "Open &Folder..."
35 #else 
36 #define I_OPEN_FOLDER "Open D&irectory..."
37 #endif //WIN32
38
39 using namespace std;
40
41 class QMenu;
42 class QMenuBar;
43 class QSystemTrayIcon;
44
45 class MenuItemData : public QObject
46 {
47
48 Q_OBJECT
49
50 public:
51     MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
52     {
53         i_object_id = i_id;
54         i_val_type = _i_type;
55         val = _val;
56         psz_var = strdup( _var );
57     }
58     virtual ~MenuItemData()
59     {
60         if( psz_var ) free( psz_var );
61         if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
62             && val.psz_string ) free( val.psz_string );
63     }
64     int i_object_id;
65     int i_val_type;
66     vlc_value_t val;
67     char *psz_var;
68 };
69
70 class QVLCMenu : public QObject
71 {
72     Q_OBJECT;
73 public:
74     static void createMenuBar( MainInterface *mi, intf_thread_t *,
75                                bool, bool );
76
77     /* Menus */
78     static QMenu *FileMenu();
79     static QMenu *SDMenu( intf_thread_t * );
80     static QMenu *PlaylistMenu( MainInterface *, intf_thread_t *);
81     static QMenu *ToolsMenu( intf_thread_t *, MainInterface *, bool, bool with = true );
82     static QMenu *NavigMenu( intf_thread_t * , QMenu * );
83     static QMenu *VideoMenu( intf_thread_t * , QMenu * );
84     static QMenu *AudioMenu( intf_thread_t * , QMenu * );
85     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
86     static QMenu *HelpMenu();
87
88     /* Popups Menus */
89     static void AudioPopupMenu( intf_thread_t * );
90     static void VideoPopupMenu( intf_thread_t * );
91     static void MiscPopupMenu( intf_thread_t * );
92     static void PopupMenu( intf_thread_t *, bool );
93
94     /* Systray */
95     static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
96                                    bool b_force_visible = false);
97
98     /* Actions */
99     static void DoAction( intf_thread_t *, QObject * );
100 private:
101     /* Generic automenu methods */
102     static QMenu * Populate( intf_thread_t *, QMenu *current,
103                              vector<const char*>&, vector<int>&,
104                              bool append = false );
105
106     static void CreateAndConnect( QMenu *, const char *, QString, QString,
107                                   int, int, vlc_value_t, int, bool c = false );
108     static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
109     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
110 };
111
112 class MenuFunc : public QObject
113 {
114 Q_OBJECT
115
116 public:
117     MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
118     void doFunc( intf_thread_t *p_intf)
119     {
120         switch( id )
121         {
122         case 1: QVLCMenu::VideoMenu( p_intf, menu ); break;
123         case 2: QVLCMenu::AudioMenu( p_intf, menu ); break;
124         case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
125         case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
126         }
127     };
128     int id; QMenu *menu;
129 };
130
131 #endif