Commit dc185ad0 authored by Jean-Philippe Andre's avatar Jean-Philippe Andre

Qt: fix #2619 (prev/next/stop never greyed)

Don't mix booleans and strings (as non empty strings evaluate to true).
parent c7325f2f
...@@ -64,6 +64,9 @@ ...@@ -64,6 +64,9 @@
Just before one of those menus are aboutToShow(), they are rebuild. Just before one of those menus are aboutToShow(), they are rebuild.
*/ */
#define STATIC_ENTRY "__static__"
#define ENTRY_ALWAYS_ENABLED "__ignore__"
enum enum
{ {
ITEM_NORMAL, ITEM_NORMAL,
...@@ -102,7 +105,7 @@ void addDPStaticEntry( QMenu *menu, ...@@ -102,7 +105,7 @@ void addDPStaticEntry( QMenu *menu,
else else
action = menu->addAction( text, THEDP, member ); action = menu->addAction( text, THEDP, member );
} }
action->setData( true ); action->setData( STATIC_ENTRY );
} }
/*** /***
...@@ -112,7 +115,8 @@ void addMIMStaticEntry( intf_thread_t *p_intf, ...@@ -112,7 +115,8 @@ void addMIMStaticEntry( intf_thread_t *p_intf,
QMenu *menu, QMenu *menu,
const QString text, const QString text,
const char *icon, const char *icon,
const char *member ) const char *member,
bool bStatic = false )
{ {
QAction *action; QAction *action;
if( strlen( icon ) > 0 ) if( strlen( icon ) > 0 )
...@@ -124,7 +128,7 @@ void addMIMStaticEntry( intf_thread_t *p_intf, ...@@ -124,7 +128,7 @@ void addMIMStaticEntry( intf_thread_t *p_intf,
{ {
action = menu->addAction( text, THEMIM, member ); action = menu->addAction( text, THEMIM, member );
} }
action->setData( "ignore" ); action->setData( bStatic ? STATIC_ENTRY : ENTRY_ALWAYS_ENABLED );
} }
/** /**
...@@ -138,9 +142,10 @@ void EnableStaticEntries( QMenu *menu, bool enable = true ) ...@@ -138,9 +142,10 @@ void EnableStaticEntries( QMenu *menu, bool enable = true )
QList< QAction* > actions = menu->actions(); QList< QAction* > actions = menu->actions();
for( int i = 0; i < actions.size(); ++i ) for( int i = 0; i < actions.size(); ++i )
{ {
actions[i]->setEnabled( actions[i]->data().toString() == "ignore" || actions[i]->setEnabled( actions[i]->data().toString()
== ENTRY_ALWAYS_ENABLED ||
/* Be careful here, because data("string").toBool is true */ /* Be careful here, because data("string").toBool is true */
( enable && (actions[i]->data().toString() == "true" ) ) ); ( enable && (actions[i]->data().toString() == STATIC_ENTRY ) ) );
} }
} }
...@@ -156,7 +161,7 @@ int DeleteNonStaticEntries( QMenu *menu ) ...@@ -156,7 +161,7 @@ int DeleteNonStaticEntries( QMenu *menu )
QList< QAction* > actions = menu->actions(); QList< QAction* > actions = menu->actions();
for( int i = 0; i < actions.size(); ++i ) for( int i = 0; i < actions.size(); ++i )
{ {
if( !actions[i]->data().toBool() ) if( actions[i]->data().toString() != STATIC_ENTRY )
delete actions[i]; delete actions[i];
else else
i_ret++; i_ret++;
...@@ -496,13 +501,13 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current ) ...@@ -496,13 +501,13 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
QAction *action = current->addAction( qtr( "Increase Volume" ), QAction *action = current->addAction( qtr( "Increase Volume" ),
ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) ); ActionsManager::getInstance( p_intf ), SLOT( AudioUp() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
action = current->addAction( qtr( "Decrease Volume" ), action = current->addAction( qtr( "Decrease Volume" ),
ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) ); ActionsManager::getInstance( p_intf ), SLOT( AudioDown() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
action = current->addAction( qtr( "Mute" ), action = current->addAction( qtr( "Mute" ),
ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) ); ActionsManager::getInstance( p_intf ), SLOT( toggleMuteAudio() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
} }
p_input = THEMIM->getInput(); p_input = THEMIM->getInput();
...@@ -737,36 +742,36 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf ) ...@@ -737,36 +742,36 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(), action = menu->addAction( qtr( "&Faster" ), THEMIM->getIM(),
SLOT( faster() ) ); SLOT( faster() ) );
action->setIcon( QIcon( ":/faster") ); action->setIcon( QIcon( ":/faster") );
action->setData( true ); action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(), action = menu->addAction( qtr( "Faster (fine)" ), THEMIM->getIM(),
SLOT( littlefaster() ) ); SLOT( littlefaster() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(), action = menu->addAction( qtr( "N&ormal Speed" ), THEMIM->getIM(),
SLOT( normalRate() ) ); SLOT( normalRate() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(), action = menu->addAction( qtr( "Slower (fine)" ), THEMIM->getIM(),
SLOT( littleslower() ) ); SLOT( littleslower() ) );
action->setData( true ); action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(), action = menu->addAction( qtr( "Slo&wer" ), THEMIM->getIM(),
SLOT( slower() ) ); SLOT( slower() ) );
action->setIcon( QIcon( ":/slower") ); action->setIcon( QIcon( ":/slower") );
action->setData( true ); action->setData( STATIC_ENTRY );
menu->addSeparator(); menu->addSeparator();
action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(), action = menu->addAction( qtr( "&Jump Forward" ), THEMIM->getIM(),
SLOT( jumpFwd() ) ); SLOT( jumpFwd() ) );
action->setIcon( QIcon( ":/skip_fw") ); action->setIcon( QIcon( ":/skip_fw") );
action->setData( true ); action->setData( STATIC_ENTRY );
action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(), action = menu->addAction( qtr( "Jump Bac&kward" ), THEMIM->getIM(),
SLOT( jumpBwd() ) ); SLOT( jumpBwd() ) );
action->setIcon( QIcon( ":/skip_back") ); action->setIcon( QIcon( ":/skip_back") );
action->setData( true ); action->setData( STATIC_ENTRY );
addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"", addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
SLOT( gotoTimeDialog() ), "Ctrl+T" ); SLOT( gotoTimeDialog() ), "Ctrl+T" );
menu->addSeparator(); menu->addSeparator();
...@@ -776,13 +781,15 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf ) ...@@ -776,13 +781,15 @@ void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu, void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu,
intf_thread_t *p_intf ) intf_thread_t *p_intf )
{ {
addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/stop", SLOT( stop() ) ); addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ), ":/stop", SLOT( stop() ),
true );
/* Next / Previous */ /* Next / Previous */
bool bEnable = THEMIM->getInput() != NULL;
addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ), addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
":/previous", SLOT( prev() ) ); ":/previous", SLOT( prev() ), true );
addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ), addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
":/next", SLOT( next() ) ); ":/next", SLOT( next() ), true );
menu->addSeparator(); menu->addSeparator();
} }
......
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