QAction *action;
QMenu *menu;
+ MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
+ assert( mi );
+
if( !current )
{
- menu = new QMenu( qtr( "&View" ) );
+ menu = new QMenu( qtr( "&View" ), mi );
}
else
{
menu = current;
- menu->clear();
+ //menu->clear();
+ //HACK menu->clear() does not delete submenus
+ QList<QAction*> actions = menu->actions();
+ foreach( QAction *a, actions )
+ {
+ QMenu *m = a->menu();
+ if( a->parent() == menu ) delete a;
+ else menu->removeAction( a );
+ if( m && m->parent() == menu ) delete m;
+ }
}
- MainInterface *mi = _mi ? _mi : p_intf->p_sys->p_mi;
- assert( mi );
-
menu->addAction( QIcon( ":/menu/playlist_menu" ),
qtr( "Play&list" ), mi,
SLOT( togglePlaylist() ), qtr( "Ctrl+L" ) );
* Popup menus - Right Click menus *
*****************************************************************************/
#define POPUP_BOILERPLATE \
+ static QMenu* menu = NULL; \
+ delete menu; menu = NULL; \
+ if( !show ) \
+ return; \
unsigned int i_last_separator = 0; \
vector<vlc_object_t *> objects; \
vector<const char *> varnames; \
input_thread_t *p_input = THEMIM->getInput();
#define CREATE_POPUP \
+ menu = new QMenu(); \
Populate( p_intf, menu, varnames, objects ); \
- p_intf->p_sys->p_popup_menu = menu; \
menu->popup( QCursor::pos() ); \
- p_intf->p_sys->p_popup_menu = NULL; \
i_last_separator = 0;
void QVLCMenu::PopupPlayEntries( QMenu *menu,
}
/* Video Tracks and Subtitles tracks */
-void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf )
+void QVLCMenu::VideoPopupMenu( intf_thread_t *p_intf, bool show )
{
- POPUP_BOILERPLATE;
+ POPUP_BOILERPLATE
if( p_input )
{
vout_thread_t *p_vout = THEMIM->getVout();
vlc_object_release( p_vout );
}
}
- QMenu *menu = new QMenu();
- CREATE_POPUP;
+ CREATE_POPUP
}
/* Audio Tracks */
-void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf )
+void QVLCMenu::AudioPopupMenu( intf_thread_t *p_intf, bool show )
{
- POPUP_BOILERPLATE;
+ POPUP_BOILERPLATE
if( p_input )
{
aout_instance_t *p_aout = THEMIM->getAout();
if( p_aout )
vlc_object_release( p_aout );
}
- QMenu *menu = new QMenu();
- CREATE_POPUP;
+ CREATE_POPUP
}
/* Navigation stuff, and general menus ( open ), used only for skins */
-void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
+void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf, bool show )
{
- POPUP_BOILERPLATE;
+ POPUP_BOILERPLATE
if( p_input )
{
PUSH_SEPARATOR;
}
- QMenu *menu = new QMenu();
+ menu = new QMenu();
Populate( p_intf, menu, varnames, objects );
menu->addSeparator();
menu->addSeparator();
PopupMenuStaticEntries( menu );
- p_intf->p_sys->p_popup_menu = menu;
menu->popup( QCursor::pos() );
- p_intf->p_sys->p_popup_menu = NULL;
}
/* Main Menu that sticks everything together */
void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
{
- /* Delete old popup if there is one */
- delete p_intf->p_sys->p_popup_menu;
-
- if( !show )
- {
- p_intf->p_sys->p_popup_menu = NULL;
- return;
- }
+ POPUP_BOILERPLATE
/* */
- QMenu *menu = new QMenu();
+ menu = new QMenu( );
QAction *action;
bool b_isFullscreen = false;
MainInterface *mi = p_intf->p_sys->p_mi;
- POPUP_BOILERPLATE;
-
PopupPlayEntries( menu, p_intf, p_input );
PopupMenuPlaylistControlEntries( menu, p_intf );
menu->addSeparator();
msg_Warn( p_intf, "could not find parent interface" );
}
else
- menu->addMenu( ViewMenu( p_intf, (QMenu *)NULL ) );
+ {
+ QMenu *viewmenu = menu->addMenu( qtr( "V&iew" ) );
+ ViewMenu( p_intf, viewmenu );
+ }
menu->addMenu( submenu );
}
/* Static entries for ending, like open */
PopupMenuStaticEntries( menu );
- p_intf->p_sys->p_popup_menu = menu;
- p_intf->p_sys->p_popup_menu->popup( QCursor::pos() );
+ menu->popup( QCursor::pos() );
}
#undef ACT_ADD
#undef ACT_ADDMENU
#undef ACT_ADDCHECK
+#undef CREATE_POPUP
+#undef POPUP_BOILERPLATE
+
#ifndef HAVE_MAEMO
/************************************************************************
* Systray Menu *
intf_thread_t *p_intf,
bool b_force_visible )
{
- POPUP_BOILERPLATE;
+ unsigned int i_last_separator = 0;
+ vector<vlc_object_t *> objects;
+ vector<const char *> varnames;
+ input_thread_t *p_input = THEMIM->getInput();
/* Get the systray menu and clean it */
QMenu *sysMenu = mi->getSysTrayMenu();
}
#endif
-#undef CREATE_POPUP
-#undef POPUP_BOILERPLATE
#undef PUSH_VAR
#undef PUSH_SEPARATOR
action->setChecked( checked );
- MenuItemData *itemData = new MenuItemData( THEDP->menusMapper, p_obj, i_val_type,
- val, psz_var );
+ MenuItemData *itemData = qFindChild<MenuItemData*>( action, QString() );
+ delete itemData;
+ itemData = new MenuItemData( action, p_obj, i_val_type, val, psz_var );
/* remove previous signal-slot connection(s) if any */
action->disconnect( );