Commit 895c05d7 authored by Jean-Philippe Andre's avatar Jean-Philippe Andre Committed by Jean-Baptiste Kempf

Qt menus: enable/disable correctly static entries

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 33aa26b1
...@@ -63,20 +63,23 @@ void addDPStaticEntry( QMenu *menu, ...@@ -63,20 +63,23 @@ void addDPStaticEntry( QMenu *menu,
const char *member, const char *member,
const char *shortcut ) const char *shortcut )
{ {
QAction *action = NULL;
if( !EMPTY_STR( icon ) > 0 ) if( !EMPTY_STR( icon ) > 0 )
{ {
if( !EMPTY_STR( shortcut ) > 0 ) if( !EMPTY_STR( shortcut ) > 0 )
menu->addAction( QIcon( icon ), text, THEDP, member, qtr( shortcut ) ); action = menu->addAction( QIcon( icon ), text, THEDP,
member, qtr( shortcut ) );
else else
menu->addAction( QIcon( icon ), text, THEDP, member ); action = menu->addAction( QIcon( icon ), text, THEDP, member );
} }
else else
{ {
if( !EMPTY_STR( shortcut ) > 0 ) if( !EMPTY_STR( shortcut ) > 0 )
menu->addAction( text, THEDP, member, qtr( shortcut ) ); action = menu->addAction( text, THEDP, member, qtr( shortcut ) );
else else
menu->addAction( text, THEDP, member ); action = menu->addAction( text, THEDP, member );
} }
action->setData( "_static_" );
} }
void addMIMStaticEntry( intf_thread_t *p_intf, void addMIMStaticEntry( intf_thread_t *p_intf,
...@@ -97,6 +100,19 @@ void addMIMStaticEntry( intf_thread_t *p_intf, ...@@ -97,6 +100,19 @@ void addMIMStaticEntry( intf_thread_t *p_intf,
} }
} }
void EnableDPStaticEntries( QMenu *menu, bool enable = true )
{
if( !menu )
return;
QAction *action;
Q_FOREACH( action, menu->actions() )
{
if( action->data().toString() == "_static_" )
action->setEnabled( enable );
}
}
/***************************************************************************** /*****************************************************************************
* Definitions of variables for the dynamic menus * Definitions of variables for the dynamic menus
*****************************************************************************/ *****************************************************************************/
...@@ -476,6 +492,14 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu ) ...@@ -476,6 +492,14 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
vector<int> objects; vector<int> objects;
vector<const char *> varnames; vector<const char *> varnames;
if( !menu )
{
menu = new QMenu();
addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ), "","",
SLOT( gotoTimeDialog() ), "Ctrl+T" );
menu->addSeparator();
}
p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_INPUT, p_object = ( vlc_object_t * )vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE ); FIND_ANYWHERE );
InputAutoMenuBuilder( p_object, objects, varnames ); InputAutoMenuBuilder( p_object, objects, varnames );
...@@ -483,13 +507,12 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu ) ...@@ -483,13 +507,12 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
PUSH_VAR( "next-title" ); PUSH_VAR( "next-title" );
PUSH_VAR( "prev-chapter" ); PUSH_VAR( "prev-chapter" );
PUSH_VAR( "next-chapter" ); PUSH_VAR( "next-chapter" );
EnableDPStaticEntries( menu, ( p_object != NULL ) );
if( p_object ) if( p_object )
{
vlc_object_release( p_object ); vlc_object_release( p_object );
QMenu *navMenu = new QMenu( menu ); }
addDPStaticEntry( navMenu, qtr( I_MENU_GOTOTIME ), "","", return Populate( p_intf, menu, varnames, objects, true );
SLOT( gotoTimeDialog() ), "Ctrl+T" );
navMenu->addSeparator();
return Populate( p_intf, navMenu, varnames, objects, true );
} }
/** /**
...@@ -792,9 +815,11 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, ...@@ -792,9 +815,11 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
if( !menu ) if( !menu )
menu = new QMenu(); menu = new QMenu();
/* Disable all non static entries */
QAction *p_action; QAction *p_action;
Q_FOREACH( p_action, menu->actions() ) Q_FOREACH( p_action, menu->actions() )
{ {
if( p_action->data().toString() != "_static_" )
p_action->setEnabled( false ); p_action->setEnabled( false );
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment