Commit 277e9ab5 authored by Clément Stenac's avatar Clément Stenac

Fix SD support

parent 75b1aa19
......@@ -27,7 +27,11 @@
#include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp"
#include <QHBoxLayout>
#include "menus.hpp"
#include <QSignalMapper>
#include <QMenu>
#include <QAction>
#include <QMenuBar>
#include "dialogs_provider.hpp"
PlaylistDialog *PlaylistDialog::instance = NULL;
......@@ -36,7 +40,11 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
QWidget *main = new QWidget( this );
setCentralWidget( main );
setWindowTitle( qtr( "Playlist" ) );
QVLCMenu::createPlMenuBar( menuBar(), p_intf );
SDMapper = new QSignalMapper();
connect( SDMapper, SIGNAL( mapped (QString)), this,
SLOT( SDMenuAction( QString ) ) );
createPlMenuBar( menuBar(), p_intf );
selector = new PLSelector( centralWidget(), p_intf, THEPL );
selector->setMaximumWidth( 130 );
......@@ -60,3 +68,79 @@ PlaylistDialog::~PlaylistDialog()
{
writeSettings( "playlist" );
}
void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
{
QMenu *manageMenu = new QMenu();
manageMenu->setTitle( qtr("Add") );
QMenu *subPlaylist = new QMenu();
subPlaylist->setTitle( qtr("Add to current playlist") );
subPlaylist->addAction( "&File...", THEDP,
SLOT( simplePLAppendDialog() ) );
subPlaylist->addAction( "&Advanced add...", THEDP,
SLOT( PLAppendDialog() ) );
manageMenu->addMenu( subPlaylist );
manageMenu->addSeparator();
QMenu *subML = new QMenu();
subML->setTitle( qtr("Add to Media library") );
subML->addAction( "&File...", THEDP,
SLOT( simpleMLAppendDialog() ) );
subML->addAction( "Directory", THEDP, SLOT( openMLDirectory() ));
subML->addAction( "&Advanced add...", THEDP,
SLOT( MLAppendDialog() ) );
manageMenu->addMenu( subML );
manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
bar->addMenu( manageMenu );
bar->addMenu( SDMenu() );
}
QMenu *PlaylistDialog::SDMenu()
{
QMenu *menu = new QMenu();
menu->setTitle( qtr( "Additional sources" ) );
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 , SIGNAL( triggered() ), SDMapper, SLOT( map() ) );
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;
}
void PlaylistDialog::SDMenuAction( QString data )
{
char *psz_sd = data.toUtf8().data();
if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
else
playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
}
......@@ -26,6 +26,7 @@
#include <QModelIndex>
#include "util/qvlcframe.hpp"
class QSignalMapper;
class PLSelector;
class PLPanel;
......@@ -40,11 +41,17 @@ public:
}
virtual ~PlaylistDialog();
private:
void createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf );
QMenu * SDMenu();
PlaylistDialog( intf_thread_t * );
static PlaylistDialog *instance;
QSignalMapper *SDMapper;
PLSelector *selector;
PLPanel *rightPanel;
private slots:
void SDMenuAction( QString );
};
......
......@@ -37,9 +37,6 @@ DialogsProvider* DialogsProvider::instance = NULL;
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
QObject( NULL ), p_intf( _p_intf )
{
// idle_timer = new QTimer( this );
// idle_timer->start( 0 );
fixed_timer = new QTimer( this );
fixed_timer->start( 150 /* milliseconds */ );
......@@ -52,9 +49,6 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
SLOT(menuUpdateAction( QObject *)) );
}
DialogsProvider::~DialogsProvider()
{
}
void DialogsProvider::customEvent( QEvent *event )
{
if( event->type() == DialogEvent_Type )
......
......@@ -50,8 +50,7 @@ public:
instance = new DialogsProvider( p_intf );
return instance;
}
virtual ~DialogsProvider();
QTimer *idle_timer;
virtual ~DialogsProvider() {};
QTimer *fixed_timer;
protected:
friend class QVLCMenu;
......
......@@ -38,7 +38,6 @@ enum
};
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 ) ); } }
......@@ -128,85 +127,6 @@ void QVLCMenu::createMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
// BAR_ADD( HelpMenu(), qtr("Help" ) );
}
void QVLCMenu::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
{
QMenu *manageMenu = new QMenu();
manageMenu->setTitle( qtr("Operations") );
QMenu *subPlaylist = new QMenu();
subPlaylist->setTitle( qtr("Add to current playlist") );
subPlaylist->addAction( "&File...", THEDP,
SLOT( simplePLAppendDialog() ) );
subPlaylist->addAction( "&Advanced add...", THEDP,
SLOT( PLAppendDialog() ) );
manageMenu->addMenu( subPlaylist );
manageMenu->addSeparator();
QMenu *subML = new QMenu();
subML->setTitle( qtr("Add to Media library") );
subML->addAction( "&File...", THEDP,
SLOT( simpleMLAppendDialog() ) );
subML->addAction( "Directory", THEDP, SLOT( openMLDirectory() ));
subML->addAction( "&Advanced add...", THEDP,
SLOT( MLAppendDialog() ) );
manageMenu->addMenu( subML );
manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
manageMenu->addSeparator();
// manageMenu->addMenu( SDMenu( p_intf ) );
bar->addMenu( manageMenu );
}
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
{
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 );
return menu;
}
QMenu *QVLCMenu::FileMenu()
{
QMenu *menu = new QMenu();
......
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