Commit 7f994b8b authored by Clément Stenac's avatar Clément Stenac

Playlist menu

Add button in playlist widget
parent 2f53a04a
......@@ -30,8 +30,10 @@
#include "pixmaps/art.xpm"
#include <vlc/vout.h>
#include <QCursor>
#include <QPushButton>
#include <QHBoxLayout>
#include <QMenu>
#define ICON_SIZE 128
......@@ -48,7 +50,6 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
{
vlc_mutex_init( p_intf, &lock );
p_vout = NULL;
setFrameStyle(QFrame::Panel | QFrame::Raised);
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
}
......@@ -103,7 +104,6 @@ void VideoWidget::release( void *p_win )
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
QFrame( NULL ), p_intf( _p_i )
{
setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
setAutoFillBackground( true );
plt = palette();
......@@ -148,7 +148,6 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e )
VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
QFrame( NULL ), p_intf( _p_i )
{
setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
QHBoxLayout *layout = new QHBoxLayout( this );
layout->setMargin( 0 );
QPushButton *prevButton = new QPushButton( "Prev" );
......@@ -175,20 +174,21 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
QVBoxLayout *left = new QVBoxLayout( );
QHBoxLayout *middle = new QHBoxLayout;
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
selector = new PLSelector( this, p_intf, THEPL );
selector->setMaximumWidth( 130 );
left->addWidget( selector );
QPushButton *undockButton = new QPushButton( "UN", this );
undockButton->setMaximumWidth( 25 );
BUTTONACT( undockButton, undock() );
undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
QPushButton *sourcesButton = new QPushButton( "Sources", this );
sourcesButton->setToolTip( qtr( "Select additional stream sources" ) );
BUTTONACT( undockButton, undock() );
middle->addWidget( undockButton );
middle->addWidget( sourcesButton );
addButton = new QPushButton( "+", this );
addButton->setMaximumWidth( 25 );
BUTTONACT( addButton, add() );
middle->addWidget( addButton );
left->addLayout( middle );
QLabel *art = new QLabel( "" );
......@@ -200,11 +200,13 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
THEPL->p_local_category );
currentRootId = p_root->i_id;
rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
p_intf, THEPL, p_root ) );
CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
CONNECT( selector, activated( int ), this, setCurrentRootId( int ) );
QHBoxLayout *layout = new QHBoxLayout(this);
layout->addLayout( left, 0 );
......@@ -216,6 +218,25 @@ PlaylistWidget::~PlaylistWidget()
{
}
void PlaylistWidget::setCurrentRootId( int _new )
{
currentRootId = _new;
if( currentRootId == THEPL->p_local_category->i_id ||
currentRootId == THEPL->p_local_onelevel->i_id )
{
addButton->setEnabled( true );
addButton->setToolTip( qtr("Add to playlist" ) );
}
else if( currentRootId == THEPL->p_ml_category->i_id ||
currentRootId == THEPL->p_ml_onelevel->i_id )
{
addButton->setEnabled( true );
addButton->setToolTip( qtr("Add to media library" ) );
}
else
addButton->setEnabled( false );
}
void PlaylistWidget::undock()
{
hide();
......@@ -226,9 +247,27 @@ void PlaylistWidget::undock()
QApplication::postEvent( p_intf->p_sys->p_mi, event );
}
void PlaylistWidget::add()
{
QMenu *popup = new QMenu();
if( currentRootId == THEPL->p_local_category->i_id ||
currentRootId == THEPL->p_local_onelevel->i_id )
{
popup->addAction( "Add file", THEDP, SLOT( simplePLAppendDialog() ) );
popup->addAction( "Advanced add", THEDP, SLOT( PLAppendDialog() ) );
}
else if( currentRootId == THEPL->p_ml_category->i_id ||
currentRootId == THEPL->p_ml_onelevel->i_id )
{
popup->addAction( "Add file", THEDP, SLOT( simpleMLAppendDialog() ) );
popup->addAction( "Advanced add", THEDP, SLOT( MLAppendDialog() ) );
popup->addAction( "Directory", THEDP, SLOT( openMLDirectory() ) );
}
popup->popup( QCursor::pos() );
}
QSize PlaylistWidget::sizeHint() const
{
fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );
return widgetSize;
}
......@@ -93,6 +93,7 @@ private:
class QSignalMapper;
class PLSelector;
class PLPanel;
class QPushButton;
class PlaylistWidget : public QFrame
{
......@@ -106,8 +107,12 @@ private:
PLSelector *selector;
PLPanel *rightPanel;
intf_thread_t *p_intf;
int currentRootId;
QPushButton *addButton;
private slots:
void undock();
void add();
void setCurrentRootId( int );
};
#endif
......@@ -29,6 +29,7 @@
#include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp"
#include "dialogs_provider.hpp"
#include "menus.hpp"
#include <QHBoxLayout>
#include <QSignalMapper>
......@@ -44,8 +45,6 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
setCentralWidget( main );
setWindowTitle( qtr( "Playlist" ) );
SDMapper = new QSignalMapper();
CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
createPlMenuBar( menuBar(), p_intf );
selector = new PLSelector( centralWidget(), p_intf, THEPL );
......@@ -96,46 +95,7 @@ void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) );
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 , triggered(), SDMapper, 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;
bar->addMenu( QVLCMenu::SDMenu( p_intf ) );
}
void PlaylistDialog::dock()
......@@ -144,12 +104,3 @@ void PlaylistDialog::dock()
QEvent *event = new QEvent( (QEvent::Type)(PLDockEvent_Type) );
QApplication::postEvent( p_intf->p_sys->p_mi, event );
}
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 );
}
......@@ -48,16 +48,13 @@ public:
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 dock();
void SDMenuAction( QString );
};
......
......@@ -51,6 +51,9 @@ DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
menusUpdateMapper = new QSignalMapper();
CONNECT( menusUpdateMapper, mapped(QObject *),
this, menuUpdateAction( QObject *) );
SDMapper = new QSignalMapper();
CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
}
DialogsProvider::~DialogsProvider()
......@@ -187,6 +190,16 @@ void DialogsProvider::menuUpdateAction( QObject *data )
f->doFunc( p_intf );
}
void DialogsProvider::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 );
}
void DialogsProvider::simplePLAppendDialog()
{
QStringList files = showSimpleOpen();
......
......@@ -59,6 +59,7 @@ protected:
friend class QVLCMenu;
QSignalMapper *menusMapper;
QSignalMapper *menusUpdateMapper;
QSignalMapper *SDMapper;
void customEvent( QEvent *);
private:
DialogsProvider( intf_thread_t *);
......@@ -84,6 +85,7 @@ public slots:
void doInteraction( intf_dialog_args_t * );
void menuAction( QObject *);
void menuUpdateAction( QObject *);
void SDMenuAction( QString );
void streamingDialog();
void openPlaylist();
void openDirectory();
......
......@@ -30,6 +30,7 @@
#include "dialogs/playlist.hpp"
#include "menus.hpp"
#include <QMenuBar>
#include <QCloseEvent>
#include <QPushButton>
#include <QStatusBar>
......@@ -92,7 +93,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
handleMainUi( settings );
QVLCMenu::createMenuBar( menuBar(), p_intf );
QVLCMenu::createMenuBar( menuBar(), p_intf, playlistEmbeddedFlag );
/* Status bar */
timeLabel = new QLabel( 0 );
......@@ -444,11 +445,15 @@ void MainInterface::customEvent( QEvent *event )
playlistWidget = NULL;
playlistEmbeddedFlag = false;
doComponentsUpdate();
menuBar()->clear();
QVLCMenu::createMenuBar( menuBar(), p_intf, false );
}
else if( event->type() == PLDockEvent_Type )
{
PlaylistDialog::killInstance();
playlistEmbeddedFlag = true;
menuBar()->clear();
QVLCMenu::createMenuBar( menuBar(), p_intf, true );
playlist();
}
}
......@@ -524,7 +529,7 @@ void MainInterface::play()
if( !THEPL->i_size || !THEPL->i_enabled )
{
/* The playlist is empty, open a file requester */
THEDP->openDialog();
THEDP->simpleOpenDialog();
setStatus( 0 );
return;
}
......
......@@ -117,9 +117,14 @@ static int AudioAutoMenuBuilder( vlc_object_t *p_object,
CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
THEDP->menusUpdateMapper->setMapping( menu, f ); }
void QVLCMenu::createMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
void QVLCMenu::createMenuBar( QMenuBar *bar, intf_thread_t *p_intf,
bool playlist )
{
BAR_ADD( FileMenu(), qtr("File") );
if( playlist )
{
BAR_ADD( PlaylistMenu( p_intf ), qtr("Playlist" ) );
}
BAR_ADD( ToolsMenu( p_intf ), qtr("Tools") );
BAR_DADD( VideoMenu( p_intf, NULL ), qtr("Video"), 1 );
BAR_DADD( AudioMenu( p_intf, NULL ), qtr("Audio"), 2 );
......@@ -139,6 +144,17 @@ QMenu *QVLCMenu::FileMenu()
return menu;
}
QMenu *QVLCMenu::PlaylistMenu( intf_thread_t *p_intf )
{
QMenu *menu = new QMenu();
menu->addMenu( SDMenu( p_intf ) );
menu->addSeparator();
DP_SADD( qtr( "Open playlist file"), "", "", openPlaylist() );
// DP_SADD( qtr( "Save playlist to file" ), "", "", savePlaylist() );
return menu;
}
QMenu *QVLCMenu::ToolsMenu( intf_thread_t *p_intf, bool with_intf )
{
QMenu *menu = new QMenu();
......@@ -242,6 +258,44 @@ QMenu *QVLCMenu::NavigMenu( intf_thread_t *p_intf, QMenu *current )
return Populate( p_intf, current, varnames, objects );
}
QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
{
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 , 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;
}
/*****************************************************************************
* Popup menus
......
......@@ -58,12 +58,12 @@ class QVLCMenu : public QObject
{
Q_OBJECT;
public:
static void createMenuBar( QMenuBar *, intf_thread_t * );
static void createPlMenuBar( QMenuBar *, intf_thread_t * );
static void createMenuBar( QMenuBar *, intf_thread_t *, bool );
/* Menus */
static QMenu *FileMenu();
static QMenu *SDMenu( intf_thread_t * );
static QMenu *PlaylistMenu( intf_thread_t *);
static QMenu *ToolsMenu( intf_thread_t *, bool with_intf = true );
static QMenu *NavigMenu( intf_thread_t * , QMenu * );
static QMenu *VideoMenu( intf_thread_t * , QMenu * );
......@@ -98,14 +98,10 @@ public:
{
switch( id )
{
case 1:
QVLCMenu::VideoMenu( p_intf, menu ); break;
case 2:
QVLCMenu::AudioMenu( p_intf, menu ); break;
case 3:
QVLCMenu::NavigMenu( p_intf, menu ); break;
case 4:
QVLCMenu::InterfacesMenu( p_intf, menu ); break;
case 1: QVLCMenu::VideoMenu( p_intf, menu ); break;
case 2: QVLCMenu::AudioMenu( p_intf, menu ); break;
case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
}
};
int id; QMenu *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