/*****************************************************************************
* menus.cpp : Qt menus
*****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006-2007 the VideoLAN team
* $Id$
*
- * Authors: ClÃment Stenac <zorglub@videolan.org>
+ * Authors: Clément Stenac <zorglub@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
-#include "menus.hpp"
-#include "dialogs_provider.hpp"
-#include "input_manager.hpp"
#include <QMenu>
#include <QMenuBar>
#include <QAction>
#include <QActionGroup>
#include <QSignalMapper>
+#ifndef WIN32
+# include <signal.h>
+#endif
+
+#include <vlc_intf_strings.h>
+
+#include "main_interface.hpp"
+#include "menus.hpp"
+#include "dialogs_provider.hpp"
+#include "input_manager.hpp"
+
enum
{
ITEM_NORMAL,
};
static QActionGroup *currentGroup;
-static char ** pp_sds;
// Add static entries to menus
-#define DP_SADD( text, help, icon, slot ) { if( strlen(icon) > 0 ) { QAction *action = menu->addAction( text, THEDP, SLOT( slot ) ); action->setIcon(QIcon(icon));} else { menu->addAction( text, THEDP, SLOT( slot ) ); } }
-#define MIM_SADD( text, help, icon, slot ) { if( strlen(icon) > 0 ) { QAction *action = menu->addAction( text, THEMIM, SLOT( slot ) ); action->setIcon(QIcon(icon));} else { menu->addAction( text, THEMIM, SLOT( slot ) ); } }
+#define DP_SADD( text, help, icon, slot, shortcut ) \
+ { \
+ if( strlen(icon) > 0 ) \
+ { \
+ if( strlen(shortcut) > 0 ) \
+ { \
+ menu->addAction( QIcon(icon), text, THEDP, SLOT( slot ), \
+ tr(shortcut) );\
+ } \
+ else \
+ { \
+ menu->addAction( QIcon(icon), text, THEDP, SLOT( slot ) );\
+ } \
+ } \
+ else \
+ { \
+ if( strlen(shortcut) > 0 ) \
+ { \
+ menu->addAction( text, THEDP, SLOT( slot ), \
+ qtr(shortcut) ); \
+ } \
+ else \
+ { \
+ menu->addAction( text, THEDP, SLOT( slot ) ); \
+ } \
+ } \
+ }
+#define MIM_SADD( text, help, icon, slot ) \
+ { \
+ if( strlen(icon) > 0 ) \
+ { \
+ QAction *action = menu->addAction( text, THEMIM, SLOT( slot ) ); \
+ action->setIcon(QIcon(icon)); \
+ } \
+ else \
+ { \
+ menu->addAction( text, THEMIM, SLOT( slot ) ); \
+ } \
+ }
#define PL_SADD
/*****************************************************************************
FIND_PARENT );
if( p_dec_obj != NULL )
{
+ vlc_object_t *p_object = p_dec_obj;
PUSH_VAR( "ffmpeg-pp-q" );
vlc_object_release( p_dec_obj );
}
#define BAR_DADD( func, title, id ) { \
QMenu *menu = func; menu->setTitle( title ); bar->addMenu( menu ); \
MenuFunc *f = new MenuFunc( menu, id ); \
- connect( menu, SIGNAL( aboutToShow() ), \
- THEDP->menusUpdateMapper, SLOT(map()) ); \
+ CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
THEDP->menusUpdateMapper->setMapping( menu, f ); }
-void QVLCMenu::createMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
+void QVLCMenu::createMenuBar( MainInterface *mi, intf_thread_t *p_intf,
+ bool playlist, bool adv_controls_enabled,
+ bool visual_selector_enabled )
{
- BAR_ADD( FileMenu(), qtr("File") );
- BAR_ADD( ToolsMenu( p_intf ), qtr("Tools") );
+#ifndef WIN32
+ /* Ugly klugde
+ * Remove SIGCHLD from the ignored signal the time to initialise
+ * Qt because it call gconf to get the icon theme */
+ sigset_t set;
+
+ sigemptyset( &set );
+ sigaddset( &set, SIGCHLD );
+ pthread_sigmask (SIG_UNBLOCK, &set, NULL);
+#endif
+ QMenuBar *bar = mi->menuBar();
+#ifndef WIN32
+ pthread_sigmask (SIG_BLOCK, &set, NULL);
+#endif
+ BAR_ADD( FileMenu(), qtr("Media") );
+ if( playlist )
+ {
+ BAR_ADD( PlaylistMenu( mi,p_intf ), qtr("Playlist" ) );
+ }
+ BAR_ADD( ToolsMenu( p_intf, mi, adv_controls_enabled,
+ visual_selector_enabled ), qtr("Tools") );
BAR_DADD( VideoMenu( p_intf, NULL ), qtr("Video"), 1 );
BAR_DADD( AudioMenu( p_intf, NULL ), qtr("Audio"), 2 );
BAR_DADD( NavigMenu( p_intf, NULL ), qtr("Navigation"), 3 );
- // BAR_ADD( HelpMenu(), qtr("Help" ) );
-}
-
-void QVLCMenu::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
-{
- QMenu *manageMenu = new QMenu();
- manageMenu->addAction( "Quick &Add File...", THEDP,
- SLOT( simpleAppendDialog() ) );
- manageMenu->addSeparator();
- manageMenu->addMenu( SDMenu( p_intf ) );
+ BAR_ADD( HelpMenu(), qtr("Help" ) );
}
-
-QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
+QMenu *QVLCMenu::FileMenu()
{
QMenu *menu = new QMenu();
- menu->setTitle( qtr( "Services Discovery" ) );
- playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
- VLC_OBJECT_PLAYLIST,
- FIND_ANYWHERE );
- assert( p_playlist );
- vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
- FIND_ANYWHERE );
- int i_num = 0;
- for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
- {
- module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
- if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
- i_num++;
- }
- if( i_num ) pp_sds = (char **)calloc( i_num, sizeof(void *) );
- for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
- {
- module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
- if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
- {
- QAction *a = menu->addAction(
- qfu( p_parser->psz_longname ?
- p_parser->psz_longname :
- ( p_parser->psz_shortname ?
- p_parser->psz_shortname :
- p_parser->psz_object_name ) ) );
- a->setCheckable( true );
- /* hack to handle submodules properly */
- int i = -1;
- while( p_parser->pp_shortcuts[++i] != NULL );
- i--;
- if( playlist_IsServicesDiscoveryLoaded( p_playlist,
- i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
- {
- a->setChecked( true );
- }
- pp_sds[i_num++] = i>=0? p_parser->pp_shortcuts[i] :
- p_parser->psz_object_name;
- }
- }
- vlc_list_release( p_list );
- vlc_object_release( p_playlist );
+/* DP_SADD( qtr("Quick &Open File...") , "", "", simpleOpenDialog() );*/
+ DP_SADD( qtr("Open &File..." ), "", "", openFileDialog(), "Ctrl+O" );
+ DP_SADD( qtr("Open &Disc..." ), "", "", openDiscDialog(), "Ctrl+D" );
+ DP_SADD( qtr("Open &Network..." ), "", "", openNetDialog(), "Ctrl+N" );
+ DP_SADD( qtr("Open &Capture Device..." ), "", "", openCaptureDialog(),
+ "Ctrl+A" );
+ menu->addSeparator();
+ DP_SADD( qtr("&Streaming..."), "", "", streamingDialog(), "Ctrl+S" );
+ menu->addSeparator();
+ DP_SADD( qtr("&Quit") , "", "", quit(), "Ctrl+Q");
return menu;
}
-QMenu *QVLCMenu::FileMenu()
+QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
{
QMenu *menu = new QMenu();
- DP_SADD( qtr("Quick &Open File...") , "", "", simpleOpenDialog() );
- DP_SADD( qtr("&Advanced Open..." ), "", "", openDialog() );
+ menu->addMenu( SDMenu( p_intf ) );
menu->addSeparator();
- DP_SADD( qtr("Streaming..."), "", "", streamingDialog() );
+
+ DP_SADD( qtr(I_PL_LOAD), "", "", openPlaylist(), "Ctrl+L" );
+ DP_SADD( qtr(I_PL_SAVE), "", "", savePlaylist(), "Ctrl+P" );
menu->addSeparator();
- DP_SADD( qtr("&Quit") , "", "", quit() );
+ menu->addAction( qtr("Undock from interface"), mi,
+ SLOT( undockPlaylist() ), qtr("Ctrl+U") );
return menu;
}
-QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, bool with_intf )
+QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, MainInterface *mi,
+ bool adv_controls_enabled,
+ bool visual_selector_enabled, bool with_intf )
{
QMenu *menu = new QMenu();
if( with_intf )
QMenu *intfmenu = InterfacesMenu( p_intf, NULL );
intfmenu->setTitle( qtr("Interfaces" ) );
menu->addMenu( intfmenu );
- /** \todo ADD EXT GUI HERE */
menu->addSeparator();
}
- DP_SADD( qtr("Messages" ), "", "", messagesDialog() );
- DP_SADD( qtr("Information") , "", "", streaminfoDialog() );
- DP_SADD( qtr("Bookmarks"), "", "", bookmarksDialog() );
+ DP_SADD( qtr(I_MENU_MSG), "", "", messagesDialog(), "Ctrl+M" );
+ DP_SADD( qtr(I_MENU_INFO) , "", "", mediaInfoDialog(), "Ctrl+J" );
+ DP_SADD( qtr(I_MENU_CODECINFO) , "", "", mediaCodecDialog(), "Ctrl+I" );
+ DP_SADD( qtr(I_MENU_EXT), "","",extendedDialog(), "Ctrl+G" );
+ if( mi )
+ {
+ menu->addSeparator();
+ QAction *adv = menu->addAction( qtr("Advanced controls" ),
+ mi, SLOT( advanced() ) );
+ adv->setCheckable( true );
+ if( adv_controls_enabled ) adv->setChecked( true );
+#if 0
+ adv = menu->addAction( qtr("Visualizations selector" ),
+ mi, SLOT( visual() ) );
+ adv->setCheckable( true );
+ if( visual_selector_enabled ) adv->setChecked( true );
+#endif
+ }
+ DP_SADD( qtr(I_MENU_GOTOTIME), "","",gotoTimeDialog(), "Ctrl+T" );
menu->addSeparator();
- DP_SADD( qtr("Preferences"), "", "", prefsDialog() );
+ DP_SADD( qtr("Preferences"), "", "", prefsDialog(), "Ctrl+P" );
return menu;
}
objects.push_back( p_intf->i_object_id );
QMenu *menu = Populate( p_intf, current, varnames, objects );
- connect( menu, SIGNAL( aboutToShow() ),
- THEDP->menusUpdateMapper, SLOT(map()) );
- THEDP->menusUpdateMapper->setMapping( menu, 4 );
+ if( !p_intf->pf_show_dialog )
+ {
+ menu->addSeparator();
+ menu->addAction( qtr("Switch to skins"), THEDP, SLOT(switchToSkins()) );
+ }
+
+ CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() );
+ THEDP->menusUpdateMapper->setMapping( menu, 4 );
return menu;
}
return Populate( p_intf, current, varnames, objects );
}
+QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
+{
+ QMenu *menu = new QMenu();
+ menu->setTitle( qtr(I_PL_SD) );
+ vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE,
+ FIND_ANYWHERE );
+ int i_num = 0;
+ for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
+ {
+ module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ;
+ if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
+ i_num++;
+ }
+ for( int i_index = 0 ; i_index < p_list->i_count; i_index++ )
+ {
+ module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object;
+ if( !strcmp( p_parser->psz_capability, "services_discovery" ) )
+ {
+ QAction *a = new QAction( qfu( p_parser->psz_longname ), menu );
+ a->setCheckable( true );
+ /* hack to handle submodules properly */
+ int i = -1;
+ while( p_parser->pp_shortcuts[++i] != NULL );
+ i--;
+ if( playlist_IsServicesDiscoveryLoaded( THEPL,
+ i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) )
+ {
+ a->setChecked( true );
+ }
+ CONNECT( a , triggered(), THEDP->SDMapper, map() );
+ THEDP->SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] :
+ p_parser->psz_object_name );
+ menu->addAction( a );
+ }
+ }
+ vlc_list_release( p_list );
+ return menu;
+}
+
+QMenu *QVLCMenu::HelpMenu()
+{
+ QMenu *menu = new QMenu();
+ DP_SADD( qtr("Help") , "", "", helpDialog(), "F1" );
+ menu->addSeparator();
+ DP_SADD( qtr(I_MENU_ABOUT), "", "", aboutDialog(), "Ctrl+Shift+F1");
+ return menu;
+}
+
/*****************************************************************************
* Popup menus
else \
MIM_SADD( qtr("Pause"), "", "", togglePlayPause() ) \
} \
- else if( THEPL->i_size && THEPL->i_enabled ) \
+ else if( THEPL->items.i_size && THEPL->i_enabled ) \
MIM_SADD( qtr("Play"), "", "", togglePlayPause() ) \
\
QMenu *intfmenu = InterfacesMenu( p_intf, NULL ); \
intfmenu->setTitle( qtr("Interfaces" ) ); \
menu->addMenu( intfmenu ); \
\
- QMenu *toolsmenu = ToolsMenu( p_intf, false ); \
+ QMenu *toolsmenu = ToolsMenu( p_intf, NULL, false, false ); \
toolsmenu->setTitle( qtr("Tools" ) ); \
menu->addMenu( toolsmenu ); \
if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE )
{
- /* Very evil hack ! intf-switch can have only one value */
+ /* Very evil hack ! intf-switch can have only one value */
if( !strcmp( psz_var, "intf-switch" ) ) return FALSE;
if( val.i_int == 1 && b_root ) return TRUE;
else return FALSE;
case VLC_VAR_BOOL:
var_Get( p_object, psz_var, &val );
- val.b_bool = !val.b_bool;
CreateAndConnect( menu, psz_var, TEXT_OR_VAR, "", ITEM_CHECK,
p_object->i_object_id, val, i_type, val.b_bool );
break;
}
-int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
+int QVLCMenu::CreateChoicesMenu( QMenu *submenu, const char *psz_var,
vlc_object_t *p_object, bool b_root )
{
vlc_value_t val, val_list, text_list;
case VLC_VAR_STRING:
var_Get( p_object, psz_var, &val );
another_val.psz_string = strdup( CURVAL.psz_string );
-
menutext = qfu( CURTEXT ? CURTEXT : another_val.psz_string );
CreateAndConnect( submenu, psz_var, menutext, "", NORMAL_OR_RADIO,
p_object->i_object_id, another_val, i_type,
break;
}
}
+ currentGroup = NULL;
/* clean up everything */
var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val_list, &text_list );
if( i_item_type == ITEM_CHECK )
{
action->setCheckable( true );
- currentGroup = NULL;
}
else if( i_item_type == ITEM_RADIO )
{
currentGroup = new QActionGroup(menu);
currentGroup->addAction( action );
}
- else
- currentGroup = NULL;
- if( checked ) action->setChecked( true );
+ if( checked )
+ {
+ action->setChecked( true );
+ }
MenuItemData *itemData = new MenuItemData( i_object_id, i_val_type,
val, psz_var );
- connect( action, SIGNAL(triggered()), THEDP->menusMapper, SLOT(map()) );
+ CONNECT( action, triggered(), THEDP->menusMapper, map() );
THEDP->menusMapper->setMapping( action, itemData );
menu->addAction( action );
}