]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.hpp
* compiles-but-untested complete implementation of menus and popups
[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 #include <QObject>
28 #include <vector>
29
30 using namespace std;
31
32 class QMenu;
33 class QMenuBar;
34
35 class MenuItemData : public QObject
36 {
37 public:
38     MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
39     {
40         i_object_id = i_id;
41         i_val_type = _i_type;
42         val = _val;
43         psz_var = strdup( _var );
44     }
45     virtual ~MenuItemData()
46     {
47         if( psz_var ) free( psz_var );
48         if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
49             && val.psz_string ) free( val.psz_string );
50     }
51     int i_object_id;
52     int i_val_type;
53     vlc_value_t val;
54     char *psz_var;
55 };
56
57 class QVLCMenu : public QObject
58 {
59     Q_OBJECT;
60 public:
61     static void createMenuBar( QMenuBar *, intf_thread_t * ); 
62
63     /* Menus */
64     static QMenu *FileMenu();
65     static QMenu *ToolsMenu( intf_thread_t *, bool with_intf = true );
66     static QMenu *NavigMenu( intf_thread_t * , QMenu * );
67     static QMenu *VideoMenu( intf_thread_t * , QMenu * );
68     static QMenu *AudioMenu( intf_thread_t * , QMenu * );
69     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
70
71     /* Popups */
72     static void AudioPopupMenu( intf_thread_t * );
73     static void VideoPopupMenu( intf_thread_t * );
74     static void MiscPopupMenu( intf_thread_t * );
75     static void PopupMenu( intf_thread_t * );
76
77     static void DoAction( intf_thread_t *, QObject * );
78 private:
79     /* Generic automenu methods */
80     static QMenu * Populate( intf_thread_t *, QMenu *current,
81                              vector<const char*>&, vector<int>&,
82                              bool append = false );
83
84     static void CreateAndConnect( QMenu *, const char *, QString, QString,
85                                   int, int, vlc_value_t, int, bool c = false );
86     static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
87     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
88
89 };
90
91 class MenuFunc : public QObject
92 {
93 public:
94     MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
95     void doFunc( intf_thread_t *p_intf)
96     {
97         switch( id )
98         {
99         case 1:
100             QVLCMenu::VideoMenu( p_intf, menu ); break;
101         case 2:
102             QVLCMenu::AudioMenu( p_intf, menu ); break;
103         case 3:
104             QVLCMenu::NavigMenu( p_intf, menu ); break;
105         case 4:
106             QVLCMenu::InterfacesMenu( p_intf, menu ); break;
107         }
108     };
109     int id; QMenu *menu;
110 };
111
112 #endif