Commit 67c51e4b authored by Jean-Philippe André's avatar Jean-Philippe André

Qt/Menu: ViewMenu is now dynamic (uses aboutToShow)

parent 1ce616c7
......@@ -294,7 +294,7 @@ void QVLCMenu::createMenuBar( MainInterface *mi,
BAR_DADD( VideoMenu( p_intf, bar ), qtr( "&Video" ), 2 );
BAR_ADD( ToolsMenu( bar ), qtr( "&Tools" ) );
BAR_ADD( ViewMenu( p_intf, mi ), qtr( "V&iew" ) );
BAR_ADD( ViewMenu( p_intf, bar ), qtr( "V&iew" ) );
BAR_ADD( HelpMenu( bar ), qtr( "&Help" ) );
}
#undef BAR_ADD
......@@ -397,19 +397,40 @@ QMenu *QVLCMenu::ToolsMenu( QWidget *parent )
return ToolsMenu( new QMenu( parent ) );
}
/**
* Dynamic View Menu
* Connect signal "aboutToShow" to the creation of the View Menu
**/
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QWidget* parent )
{
QMenu *viewMenu = new QMenu( parent );
MenuFunc *f = new MenuFunc( viewMenu, 4 );
CONNECT( viewMenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
THEDP->menusUpdateMapper->setMapping( viewMenu, f );
return viewMenu;
}
/**
* View Menu
* Interface Modification
* Interface modification, load other interfaces, activate Extensions
**/
QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
MainInterface *mi,
bool with_intf )
QMenu *current,
bool with_intf )
{
QAction *action;
assert( mi );
QMenu *menu;
if( !with_intf )
menu = new QMenu( qtr( "&View" ), current );
else
{
menu = current;
menu->clear();
}
QMenu *menu = new QMenu( qtr( "V&iew" ), mi );
MainInterface *mi = p_intf->p_sys->p_mi;
assert( mi );
menu->addAction( QIcon( ":/menu/playlist_menu" ),
qtr( "Play&list" ), mi,
......@@ -424,9 +445,6 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
if( with_intf )
{
QMenu *intfmenu = InterfacesMenu( p_intf, menu );
MenuFunc *f = new MenuFunc( intfmenu, 4 );
CONNECT( intfmenu, aboutToShow(), THEDP->menusUpdateMapper, map() );
THEDP->menusUpdateMapper->setMapping( intfmenu, f );
menu->addSeparator();
}
......@@ -473,14 +491,11 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf,
menu->addSeparator();
addDPStaticEntry( menu, qtr( "Customi&ze Interface..." ),
":/menu/preferences", SLOT( toolbarDialog() ) );
menu->addSeparator();
/* Extensions */
/// @todo Check configuration variable "auto load extensions"
menu->addSeparator();
QMenu *extmenu = ExtensionsMenu( p_intf, menu );
MenuFunc *f = new MenuFunc( menu, 5 );
CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
THEDP->menusUpdateMapper->setMapping( menu, f );
ExtensionsMenu( p_intf, menu );
return menu;
}
......@@ -499,41 +514,19 @@ QMenu *QVLCMenu::InterfacesMenu( intf_thread_t *p_intf, QMenu *current )
}
/**
* Extensions Sub-Menu
* EXPERIMENTAL
* Extensions menu: populate the current menu with extensions
**/
QMenu *QVLCMenu::ExtensionsMenu( intf_thread_t *p_intf, QMenu *current )
void QVLCMenu::ExtensionsMenu( intf_thread_t *p_intf, QMenu *extMenu )
{
QAction *extAction = NULL;
foreach( QAction *action, current->actions() )
{
if( action->text() == qtr( "&Extensions" ) )
{
extAction = action;
break;
}
}
/* Get ExtensionsManager and load extensions if needed */
ExtensionsManager *extMgr = ExtensionsManager::getInstance( p_intf );
QMenu *extMenu = new QMenu( qtr( "&Extensions" ), current );
if( extMgr->isLoaded() )
{
/* Let the ExtensionsManager build itself the menu */
extMgr->menu( extMenu );
}
else
if( !extMgr->isLoaded() && !extMgr->cannotLoad() )
{
extMenu->addAction( qtr( "&Load extensions" ),
extMgr, SLOT( loadExtensions() ) );
extMgr->loadExtensions();
}
if( extAction )
extAction->setMenu( extMenu );
else
current->addMenu( extMenu );
return extMenu;
/* Let the ExtensionsManager build itself the menu */
extMgr->menu( extMenu );
}
/**
......@@ -1035,7 +1028,7 @@ void QVLCMenu::PopupMenu( intf_thread_t *p_intf, bool show )
msg_Warn( p_intf, "could not find parent interface" );
}
else
menu->addMenu( ViewMenu( p_intf, mi, false ));
menu->addMenu( ViewMenu( p_intf, menu, false ));
menu->addMenu( submenu );
}
......
......@@ -106,10 +106,11 @@ private:
static QMenu *ToolsMenu( QMenu * );
static QMenu *ToolsMenu( QWidget * );
static QMenu *ViewMenu( intf_thread_t *, MainInterface *,
bool with = true );
static QMenu *ViewMenu( intf_thread_t *, QWidget *parent );
static QMenu *ViewMenu( intf_thread_t *, QMenu *, bool with_intf );
static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
static QMenu *ExtensionsMenu( intf_thread_t *p_intf, QMenu * );
static void ExtensionsMenu( intf_thread_t *p_intf, QMenu * );
static QMenu *NavigMenu( intf_thread_t *, QMenu * );
static QMenu *NavigMenu( intf_thread_t *, QWidget * );
......@@ -163,8 +164,7 @@ public:
case 1: QVLCMenu::AudioMenu( p_intf, menu ); break;
case 2: QVLCMenu::VideoMenu( p_intf, menu ); break;
case 3: QVLCMenu::RebuildNavigMenu( p_intf, menu ); break;
case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
case 5: QVLCMenu::ExtensionsMenu( p_intf, menu ); break;
case 4: QVLCMenu::ViewMenu( p_intf, menu, true ); break;
}
}
private:
......
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