]> git.sesse.net Git - vlc/commitdiff
Put the dock/undock back in the menu
authorClément Stenac <zorglub@videolan.org>
Fri, 22 Sep 2006 20:42:33 +0000 (20:42 +0000)
committerClément Stenac <zorglub@videolan.org>
Fri, 22 Sep 2006 20:42:33 +0000 (20:42 +0000)
Put the add button in the playlist standard panel
Remove duplicated code for playlist widgets

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/components/playlist/panels.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/menus.cpp
modules/gui/qt4/menus.hpp
modules/gui/qt4/qt4.hpp

index 0fafbb50b89af5b5cde88faf9978f09d2be7bad3..a64070ad2f2cfe05ef3debf2de937e5b4ae14341 100644 (file)
@@ -168,8 +168,8 @@ VisualSelector::~VisualSelector()
 #include "components/playlist/panels.hpp"
 #include "components/playlist/selector.hpp"
 
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
-                                                            p_intf( _p_intf )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
+                                BasePlaylistWidget ( _p_intf)
 {
     QVBoxLayout *left = new QVBoxLayout( );
     QHBoxLayout *middle = new QHBoxLayout;
@@ -178,17 +178,12 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
     selector->setMaximumWidth( 130 );
     left->addWidget( selector );
 
-    QPushButton *undockButton = new QPushButton( "UN", this );
+/*    QPushButton *undockButton = new QPushButton( "UN", this );
     undockButton->setMaximumWidth( 25 );
     undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
     BUTTONACT( undockButton, undock() );
     middle->addWidget( undockButton );
-
-    addButton = new QPushButton( "+", this );
-    addButton->setMaximumWidth( 25 );
-    BUTTONACT( addButton, add() );
-    middle->addWidget( addButton );
-
+*/
     left->addLayout( middle );
 
     QLabel *art = new QLabel( "" );
@@ -200,13 +195,15 @@ 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 ) );
+
+    connect( selector, SIGNAL(activated( int )),
+             this, SIGNAL( rootChanged( int ) ) );
+    emit rootChanged( p_root->i_id );
 
     QHBoxLayout *layout = new QHBoxLayout(this);
     layout->addLayout( left, 0 );
@@ -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
 {
     return widgetSize;
index 6d467664551a5fb01522f9e7c2b40d385622ecd1..fd894685a271ba8c33725ffd6c4db3bc33a44cd9 100644 (file)
@@ -26,6 +26,9 @@
 
 #include <vlc/vlc.h>
 #include <vlc/intf.h>
+
+#include "qt4.hpp"
+
 #include <QWidget>
 #include <QFrame>
 #include <QPalette>
@@ -88,14 +91,14 @@ private:
     intf_thread_t *p_intf;
 };
 
-/******************** Playlist Widget ****************/
+/******************** Playlist Widgets ****************/
 #include <QModelIndex>
 class QSignalMapper;
 class PLSelector;
 class PLPanel;
 class QPushButton;
 
-class PlaylistWidget : public QFrame
+class PlaylistWidget : public BasePlaylistWidget
 {
     Q_OBJECT;
 public:
@@ -106,13 +109,9 @@ public:
 private:
     PLSelector *selector;
     PLPanel *rightPanel;
-    intf_thread_t *p_intf;
-    int currentRootId;
     QPushButton *addButton;
-private slots:
-    void undock();
-    void add();
-    void setCurrentRootId( int );
+signals:
+    void rootChanged( int );
 };
 
 #endif
index 2e2eb45cdf4fd503bc68ee62e71dc244e9b3280d..f6d3336591d6c40b5f92722b0b2f1333e1fb438a 100644 (file)
@@ -25,6 +25,9 @@
 #define _PLPANELS_H_
 
 #include <vlc/vlc.h>
+
+#include "qt4.hpp"
+
 #include <QModelIndex>
 #include <QWidget>
 #include <QString>
@@ -39,13 +42,15 @@ class PLPanel: public QWidget
 {
     Q_OBJECT;
 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;
+        parent = p;
     }
     virtual ~PLPanel() {};
 protected:
     intf_thread_t *p_intf;
+    BasePlaylistWidget *parent;
 public slots:
     virtual void setRoot( int ) = 0;
 };
@@ -55,7 +60,7 @@ class StandardPLPanel: public PLPanel
 {
     Q_OBJECT;
 public:
-    StandardPLPanel( QWidget *, intf_thread_t *,
+    StandardPLPanel( BasePlaylistWidget *, intf_thread_t *,
                      playlist_t *,playlist_item_t * );
     virtual ~StandardPLPanel();
 protected:
@@ -63,8 +68,9 @@ protected:
 private:
     PLModel *model;
     QTreeView *view;
-    QPushButton *repeatButton , *randomButton;
+    QPushButton *repeatButton , *randomButton,*addButton;
     ClickLineEdit *searchLine;
+    int currentRootId;
 public slots:
     virtual void setRoot( int );
 private slots:
@@ -75,6 +81,8 @@ private slots:
     void doPopup( QModelIndex index, QPoint point );
     void search( QString search );
     void clearFilter();
+    void add();
+    void setCurrentRootId( int );
 };
 
 #endif
index d2b054b924537576cc1e80c862647e63388eb97b..74f6b4893304e5b79e24d6a393d52d38d63fdfaf 100644 (file)
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #include "qt4.hpp"
+#include "dialogs_provider.hpp"
 #include "playlist_model.hpp"
 #include "components/playlist/panels.hpp"
 #include "util/customwidgets.hpp"
 #include <QToolBar>
 #include <QLabel>
 #include <QSpacerItem>
+#include <QMenu>
 
 #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_item_t *p_root ):
                                   PLPanel( _parent, _p_intf )
@@ -62,20 +65,28 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
     CONNECT( model, dataChanged( const QModelIndex&, const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
 
+    currentRootId = -1;
+    CONNECT( parent, rootChanged(int), this, setCurrentRootId( int ) );
+
     QVBoxLayout *layout = new QVBoxLayout();
     layout->setSpacing( 0 ); layout->setMargin( 0 );
 
     QHBoxLayout *buttons = new QHBoxLayout();
 
+    addButton = new QPushButton( "+", this );
+    addButton->setMaximumWidth( 25 );
+    BUTTONACT( addButton, add() );
+    buttons->addWidget( addButton );
+
     repeatButton = new QPushButton( 0 ); buttons->addWidget( repeatButton );
-    if( model->hasRepeat() ) repeatButton->setText( qtr( "Repeat One" ) );
-    else if( model->hasLoop() ) repeatButton->setText( qtr( "Repeat All" ) );
-    else repeatButton->setText( qtr( "No Repeat" ) );
+    if( model->hasRepeat() ) repeatButton->setText( qtr( "R1" ) );
+    else if( model->hasLoop() ) repeatButton->setText( qtr( "RA" ) );
+    else repeatButton->setText( qtr( "NR" ) );
     BUTTONACT( repeatButton, toggleRepeat() );
 
     randomButton = new QPushButton( 0 ); buttons->addWidget( randomButton );
-    if( model->hasRandom() ) randomButton->setText( qtr( "Random" ) );
-    else randomButton->setText( qtr( "No random" ) );
+    if( model->hasRandom() ) randomButton->setText( qtr( " RND" ) );
+    else randomButton->setText( qtr( "NRND" ) );
     BUTTONACT( randomButton, toggleRandom() );
 
     QSpacerItem *spacer = new QSpacerItem( 10, 20 );buttons->addItem( spacer );
@@ -87,6 +98,7 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
     buttons->addWidget( searchLine ); filter->setBuddy( searchLine );
 
     QPushButton *clear = new QPushButton( qfu( "CL") );
+    clear->setMaximumWidth( 30 );
     buttons->addWidget( clear );
     BUTTONACT( clear, clearFilter() );
 
@@ -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()
 {
     searchLine->setText( "" );
index 5e55081fc71ae995c0828ae9b6282e996034f6e0..0cbc2bea7d383799a484b6788021cc21be16c907 100644 (file)
@@ -26,8 +26,7 @@
 #include "qt4.hpp"
 #include "main_interface.hpp"
 #include "util/qvlcframe.hpp"
-#include "components/playlist/panels.hpp"
-#include "components/playlist/selector.hpp"
+#include "components/interface_widgets.hpp"
 #include "dialogs_provider.hpp"
 #include "menus.hpp"
 
@@ -45,22 +44,12 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     setCentralWidget( main );
     setWindowTitle( qtr( "Playlist" ) );
 
-   createPlMenuBar( menuBar(), p_intf );
+    createPlMenuBar( menuBar(), p_intf );
 
-    selector = new PLSelector( centralWidget(), p_intf, THEPL );
-    selector->setMaximumWidth( 130 );
+    QHBoxLayout *l = new QHBoxLayout( centralWidget() );
+    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 ) );
 }
 
@@ -72,27 +61,9 @@ PlaylistDialog::~PlaylistDialog()
 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->setTitle( qtr("Manage") );
     manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
-
+    manageMenu->addSeparator();
     manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) );
     bar->addMenu( manageMenu );
     bar->addMenu( QVLCMenu::SDMenu( p_intf ) );
index b34261bc491f229976d356ba7c1ebd5959120644..9fe65065468cd00575600e295a73857ab9fe5870 100644 (file)
@@ -93,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, playlistEmbeddedFlag );
+    QVLCMenu::createMenuBar( this, p_intf, playlistEmbeddedFlag );
 
     /* Status bar */
     timeLabel = new QLabel( 0 );
@@ -437,23 +437,39 @@ void MainInterface::doComponentsUpdate()
     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 );
         playlistWidget = NULL;
         playlistEmbeddedFlag = false;
-        doComponentsUpdate();
+
         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();
         playlistEmbeddedFlag = true;
         menuBar()->clear();
-        QVLCMenu::createMenuBar( menuBar(), p_intf, true );
+        QVLCMenu::createMenuBar(this, p_intf, true );
         playlist();
     }
 }
index 41b4cf19dde6fbd8e23df8231d3ef43e9b4ecf87..2cfb0ac8ba21781f9eb064c8967ee719a62b1afa 100644 (file)
@@ -88,6 +88,8 @@ private:
     QLabel              *nameLabel;
 
     void customEvent( QEvent *);
+public slots:
+    void undockPlaylist();
 private slots:
     void setStatus( int );
     void setName( QString );
index 6f336ef0d6d802b12390fc34c39f1fa8adb151ba..f814834b322973d9e9e70c77d265f66882ea6640 100644 (file)
@@ -27,6 +27,8 @@
 #include <QActionGroup>
 #include <QSignalMapper>
 
+#include "main_interface.hpp"
+
 #include "menus.hpp"
 #include "dialogs_provider.hpp"
 #include "input_manager.hpp"
@@ -117,13 +119,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( MainInterface *mi, intf_thread_t *p_intf,
                               bool playlist )
 {
+    QMenuBar *bar = mi->menuBar();
     BAR_ADD( FileMenu(), qtr("File") );
     if( playlist )
     {
-        BAR_ADD( PlaylistMenu( p_intf ), qtr("Playlist" ) );
+        BAR_ADD( PlaylistMenu( mi,p_intf ), qtr("Playlist" ) );
     }
     BAR_ADD( ToolsMenu( p_intf ), qtr("Tools") );
     BAR_DADD( VideoMenu( p_intf, NULL ), qtr("Video"), 1 );
@@ -144,7 +147,7 @@ QMenu *QVLCMenu::FileMenu()
     return menu;
 }
 
-QMenu *QVLCMenu::PlaylistMenu( intf_thread_t *p_intf )
+QMenu *QVLCMenu::PlaylistMenu( MainInterface *mi, intf_thread_t *p_intf )
 {
     QMenu *menu = new QMenu();
     menu->addMenu( SDMenu( p_intf ) );
@@ -152,6 +155,9 @@ QMenu *QVLCMenu::PlaylistMenu( intf_thread_t *p_intf )
 
     DP_SADD( qtr( "Open playlist file"), "", "", openPlaylist() );
 //    DP_SADD( qtr( "Save playlist to file" ), "", "", savePlaylist() );
+    menu->addSeparator();
+    menu->addAction( qtr("Undock from interface"), mi,
+                     SLOT( undockPlaylist() ) );
     return menu;
 }
 
index 7e27e62afad0f6003e0d917c45661b55cec1eb2a..8929c6da57662f05816c83f14f1898d7419a6e2a 100644 (file)
@@ -58,12 +58,12 @@ class QVLCMenu : public QObject
 {
     Q_OBJECT;
 public:
-    static void createMenuBar( QMenuBar *, intf_thread_t *, bool );
+    static void createMenuBar( MainInterface *mi, intf_thread_t *, bool );
 
     /* Menus */
     static QMenu *FileMenu();
     static QMenu *SDMenu( intf_thread_t * );
-    static QMenu *PlaylistMenu( intf_thread_t *);
+    static QMenu *PlaylistMenu( MainInterface *, 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 * );
index 39e6d7f73668f5e1924bcfae73c18e95ecd0b38c..fe66a737e562fc987a6985bf0b8c55570e7a0640 100644 (file)
@@ -82,4 +82,15 @@ public:
     intf_dialog_args_t *p_arg;
 };
 
+/* Ugly to put it here, but don't want more files ... */
+#include <QFrame>
+class BasePlaylistWidget : public QFrame
+{
+public:
+    BasePlaylistWidget( intf_thread_t *_p_i ) : p_intf( _p_i)  {};
+    virtual ~BasePlaylistWidget() {};
+protected:
+    intf_thread_t *p_intf;
+};
+
 #endif