]> git.sesse.net Git - vlc/blob - modules/gui/qt4/menus.hpp
Qt4 - SysTrayIcon: change the previous commit after some remarks on IRC and fix the...
[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 class QSystemTrayIcon;
35
36 class MenuItemData : public QObject
37 {
38
39 Q_OBJECT
40
41 public:
42     MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
43     {
44         i_object_id = i_id;
45         i_val_type = _i_type;
46         val = _val;
47         psz_var = strdup( _var );
48     }
49     virtual ~MenuItemData()
50     {
51         if( psz_var ) free( psz_var );
52         if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
53             && val.psz_string ) free( val.psz_string );
54     }
55     int i_object_id;
56     int i_val_type;
57     vlc_value_t val;
58     char *psz_var;
59 };
60
61 class QVLCMenu : public QObject
62 {
63     Q_OBJECT;
64 public:
65     static void createMenuBar( MainInterface *mi, intf_thread_t *,
66                                bool, bool, bool );
67
68     /* Menus */
69     static QMenu *FileMenu();
70     static QMenu *SDMenu( intf_thread_t * );
71     static QMenu *PlaylistMenu( MainInterface *, intf_thread_t *);
72     static QMenu *ToolsMenu( intf_thread_t *, MainInterface *, bool, bool,
73                              bool with = true );
74     static QMenu *NavigMenu( intf_thread_t * , QMenu * );
75     static QMenu *VideoMenu( intf_thread_t * , QMenu * );
76     static QMenu *AudioMenu( intf_thread_t * , QMenu * );
77     static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
78     static QMenu *HelpMenu();
79
80     /* Popups Menus */
81     static void AudioPopupMenu( intf_thread_t * );
82     static void VideoPopupMenu( intf_thread_t * );
83     static void MiscPopupMenu( intf_thread_t * );
84     static void PopupMenu( intf_thread_t *, bool );
85
86     /* Systray */
87     static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
88                                    bool b_force_visible = false);
89
90     /* Actions */
91     static void DoAction( intf_thread_t *, QObject * );
92 private:
93     /* Generic automenu methods */
94     static QMenu * Populate( intf_thread_t *, QMenu *current,
95                              vector<const char*>&, vector<int>&,
96                              bool append = false );
97
98     static void CreateAndConnect( QMenu *, const char *, QString, QString,
99                                   int, int, vlc_value_t, int, bool c = false );
100     static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
101     static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
102 };
103
104 class MenuFunc : public QObject
105 {
106 Q_OBJECT
107
108 public:
109     MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
110     void doFunc( intf_thread_t *p_intf)
111     {
112         switch( id )
113         {
114         case 1: QVLCMenu::VideoMenu( p_intf, menu ); break;
115         case 2: QVLCMenu::AudioMenu( p_intf, menu ); break;
116         case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
117         case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
118         }
119     };
120     int id; QMenu *menu;
121 };
122
123 #endif