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

Qt, menus: comments, cosmetics and simplifications

parent cf346f17
/***************************************************************************** /*****************************************************************************
* menus.cpp : Qt menus * menus.cpp : Qt menus
***************************************************************************** *****************************************************************************
* Copyright © 2006-2009 the VideoLAN team * Copyright © 2006-2011 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
...@@ -35,18 +35,18 @@ ...@@ -35,18 +35,18 @@
#endif #endif
#include <vlc_intf_strings.h> #include <vlc_intf_strings.h>
#include <vlc_services_discovery.h> #include <vlc_services_discovery.h> /*vlc_sd_GetNames*/
#include <vlc_aout.h> #include <vlc_aout.h>
#include <vlc_vout.h> #include <vlc_vout.h>
#include "menus.hpp" #include "menus.hpp"
#include "main_interface.hpp" /* View modifications */ #include "main_interface.hpp" /* View modifications */
#include "dialogs_provider.hpp" /* Dialogs display */ #include "dialogs_provider.hpp" /* Dialogs display */
#include "input_manager.hpp" /* Input Management */ #include "input_manager.hpp" /* Input Management */
#include "recents.hpp" /* Recent Items */ #include "recents.hpp" /* Recent Items */
#include "actions_manager.hpp" #include "actions_manager.hpp" /* Actions Management: play+volume */
#include "extensions_manager.hpp" #include "extensions_manager.hpp" /* Extensions menu*/
#include <QMenu> #include <QMenu>
#include <QMenuBar> #include <QMenuBar>
...@@ -54,15 +54,14 @@ ...@@ -54,15 +54,14 @@
#include <QActionGroup> #include <QActionGroup>
#include <QSignalMapper> #include <QSignalMapper>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QList>
/* /*
This file defines the main menus and the pop-up menu (right-click menu) This file defines the main menus and the pop-up menu (right-click menu)
and the systray menu (in that order in the file) and the systray menu (in that order in the file)
There are 3 menus that have to be rebuilt everytime there are called: There are 4 menus that have to be rebuilt everytime there are called:
Audio, Video, Navigation Audio, Video, Navigation, view
3 functions are building those menus: AudioMenu, VideoMenu, NavigMenu 4 functions are building those menus: AudioMenu, VideoMenu, NavigMenu, View
and 3 functions associated are collecting the objects : and 3 functions associated are collecting the objects :
InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder. InputAutoMenuBuilder, AudioAutoMenuBuilder, VideoAutoMenuBuilder.
...@@ -75,20 +74,18 @@ ...@@ -75,20 +74,18 @@
enum enum
{ {
ITEM_NORMAL, ITEM_NORMAL, /* not a checkbox, nor a radio */
ITEM_CHECK, ITEM_CHECK, /* Checkbox */
ITEM_RADIO ITEM_RADIO /* Radiobox */
}; };
static QActionGroup *currentGroup; static QActionGroup *currentGroup;
QMenu *QVLCMenu::recentsMenu = NULL; QMenu *QVLCMenu::recentsMenu = NULL;
/**************************************************************************** /**
* Menu code helpers: * @brief Add static entries to DP in menus
**************************************************************************** **/
* Add static entries to DP in menus
***************************************************************************/
void addDPStaticEntry( QMenu *menu, void addDPStaticEntry( QMenu *menu,
const QString& text, const QString& text,
const char *icon, const char *icon,
...@@ -118,9 +115,9 @@ void addDPStaticEntry( QMenu *menu, ...@@ -118,9 +115,9 @@ void addDPStaticEntry( QMenu *menu,
action->setData( STATIC_ENTRY ); action->setData( STATIC_ENTRY );
} }
/*** /**
* Same for MIM * @brief Add static entries to MIM in menus
***/ **/
QAction* addMIMStaticEntry( intf_thread_t *p_intf, QAction* addMIMStaticEntry( intf_thread_t *p_intf,
QMenu *menu, QMenu *menu,
const QString& text, const QString& text,
...@@ -145,9 +142,10 @@ QAction* addMIMStaticEntry( intf_thread_t *p_intf, ...@@ -145,9 +142,10 @@ QAction* addMIMStaticEntry( intf_thread_t *p_intf,
} }
/** /**
* @brief Enable all static entries, disable the others * @brief Enable all static entries of a menu, disable the others
* @param menu the menu in which the entries will be disabled
* @param enable if false, disable all entries * @param enable if false, disable all entries
*/ **/
void EnableStaticEntries( QMenu *menu, bool enable = true ) void EnableStaticEntries( QMenu *menu, bool enable = true )
{ {
if( !menu ) return; if( !menu ) return;
...@@ -164,7 +162,7 @@ void EnableStaticEntries( QMenu *menu, bool enable = true ) ...@@ -164,7 +162,7 @@ void EnableStaticEntries( QMenu *menu, bool enable = true )
/** /**
* \return Number of static entries * \return Number of static entries
*/ **/
inline int DeleteNonStaticEntries( QMenu *menu ) inline int DeleteNonStaticEntries( QMenu *menu )
{ {
if( !menu ) return VLC_EGENERIC; if( !menu ) return VLC_EGENERIC;
...@@ -345,8 +343,7 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent ) ...@@ -345,8 +343,7 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
addDPStaticEntry( menu, qtr( "Open &Network Stream..." ), addDPStaticEntry( menu, qtr( "Open &Network Stream..." ),
":/type/network", SLOT( openNetDialog() ), "Ctrl+N" ); ":/type/network", SLOT( openNetDialog() ), "Ctrl+N" );
addDPStaticEntry( menu, qtr( "Open &Capture Device..." ), addDPStaticEntry( menu, qtr( "Open &Capture Device..." ),
":/type/capture-card", SLOT( openCaptureDialog() ), ":/type/capture-card", SLOT( openCaptureDialog() ), "Ctrl+C" );
"Ctrl+C" );
menu->addSeparator(); menu->addSeparator();
addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ), addDPStaticEntry( menu, qtr( "Open &Location from clipboard" ),
...@@ -368,8 +365,7 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent ) ...@@ -368,8 +365,7 @@ QMenu *QVLCMenu::FileMenu( intf_thread_t *p_intf, QWidget *parent )
addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "", addDPStaticEntry( menu, qtr( "Conve&rt / Save..." ), "",
SLOT( openAndTranscodingDialogs() ), "Ctrl+R" ); SLOT( openAndTranscodingDialogs() ), "Ctrl+R" );
addDPStaticEntry( menu, qtr( "&Streaming..." ), addDPStaticEntry( menu, qtr( "&Streaming..." ),
":/menu/stream", SLOT( openAndStreamingDialogs() ), ":/menu/stream", SLOT( openAndStreamingDialogs() ), "Ctrl+S" );
"Ctrl+S" );
menu->addSeparator(); menu->addSeparator();
#endif #endif
...@@ -403,8 +399,7 @@ QMenu *QVLCMenu::ToolsMenu( QMenu *menu ) ...@@ -403,8 +399,7 @@ QMenu *QVLCMenu::ToolsMenu( QMenu *menu )
"" ); "" );
addDPStaticEntry( menu, qtr( I_MENU_MSG ), addDPStaticEntry( menu, qtr( I_MENU_MSG ),
":/menu/messages", SLOT( messagesDialog() ), ":/menu/messages", SLOT( messagesDialog() ), "Ctrl+M" );
"Ctrl+M" );
addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ), addDPStaticEntry( menu, qtr( "Plu&gins and extensions" ),
"", SLOT( pluginDialog() ) ); "", SLOT( pluginDialog() ) );
...@@ -498,8 +493,8 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface ...@@ -498,8 +493,8 @@ QMenu *QVLCMenu::ViewMenu( intf_thread_t *p_intf, QMenu *current, MainInterface
CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) ); CONNECT( action, triggered( bool ), THEMIM, activatePlayQuit( bool ) );
#if 0 /* For Visualisations. Not yet working */ #if 0 /* For Visualisations. Not yet working */
adv = menu->addAction( qtr( "Visualizations selector" ), adv = menu->addAction( qtr( "Visualizations selector" ), mi,
mi, SLOT( visual() ) ); SLOT( visual() ) );
adv->setCheckable( true ); adv->setCheckable( true );
if( visual_selector_enabled ) adv->setChecked( true ); if( visual_selector_enabled ) adv->setChecked( true );
#endif #endif
...@@ -1064,9 +1059,6 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi, ...@@ -1064,9 +1059,6 @@ void QVLCMenu::updateSystrayMenu( MainInterface *mi,
intf_thread_t *p_intf, intf_thread_t *p_intf,
bool b_force_visible ) bool b_force_visible )
{ {
unsigned int i_last_separator = 0;
vector<vlc_object_t *> objects;
vector<const char *> varnames;
input_thread_t *p_input = THEMIM->getInput(); input_thread_t *p_input = THEMIM->getInput();
/* Get the systray menu and clean it */ /* Get the systray menu and clean it */
...@@ -1121,18 +1113,15 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf, ...@@ -1121,18 +1113,15 @@ QMenu * QVLCMenu::Populate( intf_thread_t *p_intf,
currentGroup = NULL; currentGroup = NULL;
vlc_object_t *p_object; for( int i = 0; i < (int)objects.size() ; i++ )
for( int i = 0; i < ( int )objects.size() ; i++ )
{ {
if( !varnames[i] || !*varnames[i] ) if( !varnames[i] || !*varnames[i] )
{ {
menu->addSeparator(); menu->addSeparator();
continue; continue;
} }
p_object = objects[i];
UpdateItem( p_intf, menu, varnames[i], p_object, true ); UpdateItem( p_intf, menu, varnames[i], objects[i], true );
} }
return menu; return menu;
} }
......
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