Commit 1a2be0db authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt, menus: improve the NavigMenu entries.

parent 9f0375cd
...@@ -119,15 +119,17 @@ void addMIMStaticEntry( intf_thread_t *p_intf, ...@@ -119,15 +119,17 @@ void addMIMStaticEntry( intf_thread_t *p_intf,
const char *icon, const char *icon,
const char *member ) const char *member )
{ {
QAction *action;
if( strlen( icon ) > 0 ) if( strlen( icon ) > 0 )
{ {
QAction *action = menu->addAction( text, THEMIM, member ); action = menu->addAction( text, THEMIM, member );
action->setIcon( QIcon( icon ) ); action->setIcon( QIcon( icon ) );
} }
else else
{ {
menu->addAction( text, THEMIM, member ); menu->addAction( text, THEMIM, member );
} }
action->setData( "ignore" );
} }
/** /**
...@@ -141,9 +143,9 @@ void EnableStaticEntries( QMenu *menu, bool enable = true ) ...@@ -141,9 +143,9 @@ 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( enable && actions[i]->setEnabled( actions[i]->data().toString() == "ignore" ||
/* Be careful here, because data("string").toBool is true */ /* Be careful here, because data("string").toBool is true */
(actions[i]->data().toString() == "true" ) ); ( enable && (actions[i]->data().toString() == "true" ) ) );
} }
} }
...@@ -321,7 +323,6 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent ) ...@@ -321,7 +323,6 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
recentsMenu = new QMenu( qtr( "&Recent Media" ), menu ); recentsMenu = new QMenu( qtr( "&Recent Media" ), menu );
updateRecents( p_intf ); updateRecents( p_intf );
menu->addMenu( recentsMenu ); menu->addMenu( recentsMenu );
menu->addSeparator();
menu->addMenu( SDMenu( p_intf, menu ) ); menu->addMenu( SDMenu( p_intf, menu ) );
menu->addSeparator(); menu->addSeparator();
...@@ -496,8 +497,8 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current ) ...@@ -496,8 +497,8 @@ QMenu *QVLCMenu::AudioMenu( intf_thread_t *p_intf, QMenu * current )
if( p_input ) if( p_input )
vlc_object_hold( p_input ); vlc_object_hold( p_input );
p_aout = THEMIM->getAout(); p_aout = THEMIM->getAout();
AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
EnableStaticEntries( current, ( p_aout != NULL ) ); EnableStaticEntries( current, ( p_aout != NULL ) );
AudioAutoMenuBuilder( p_aout, p_input, objects, varnames );
if( p_aout ) if( p_aout )
{ {
vlc_object_release( p_aout ); vlc_object_release( p_aout );
...@@ -560,11 +561,10 @@ QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current ) ...@@ -560,11 +561,10 @@ QMenu *QVLCMenu::VideoMenu( intf_thread_t *p_intf, QMenu *current )
p_vout = THEMIM->getVout(); p_vout = THEMIM->getVout();
VideoAutoMenuBuilder( p_vout, p_input, objects, varnames ); VideoAutoMenuBuilder( p_vout, p_input, objects, varnames );
EnableStaticEntries( current, ( p_vout != NULL ) );
if( p_vout ) if( p_vout )
{
vlc_object_release( p_vout ); vlc_object_release( p_vout );
}
if( p_input ) if( p_input )
vlc_object_release( p_input ); vlc_object_release( p_input );
...@@ -597,8 +597,8 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu ) ...@@ -597,8 +597,8 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *menu )
ACT_ADDMENU( menu, "program", qtr( "&Program" ) ); ACT_ADDMENU( menu, "program", qtr( "&Program" ) );
menu->addSeparator(); menu->addSeparator();
PopupMenuControlEntries( menu, p_intf );//, THEMIM->getInput() );
PopupMenuPlaylistControlEntries( menu, p_intf ); PopupMenuPlaylistControlEntries( menu, p_intf );
PopupMenuControlEntries( menu, p_intf );
return menu; return menu;
} }
...@@ -628,6 +628,7 @@ QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu ) ...@@ -628,6 +628,7 @@ QMenu *QVLCMenu::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu )
if( p_object ) if( p_object )
vlc_object_release( p_object ); vlc_object_release( p_object );
EnableStaticEntries( menu, (p_object != NULL ) );
return Populate( p_intf, menu, varnames, objects ); return Populate( p_intf, menu, varnames, objects );
} }
...@@ -643,6 +644,7 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent ) ...@@ -643,6 +644,7 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
{ {
QMenu *menu = new QMenu( parent ); QMenu *menu = new QMenu( parent );
menu->setTitle( qtr( I_PL_SD ) ); menu->setTitle( qtr( I_PL_SD ) );
char **ppsz_longnames; char **ppsz_longnames;
char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames ); char **ppsz_names = vlc_sd_GetNames( &ppsz_longnames );
if( !ppsz_names ) if( !ppsz_names )
...@@ -655,10 +657,11 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent ) ...@@ -655,10 +657,11 @@ QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf, QWidget *parent )
a->setCheckable( true ); a->setCheckable( true );
if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) ) if( playlist_IsServicesDiscoveryLoaded( THEPL, *ppsz_name ) )
a->setChecked( true ); a->setChecked( true );
CONNECT( a , triggered(), THEDP->SDMapper, map() ); CONNECT( a, triggered(), THEDP->SDMapper, map() );
THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) ); THEDP->SDMapper->setMapping( a, QString( *ppsz_name ) );
menu->addAction( a ); menu->addAction( a );
/* Special case for podcast */
if( !strcmp( *ppsz_name, "podcast" ) ) if( !strcmp( *ppsz_name, "podcast" ) )
{ {
QAction *b = new QAction( qtr( "Configure podcasts..." ), menu ); QAction *b = new QAction( qtr( "Configure podcasts..." ), menu );
...@@ -723,47 +726,58 @@ void QVLCMenu::PopupPlayEntries( QMenu *menu, ...@@ -723,47 +726,58 @@ void QVLCMenu::PopupPlayEntries( QMenu *menu,
} }
else else
{ {
addMIMStaticEntry( p_intf, menu, qtr( "Pause" ), addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
":/pause", SLOT( togglePlayPause() ) ); ":/pause", SLOT( togglePlayPause() ) );
} }
} }
void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf ) void QVLCMenu::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf )
{ {
QAction *action; QAction *action;
/* Stop */
addMIMStaticEntry( p_intf, menu, qtr( "Stop" ), ":/stop", SLOT( stop() ) );
/* Faster/Slower */ /* Faster/Slower */
action = menu->addAction( qtr( "Faster" ), THEMIM->getIM(), SLOT( faster() ) ); action = menu->addAction( qtr( "Faster" ), THEMIM->getIM(),
SLOT( faster() ) );
action->setIcon( QIcon( ":/faster") ); action->setIcon( QIcon( ":/faster") );
menu->addAction( qtr( "Normal Speed" ), THEMIM->getIM(), SLOT( normalRate() ) ); action->setData( true );
action = menu->addAction( qtr( "Slower" ), THEMIM->getIM(), SLOT( slower() ) );
action = menu->addAction( qtr( "Normal Speed" ), THEMIM->getIM(),
SLOT( normalRate() ) );
action->setData( true );
action = menu->addAction( qtr( "Slower" ), THEMIM->getIM(),
SLOT( slower() ) );
action->setIcon( QIcon( ":/slower") ); action->setIcon( QIcon( ":/slower") );
action->setData( true );
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 = menu->addAction( qtr( "Jump Backward" ), THEMIM->getIM(), action = menu->addAction( qtr( "Jump Backward" ), THEMIM->getIM(),
SLOT( jumpBwd() ) ); SLOT( jumpBwd() ) );
action->setIcon( QIcon( ":/skip_back") ); action->setIcon( QIcon( ":/skip_back") );
action->setData( true );
addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"",
SLOT( gotoTimeDialog() ), "Ctrl+T" );
menu->addSeparator();
} }
void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu, void QVLCMenu::PopupMenuPlaylistControlEntries( QMenu *menu,
intf_thread_t *p_intf ) intf_thread_t *p_intf )
{ {
addDPStaticEntry( menu, qtr( I_MENU_GOTOTIME ),"", addMIMStaticEntry( p_intf, menu, qtr( "Stop" ), ":/stop", SLOT( stop() ) );
SLOT( gotoTimeDialog() ), "Ctrl+T" );
menu->addSeparator();
/* Next / Previous */ /* Next / Previous */
addMIMStaticEntry( p_intf, menu, qtr( "Previous" ), addMIMStaticEntry( p_intf, menu, qtr( "Previous" ),
":/previous", SLOT( prev() ) ); ":/previous", SLOT( prev() ) );
addMIMStaticEntry( p_intf, menu, qtr( "Next" ), addMIMStaticEntry( p_intf, menu, qtr( "Next" ),
":/next", SLOT( next() ) ); ":/next", SLOT( next() ) );
menu->addSeparator();
} }
void QVLCMenu::PopupMenuStaticEntries( QMenu *menu ) void QVLCMenu::PopupMenuStaticEntries( QMenu *menu )
...@@ -845,10 +859,11 @@ void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf ) ...@@ -845,10 +859,11 @@ void QVLCMenu::MiscPopupMenu( intf_thread_t *p_intf )
Populate( p_intf, menu, varnames, objects ); Populate( p_intf, menu, varnames, objects );
menu->addSeparator(); menu->addSeparator();
PopupMenuControlEntries( menu, p_intf ); //, p_input ); PopupPlayEntries( menu, p_intf, p_input );
PopupMenuPlaylistControlEntries( menu, p_intf);
menu->addSeparator(); menu->addSeparator();
PopupMenuPlaylistControlEntries( menu, p_intf); //, p_input ); PopupMenuControlEntries( menu, p_intf );
menu->addSeparator(); menu->addSeparator();
PopupMenuStaticEntries( menu ); PopupMenuStaticEntries( menu );
...@@ -882,7 +897,8 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show ) ...@@ -882,7 +897,8 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
POPUP_BOILERPLATE; POPUP_BOILERPLATE;
PopupMenuControlEntries( menu, p_intf ); //, p_input ); PopupPlayEntries( menu, p_intf, p_input );
PopupMenuPlaylistControlEntries( menu, p_intf );
menu->addSeparator(); menu->addSeparator();
if( p_input ) if( p_input )
...@@ -1003,8 +1019,9 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, ...@@ -1003,8 +1019,9 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi,
} }
sysMenu->addSeparator(); sysMenu->addSeparator();
PopupMenuControlEntries( sysMenu, p_intf);//, p_input ); PopupPlayEntries( sysMenu, p_intf, p_input );
PopupMenuPlaylistControlEntries( sysMenu, p_intf);//, p_input ); PopupMenuPlaylistControlEntries( sysMenu, p_intf);
PopupMenuControlEntries( sysMenu, p_intf);
sysMenu->addSeparator(); sysMenu->addSeparator();
addDPStaticEntry( sysMenu, qtr( "&Open Media" ), addDPStaticEntry( sysMenu, qtr( "&Open Media" ),
......
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