1 /*****************************************************************************
2 * menus.hpp : Menus handling
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
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.
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.
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 *****************************************************************************/
34 class MenuItemData
: public QObject
39 MenuItemData( QObject
* parent
, vlc_object_t
*_p_obj
, int _i_type
,
40 vlc_value_t _val
, const char *_var
) : QObject( parent
)
44 vlc_object_hold( p_obj
);
47 psz_var
= strdup( _var
);
49 virtual ~MenuItemData()
52 if( ( i_val_type
& VLC_VAR_TYPE
) == VLC_VAR_STRING
)
53 free( val
.psz_string
);
55 vlc_object_release( p_obj
);
66 class VLCMenuBar
: public QObject
69 friend class MenuFunc
;
72 /* Main bar creation */
73 static void createMenuBar( MainInterface
*mi
, intf_thread_t
* );
76 static QMenu
* PopupMenu( intf_thread_t
*, bool );
77 static QMenu
* AudioPopupMenu( intf_thread_t
*, bool );
78 static QMenu
* VideoPopupMenu( intf_thread_t
*, bool );
79 static QMenu
* MiscPopupMenu( intf_thread_t
*, bool );
82 static void updateSystrayMenu( MainInterface
*, intf_thread_t
*,
83 bool b_force_visible
= false);
86 static void DoAction( QObject
* );
89 ACTION_ALWAYS_ENABLED
= 0x1,
90 ACTION_MANAGED
= 0x2, /* managed using EnableStatic(bool)? */
91 ACTION_NO_CLEANUP
= 0x4,
92 ACTION_STATIC
= 0x6, /* legacy shortcut */
93 ACTION_DELETE_ON_REBUILD
= 0x8
95 Q_DECLARE_FLAGS(actionflags
, actionflag
)
97 static QMenu
*rendererMenu
;
98 static QActionGroup
*rendererGroup
;
102 static QMenu
*FileMenu( intf_thread_t
*, QWidget
*, MainInterface
* mi
= NULL
);
104 static QMenu
*ToolsMenu( intf_thread_t
*, QMenu
* );
105 static QMenu
*ToolsMenu( intf_thread_t
* p_intf
, QWidget
*parent
)
106 { return ToolsMenu( p_intf
, new QMenu( parent
) ); }
108 static QMenu
*ViewMenu( intf_thread_t
*, QMenu
*, MainInterface
* mi
= NULL
);
110 static QMenu
*InterfacesMenu( intf_thread_t
*p_intf
, QMenu
* );
111 static void ExtensionsMenu( intf_thread_t
*p_intf
, QMenu
* );
113 static QMenu
*NavigMenu( intf_thread_t
*, QMenu
* );
114 static QMenu
*NavigMenu( intf_thread_t
*p_intf
, QWidget
*parent
) {
115 return NavigMenu( p_intf
, new QMenu( parent
) );
117 static QMenu
*RebuildNavigMenu( intf_thread_t
*, QMenu
*, bool b_keep
= false );
119 static QMenu
*VideoMenu( intf_thread_t
*, QMenu
* );
120 static QMenu
*VideoMenu( intf_thread_t
*p_intf
, QWidget
*parent
) {
121 return VideoMenu( p_intf
, new QMenu( parent
) );
123 static QMenu
*SubtitleMenu( intf_thread_t
*, QMenu
*current
, bool b_popup
= false );
124 static QMenu
*SubtitleMenu( intf_thread_t
*p_intf
, QWidget
*parent
) {
125 return SubtitleMenu( p_intf
, new QMenu( parent
) );
128 static QMenu
*AudioMenu( intf_thread_t
*, QMenu
* );
129 static QMenu
*AudioMenu( intf_thread_t
*p_intf
, QWidget
*parent
) {
130 return AudioMenu( p_intf
, new QMenu( parent
) );
133 static QMenu
*HelpMenu( QWidget
* );
134 static QMenu
*RendererMenu(intf_thread_t
*p_intf
, QMenu
*menu
= NULL
);
137 static void PopupMenuStaticEntries( QMenu
*menu
);
138 static void PopupMenuPlaylistEntries( QMenu
*menu
, intf_thread_t
*p_intf
,
139 input_thread_t
*p_input
);
140 static void PopupMenuPlaylistControlEntries( QMenu
*menu
, intf_thread_t
*p_intf
);
141 static void PopupMenuControlEntries( QMenu
*menu
, intf_thread_t
*p_intf
, bool b
= true );
143 /* Generic automenu methods */
144 static QMenu
* Populate( QMenu
*current
,
145 QVector
<const char*>&, QVector
<vlc_object_t
*>& );
147 static void CreateAndConnect( QMenu
*, const char *, const QString
&,
148 const QString
&, int, vlc_object_t
*,
149 vlc_value_t
, int, bool c
= false );
150 static void UpdateItem( QMenu
*, const char *, vlc_object_t
*, bool );
151 static int CreateChoicesMenu( QMenu
*,const char *, vlc_object_t
* );
152 static void EnableStaticEntries( QMenu
*, bool );
155 static QMenu
*recentsMenu
, *audioDeviceMenu
;
157 static void updateAudioDevice( intf_thread_t
*, audio_output_t
*, QMenu
* );
160 static void updateRecents( intf_thread_t
* );
162 Q_DECLARE_OPERATORS_FOR_FLAGS(VLCMenuBar::actionflags
)
164 class MenuFunc
: public QObject
169 MenuFunc( QMenu
*_menu
, int _id
) : QObject( (QObject
*)_menu
),
170 menu( _menu
), id( _id
){}
172 void doFunc( intf_thread_t
*p_intf
)
176 case 1: VLCMenuBar::AudioMenu( p_intf
, menu
); break;
177 case 2: VLCMenuBar::VideoMenu( p_intf
, menu
); break;
178 case 3: VLCMenuBar::RebuildNavigMenu( p_intf
, menu
); break;
179 case 4: VLCMenuBar::ViewMenu( p_intf
, menu
); break;
180 case 5: VLCMenuBar::SubtitleMenu( p_intf
, menu
); break;