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