Commit a01c61f6 authored by zorglub's avatar zorglub

Put the dock/undock back in the menu

Put the add button in the playlist standard panel
Remove duplicated code for playlist widgets
parent 7f994b8b
...@@ -168,8 +168,8 @@ VisualSelector::~VisualSelector() ...@@ -168,8 +168,8 @@ VisualSelector::~VisualSelector()
#include "components/playlist/panels.hpp" #include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp" #include "components/playlist/selector.hpp"
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL), PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
p_intf( _p_intf ) BasePlaylistWidget ( _p_intf)
{ {
QVBoxLayout *left = new QVBoxLayout( ); QVBoxLayout *left = new QVBoxLayout( );
QHBoxLayout *middle = new QHBoxLayout; QHBoxLayout *middle = new QHBoxLayout;
...@@ -178,17 +178,12 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL), ...@@ -178,17 +178,12 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
selector->setMaximumWidth( 130 ); selector->setMaximumWidth( 130 );
left->addWidget( selector ); left->addWidget( selector );
QPushButton *undockButton = new QPushButton( "UN", this ); /* QPushButton *undockButton = new QPushButton( "UN", this );
undockButton->setMaximumWidth( 25 ); undockButton->setMaximumWidth( 25 );
undockButton->setToolTip( qtr( "Undock playlist for main interface" ) ); undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
BUTTONACT( undockButton, undock() ); BUTTONACT( undockButton, undock() );
middle->addWidget( undockButton ); middle->addWidget( undockButton );
*/
addButton = new QPushButton( "+", this );
addButton->setMaximumWidth( 25 );
BUTTONACT( addButton, add() );
middle->addWidget( addButton );
left->addLayout( middle ); left->addLayout( middle );
QLabel *art = new QLabel( "" ); QLabel *art = new QLabel( "" );
...@@ -200,13 +195,15 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL), ...@@ -200,13 +195,15 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
playlist_item_t *p_root = playlist_GetPreferredNode( THEPL, playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
THEPL->p_local_category ); THEPL->p_local_category );
currentRootId = p_root->i_id;
rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this, rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
p_intf, THEPL, p_root ) ); p_intf, THEPL, p_root ) );
CONNECT( selector, activated( int ), rightPanel, setRoot( int ) ); CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
CONNECT( selector, activated( int ), this, setCurrentRootId( int ) );
connect( selector, SIGNAL(activated( int )),
this, SIGNAL( rootChanged( int ) ) );
emit rootChanged( p_root->i_id );
QHBoxLayout *layout = new QHBoxLayout(this); QHBoxLayout *layout = new QHBoxLayout(this);
layout->addLayout( left, 0 ); layout->addLayout( left, 0 );
...@@ -218,54 +215,6 @@ PlaylistWidget::~PlaylistWidget() ...@@ -218,54 +215,6 @@ 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();
THEDP->playlistDialog();
deleteLater();
QEvent *event = new QEvent( (QEvent::Type)(PLUndockEvent_Type) );
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 QSize PlaylistWidget::sizeHint() const
{ {
return widgetSize; return widgetSize;
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include "qt4.hpp"
#include <QWidget> #include <QWidget>
#include <QFrame> #include <QFrame>
#include <QPalette> #include <QPalette>
...@@ -88,14 +91,14 @@ private: ...@@ -88,14 +91,14 @@ private:
intf_thread_t *p_intf; intf_thread_t *p_intf;
}; };
/******************** Playlist Widget ****************/ /******************** Playlist Widgets ****************/
#include <QModelIndex> #include <QModelIndex>
class QSignalMapper; class QSignalMapper;
class PLSelector; class PLSelector;
class PLPanel; class PLPanel;
class QPushButton; class QPushButton;
class PlaylistWidget : public QFrame class PlaylistWidget : public BasePlaylistWidget
{ {
Q_OBJECT; Q_OBJECT;
public: public:
...@@ -106,13 +109,9 @@ public: ...@@ -106,13 +109,9 @@ public:
private: private:
PLSelector *selector; PLSelector *selector;
PLPanel *rightPanel; PLPanel *rightPanel;
intf_thread_t *p_intf;
int currentRootId;
QPushButton *addButton; QPushButton *addButton;
private slots: signals:
void undock(); void rootChanged( int );
void add();
void setCurrentRootId( int );
}; };
#endif #endif
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#define _PLPANELS_H_ #define _PLPANELS_H_
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include "qt4.hpp"
#include <QModelIndex> #include <QModelIndex>
#include <QWidget> #include <QWidget>
#include <QString> #include <QString>
...@@ -39,13 +42,15 @@ class PLPanel: public QWidget ...@@ -39,13 +42,15 @@ class PLPanel: public QWidget
{ {
Q_OBJECT; Q_OBJECT;
public: public:
PLPanel( QWidget *p, intf_thread_t *_p_intf ) : QWidget( p ) PLPanel( BasePlaylistWidget *p, intf_thread_t *_p_intf ) : QWidget( p )
{ {
p_intf = _p_intf; p_intf = _p_intf;
parent = p;
} }
virtual ~PLPanel() {}; virtual ~PLPanel() {};
protected: protected:
intf_thread_t *p_intf; intf_thread_t *p_intf;
BasePlaylistWidget *parent;
public slots: public slots:
virtual void setRoot( int ) = 0; virtual void setRoot( int ) = 0;
}; };
...@@ -55,7 +60,7 @@ class StandardPLPanel: public PLPanel ...@@ -55,7 +60,7 @@ class StandardPLPanel: public PLPanel
{ {
Q_OBJECT; Q_OBJECT;
public: public:
StandardPLPanel( QWidget *, intf_thread_t *, StandardPLPanel( BasePlaylistWidget *, intf_thread_t *,
playlist_t *,playlist_item_t * ); playlist_t *,playlist_item_t * );
virtual ~StandardPLPanel(); virtual ~StandardPLPanel();
protected: protected:
...@@ -63,8 +68,9 @@ protected: ...@@ -63,8 +68,9 @@ protected:
private: private:
PLModel *model; PLModel *model;
QTreeView *view; QTreeView *view;
QPushButton *repeatButton , *randomButton; QPushButton *repeatButton , *randomButton,*addButton;
ClickLineEdit *searchLine; ClickLineEdit *searchLine;
int currentRootId;
public slots: public slots:
virtual void setRoot( int ); virtual void setRoot( int );
private slots: private slots:
...@@ -75,6 +81,8 @@ private slots: ...@@ -75,6 +81,8 @@ private slots:
void doPopup( QModelIndex index, QPoint point ); void doPopup( QModelIndex index, QPoint point );
void search( QString search ); void search( QString search );
void clearFilter(); void clearFilter();
void add();
void setCurrentRootId( int );
}; };
#endif #endif
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*****************************************************************************/ *****************************************************************************/
#include "qt4.hpp" #include "qt4.hpp"
#include "dialogs_provider.hpp"
#include "playlist_model.hpp" #include "playlist_model.hpp"
#include "components/playlist/panels.hpp" #include "components/playlist/panels.hpp"
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp"
...@@ -36,10 +37,12 @@ ...@@ -36,10 +37,12 @@
#include <QToolBar> #include <QToolBar>
#include <QLabel> #include <QLabel>
#include <QSpacerItem> #include <QSpacerItem>
#include <QMenu>
#include <assert.h> #include <assert.h>
StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, StandardPLPanel::StandardPLPanel( BasePlaylistWidget *_parent,
intf_thread_t *_p_intf,
playlist_t *p_playlist, playlist_t *p_playlist,
playlist_item_t *p_root ): playlist_item_t *p_root ):
PLPanel( _parent, _p_intf ) PLPanel( _parent, _p_intf )
...@@ -62,20 +65,28 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, ...@@ -62,20 +65,28 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ), CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
currentRootId = -1;
CONNECT( parent, rootChanged(int), this, setCurrentRootId( int ) );
QVBoxLayout *layout = new QVBoxLayout(); QVBoxLayout *layout = new QVBoxLayout();
layout->setSpacing( 0 ); layout->setMargin( 0 ); layout->setSpacing( 0 ); layout->setMargin( 0 );
QHBoxLayout *buttons = new QHBoxLayout(); QHBoxLayout *buttons = new QHBoxLayout();
addButton = new QPushButton( "+", this );
addButton->setMaximumWidth( 25 );
BUTTONACT( addButton, add() );
buttons->addWidget( addButton );
repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton ); repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton );
if( model->hasRepeat() ) repeatButton->setText( qtr( "Repeat One" ) ); if( model->hasRepeat() ) repeatButton->setText( qtr( "R1" ) );
else if( model->hasLoop() ) repeatButton->setText( qtr( "Repeat All" ) ); else if( model->hasLoop() ) repeatButton->setText( qtr( "RA" ) );
else repeatButton->setText( qtr( "No Repeat" ) ); else repeatButton->setText( qtr( "NR" ) );
BUTTONACT( repeatButton, toggleRepeat() ); BUTTONACT( repeatButton, toggleRepeat() );
randomButton = new QPushButton( 0 ); buttons->addWidget( randomButton ); randomButton = new QPushButton( 0 ); buttons->addWidget( randomButton );
if( model->hasRandom() ) randomButton->setText( qtr( "Random" ) ); if( model->hasRandom() ) randomButton->setText( qtr( " RND" ) );
else randomButton->setText( qtr( "No random" ) ); else randomButton->setText( qtr( "NRND" ) );
BUTTONACT( randomButton, toggleRandom() ); BUTTONACT( randomButton, toggleRandom() );
QSpacerItem *spacer = new QSpacerItem( 10, 20 );buttons->addItem( spacer ); QSpacerItem *spacer = new QSpacerItem( 10, 20 );buttons->addItem( spacer );
...@@ -87,6 +98,7 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf, ...@@ -87,6 +98,7 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
buttons->addWidget( searchLine ); filter->setBuddy( searchLine ); buttons->addWidget( searchLine ); filter->setBuddy( searchLine );
QPushButton *clear = new QPushButton( qfu( "CL") ); QPushButton *clear = new QPushButton( qfu( "CL") );
clear->setMaximumWidth( 30 );
buttons->addWidget( clear ); buttons->addWidget( clear );
BUTTONACT( clear, clearFilter() ); BUTTONACT( clear, clearFilter() );
...@@ -136,6 +148,44 @@ void StandardPLPanel::handleExpansion( const QModelIndex &index ) ...@@ -136,6 +148,44 @@ void StandardPLPanel::handleExpansion( const QModelIndex &index )
} }
} }
void StandardPLPanel::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 StandardPLPanel::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() );
}
void StandardPLPanel::clearFilter() void StandardPLPanel::clearFilter()
{ {
searchLine->setText( "" ); searchLine->setText( "" );
......
...@@ -26,8 +26,7 @@ ...@@ -26,8 +26,7 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "components/playlist/panels.hpp" #include "components/interface_widgets.hpp"
#include "components/playlist/selector.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "menus.hpp" #include "menus.hpp"
...@@ -45,22 +44,12 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -45,22 +44,12 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
setCentralWidget( main ); setCentralWidget( main );
setWindowTitle( qtr( "Playlist" ) ); setWindowTitle( qtr( "Playlist" ) );
createPlMenuBar( menuBar(), p_intf ); createPlMenuBar( menuBar(), p_intf );
selector = new PLSelector( centralWidget(), p_intf, THEPL ); QHBoxLayout *l = new QHBoxLayout( centralWidget() );
selector->setMaximumWidth( 130 ); PlaylistWidget *plw = new PlaylistWidget( p_intf );
l->addWidget( plw );
playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
THEPL->p_local_category );
rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( centralWidget(),
p_intf, THEPL, p_root ) );
CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( selector, 0 );
layout->addWidget( rightPanel, 10 );
centralWidget()->setLayout( layout );
readSettings( "playlist", QSize( 600,700 ) ); readSettings( "playlist", QSize( 600,700 ) );
} }
...@@ -72,27 +61,9 @@ PlaylistDialog::~PlaylistDialog() ...@@ -72,27 +61,9 @@ PlaylistDialog::~PlaylistDialog()
void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ) void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
{ {
QMenu *manageMenu = new QMenu(); QMenu *manageMenu = new QMenu();
manageMenu->setTitle( qtr("Add") ); manageMenu->setTitle( qtr("Manage") );
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->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
manageMenu->addSeparator();
manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) ); manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) );
bar->addMenu( manageMenu ); bar->addMenu( manageMenu );
bar->addMenu( QVLCMenu::SDMenu( p_intf ) ); bar->addMenu( QVLCMenu::SDMenu( p_intf ) );
......
...@@ -93,7 +93,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -93,7 +93,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
setWindowTitle( QString::fromUtf8( _("VLC media player") ) ); setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
handleMainUi( settings ); handleMainUi( settings );
QVLCMenu::createMenuBar( menuBar(), p_intf, playlistEmbeddedFlag ); QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag );
/* Status bar */ /* Status bar */
timeLabel = new QLabel( 0 ); timeLabel = new QLabel( 0 );
...@@ -437,23 +437,39 @@ void MainInterface::doComponentsUpdate() ...@@ -437,23 +437,39 @@ void MainInterface::doComponentsUpdate()
resize( mainSize ); resize( mainSize );
} }
void MainInterface::customEvent( QEvent *event ) void MainInterface::undockPlaylist()
{ {
if( event->type() == PLUndockEvent_Type ) if( playlistWidget )
{ {
playlistWidget->hide();
playlistWidget->deleteLater();
ui.vboxLayout->removeWidget( playlistWidget ); ui.vboxLayout->removeWidget( playlistWidget );
playlistWidget = NULL; playlistWidget = NULL;
playlistEmbeddedFlag = false; playlistEmbeddedFlag = false;
doComponentsUpdate();
menuBar()->clear(); menuBar()->clear();
QVLCMenu::createMenuBar( menuBar(), p_intf, false ); QVLCMenu::createMenuBar( this, p_intf, false );
if( videoIsActive )
{
videoWidget->widgetSize = savedVideoSize;
videoWidget->resize( videoWidget->widgetSize );
videoWidget->updateGeometry();
}
doComponentsUpdate();
THEDP->playlistDialog();
} }
else if( event->type() == PLDockEvent_Type ) }
void MainInterface::customEvent( QEvent *event )
{
if( event->type() == PLDockEvent_Type )
{ {
PlaylistDialog::killInstance(); PlaylistDialog::killInstance();
playlistEmbeddedFlag = true; playlistEmbeddedFlag = true;
menuBar()->clear(); menuBar()->clear();
QVLCMenu::createMenuBar( menuBar(), p_intf, true ); QVLCMenu::createMenuBar(this, p_intf, true );
playlist(); playlist();
} }
} }
......
...@@ -88,6 +88,8 @@ private: ...@@ -88,6 +88,8 @@ private:
QLabel *nameLabel; QLabel *nameLabel;
void customEvent( QEvent *); void customEvent( QEvent *);
public slots:
void undockPlaylist();
private slots: private slots:
void setStatus( int ); void setStatus( int );
void setName( QString ); void setName( QString );
......
...@@ -27,6 +27,8 @@ ...@@ -27,6 +27,8 @@
#include <QActionGroup> #include <QActionGroup>
#include <QSignalMapper> #include <QSignalMapper>
#include "main_interface.hpp"
#include "menus.hpp" #include "menus.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
#include "input_manager.hpp" #include "input_manager.hpp"
...@@ -117,13 +119,14 @@ static int AudioAutoMenuBuilder( vlc_object_t *p_object, ...@@ -117,13 +119,14 @@ static int AudioAutoMenuBuilder( vlc_object_t *p_object,
CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \ CONNECT( menu, aboutToShow(), THEDP->menusUpdateMapper, map() ); \
THEDP->menusUpdateMapper->setMapping( menu, f ); }