#include "pixmaps/art.xpm"
#include <vlc/vout.h>
+#include <QCursor>
#include <QPushButton>
#include <QHBoxLayout>
+#include <QMenu>
#define ICON_SIZE 128
{
vlc_mutex_init( p_intf, &lock );
p_vout = NULL;
- setFrameStyle(QFrame::Panel | QFrame::Raised);
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
}
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
QFrame( NULL ), p_intf( _p_i )
{
- setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
setAutoFillBackground( true );
plt = palette();
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" );
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( "" );
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 );
{
}
+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();
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;
}
class QSignalMapper;
class PLSelector;
class PLPanel;
+class QPushButton;
class PlaylistWidget : public QFrame
{
PLSelector *selector;
PLPanel *rightPanel;
intf_thread_t *p_intf;
+ int currentRootId;
+ QPushButton *addButton;
private slots:
void undock();
+ void add();
+ void setCurrentRootId( int );
};
#endif
#include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp"
#include "dialogs_provider.hpp"
+#include "menus.hpp"
#include <QHBoxLayout>
#include <QSignalMapper>
setCentralWidget( main );
setWindowTitle( qtr( "Playlist" ) );
- SDMapper = new QSignalMapper();
- CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
- createPlMenuBar( menuBar(), p_intf );
+ createPlMenuBar( menuBar(), p_intf );
selector = new PLSelector( centralWidget(), p_intf, THEPL );
selector->setMaximumWidth( 130 );
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()
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 );
-}
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 );
};
menusUpdateMapper = new QSignalMapper();
CONNECT( menusUpdateMapper, mapped(QObject *),
this, menuUpdateAction( QObject *) );
+
+ SDMapper = new QSignalMapper();
+ CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
}
DialogsProvider::~DialogsProvider()
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();
friend class QVLCMenu;
QSignalMapper *menusMapper;
QSignalMapper *menusUpdateMapper;
+ QSignalMapper *SDMapper;
void customEvent( QEvent *);
private:
DialogsProvider( intf_thread_t *);
void doInteraction( intf_dialog_args_t * );
void menuAction( QObject *);
void menuUpdateAction( QObject *);
+ void SDMenuAction( QString );
void streamingDialog();
void openPlaylist();
void openDirectory();
#include "dialogs/playlist.hpp"
#include "menus.hpp"
+#include <QMenuBar>
#include <QCloseEvent>
#include <QPushButton>
#include <QStatusBar>
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 );
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();
}
}
if( !THEPL->i_size || !THEPL->i_enabled )
{
/* The playlist is empty, open a file requester */
- THEDP->openDialog();
+ THEDP->simpleOpenDialog();
setStatus( 0 );
return;
}
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 );
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();
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
{
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 * );
{
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;