Commit f188888c authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: menu simplification

(cherry picked from commit 3f5029f86312e70edb86252dabcaae3ba6a71cc5)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent f61ba3e2
...@@ -733,8 +733,7 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_ ...@@ -733,8 +733,7 @@ QMenu *VLCMenuBar::RebuildNavigMenu( intf_thread_t *p_intf, QMenu *menu, bool b_
delete actions[i]; delete actions[i];
} }
PopupPlayEntries( menu, p_intf, p_object ); PopupMenuPlaylistEntries( menu, p_intf, p_object );
PopupMenuPlaylistControlEntries( menu, p_intf );
/* */ /* */
EnableStaticEntries( menu, (p_object != NULL ) ); EnableStaticEntries( menu, (p_object != NULL ) );
...@@ -776,7 +775,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent ) ...@@ -776,7 +775,7 @@ QMenu *VLCMenuBar::HelpMenu( QWidget *parent )
Populate( p_intf, menu, varnames, objects ); \ Populate( p_intf, menu, varnames, objects ); \
menu->popup( QCursor::pos() ); \ menu->popup( QCursor::pos() ); \
void VLCMenuBar::PopupPlayEntries( QMenu *menu, void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
intf_thread_t *p_intf, intf_thread_t *p_intf,
input_thread_t *p_input ) input_thread_t *p_input )
{ {
...@@ -793,9 +792,31 @@ void VLCMenuBar::PopupPlayEntries( QMenu *menu, ...@@ -793,9 +792,31 @@ void VLCMenuBar::PopupPlayEntries( QMenu *menu,
} }
else else
{ {
addMIMStaticEntry( p_intf, menu, qtr( "Pause" ), addMIMStaticEntry( p_intf, menu, qtr( "Pause" ),
":/menu/pause", SLOT( togglePlayPause() ) ); ":/menu/pause", SLOT( togglePlayPause() ) );
} }
/* Stop */
action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ),
":/menu/stop", SLOT( stop() ), true );
if( !p_input )
action->setEnabled( false );
/* Next / Previous */
bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
":/menu/previous", SLOT( prev() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
":/menu/next", SLOT( next() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
menu->addSeparator();
} }
void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf, void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
...@@ -863,33 +884,6 @@ void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf, ...@@ -863,33 +884,6 @@ void VLCMenuBar::PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf,
menu->addSeparator(); menu->addSeparator();
} }
void VLCMenuBar::PopupMenuPlaylistControlEntries( QMenu *menu,
intf_thread_t *p_intf )
{
bool bEnable = THEMIM->getInput() != NULL;
bool bPlaylistEmpty = THEMIM->hasEmptyPlaylist();
QAction *action = addMIMStaticEntry( p_intf, menu, qtr( "&Stop" ),
":/menu/stop", SLOT( stop() ), true );
/* Disable Stop in the right-click popup menu */
if( !bEnable )
action->setEnabled( false );
/* Next / Previous */
action = addMIMStaticEntry( p_intf, menu, qtr( "Pre&vious" ),
":/menu/previous", SLOT( prev() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
action = addMIMStaticEntry( p_intf, menu, qtr( "Ne&xt" ),
":/menu/next", SLOT( next() ), true );
action->setEnabled( !bPlaylistEmpty );
action->setData( ACTION_NO_CLEANUP );
CONNECT( THEMIM, playlistNotEmpty(bool), action, setEnabled(bool) );
menu->addSeparator();
}
void VLCMenuBar::PopupMenuStaticEntries( QMenu *menu ) void VLCMenuBar::PopupMenuStaticEntries( QMenu *menu )
{ {
QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu ); QMenu *openmenu = new QMenu( qtr( "Open Media" ), menu );
...@@ -962,8 +956,7 @@ void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show ) ...@@ -962,8 +956,7 @@ void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
Populate( p_intf, menu, varnames, objects ); Populate( p_intf, menu, varnames, objects );
menu->addSeparator(); menu->addSeparator();
PopupPlayEntries( menu, p_intf, p_input ); PopupMenuPlaylistEntries( menu, p_intf, p_input );
PopupMenuPlaylistControlEntries( menu, p_intf);
menu->addSeparator(); menu->addSeparator();
PopupMenuControlEntries( menu, p_intf ); PopupMenuControlEntries( menu, p_intf );
...@@ -985,8 +978,7 @@ void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show ) ...@@ -985,8 +978,7 @@ void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
bool b_isFullscreen = false; bool b_isFullscreen = false;
MainInterface *mi = p_intf->p_sys->p_mi; MainInterface *mi = p_intf->p_sys->p_mi;
PopupPlayEntries( menu, p_intf, p_input ); PopupMenuPlaylistEntries( menu, p_intf, p_input );
PopupMenuPlaylistControlEntries( menu, p_intf );
menu->addSeparator(); menu->addSeparator();
if( p_input ) if( p_input )
...@@ -1130,8 +1122,7 @@ void VLCMenuBar::updateSystrayMenu( MainInterface *mi, ...@@ -1130,8 +1122,7 @@ void VLCMenuBar::updateSystrayMenu( MainInterface *mi,
sysMenu->addSeparator(); sysMenu->addSeparator();
#endif #endif
PopupPlayEntries( sysMenu, p_intf, p_input ); PopupMenuPlaylistEntries( sysMenu, p_intf, p_input );
PopupMenuPlaylistControlEntries( sysMenu, p_intf);
PopupMenuControlEntries( sysMenu, p_intf, false ); PopupMenuControlEntries( sysMenu, p_intf, false );
VolumeEntries( p_intf, sysMenu ); VolumeEntries( p_intf, sysMenu );
......
...@@ -131,10 +131,10 @@ private: ...@@ -131,10 +131,10 @@ private:
/* Popups Menus */ /* Popups Menus */
static void PopupMenuStaticEntries( QMenu *menu ); static void PopupMenuStaticEntries( QMenu *menu );
static void PopupPlayEntries( QMenu *menu, intf_thread_t *p_intf, static void PopupMenuPlaylistEntries( QMenu *menu, intf_thread_t *p_intf,
input_thread_t *p_input ); input_thread_t *p_input );
static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf, bool b = true );
static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf ); static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf );
static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf, bool b = true );
/* Generic automenu methods */ /* Generic automenu methods */
static QMenu * Populate( intf_thread_t *, QMenu *current, static QMenu * Populate( intf_thread_t *, QMenu *current,
......
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