]> git.sesse.net Git - vlc/commitdiff
Qt4 - remove PlaylistWidget from interface_widget and move it to its own file in...
authorJean-Baptiste Kempf <jb@videolan.org>
Fri, 7 Dec 2007 02:59:19 +0000 (02:59 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Fri, 7 Dec 2007 02:59:19 +0000 (02:59 +0000)
modules/gui/qt4/Modules.am
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/playlist.cpp [new file with mode: 0644]
modules/gui/qt4/components/playlist/playlist.hpp [new file with mode: 0644]
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/main_interface.cpp

index d1dac59e3c0aed899c46202c676b0c009374d442..bfa292ed0ff09a2eafcfb818c5de5c04aaec1177 100644 (file)
@@ -38,6 +38,7 @@ nodist_SOURCES_qt4 = \
                components/simple_preferences.moc.cpp \
                components/open_panels.moc.cpp \
                components/interface_widgets.moc.cpp \
+               components/playlist/playlist.moc.cpp \
                components/playlist/panels.moc.cpp \
                components/playlist/selector.moc.cpp \
                util/input_slider.moc.cpp \
@@ -105,6 +106,7 @@ SOURCES_qt4 =       qt4.cpp \
                components/open_panels.cpp \
                components/interface_widgets.cpp \
                components/playlist/standardpanel.cpp \
+               components/playlist/playlist.cpp \
                components/playlist/selector.cpp \
                util/input_slider.cpp \
                util/customwidgets.cpp
@@ -137,6 +139,7 @@ noinst_HEADERS = \
        components/open_panels.hpp \
        components/interface_widgets.hpp \
        components/playlist/panels.hpp \
+       components/playlist/playlist.hpp \
        components/playlist/selector.hpp \
        util/input_slider.hpp \
        util/directslider.hpp \
index 22a05af5831edfbf1b64168bad7f38349f40c7b8..73bac4c022a2abc524c3c735fbabd2cf251628a9 100644 (file)
@@ -712,107 +712,6 @@ void ControlsWidget::toggleAdvanced()
     emit advancedControlsToggled( b_advancedVisible );  //  doComponentsUpdate();
 }
 
-/**********************************************************************
- * Playlist Widget. The embedded playlist
- **********************************************************************/
-#include "components/playlist/panels.hpp"
-#include "components/playlist/selector.hpp"
-
-#include <QSplitter>
-
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) :
-                                p_intf ( _p_i )
-{
-    /* Left Part and design */
-    QWidget *leftW = new QWidget( this );
-    QVBoxLayout *left = new QVBoxLayout( leftW );
-
-    /* Source Selector */
-    selector = new PLSelector( this, p_intf, THEPL );
-    left->addWidget( selector );
-
-    /* Art label */
-    art = new QLabel( "" );
-    art->setMinimumHeight( 128 );
-    art->setMinimumWidth( 128 );
-    art->setMaximumHeight( 128 );
-    art->setMaximumWidth( 128 );
-    art->setScaledContents( true );
-    art->setPixmap( QPixmap( ":/noart.png" ) );
-    left->addWidget( art );
-
-    /* Initialisation of the playlist */
-    playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
-                                                THEPL->p_local_category );
-
-    rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
-                              p_intf, THEPL, p_root ) );
-
-    /* Connects */
-    CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
-
-    CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
-             artSet( QString ) , this, setArt( QString ) );
-    /* Forward removal requests from the selector to the main panel */
-    CONNECT( qobject_cast<PLSelector *>( selector )->model,
-             shouldRemove( int ),
-             qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
-
-    connect( selector, SIGNAL( activated( int ) ),
-             this, SIGNAL( rootChanged( int ) ) );
-    emit rootChanged( p_root->i_id );
-
-    /* Add the two sides of the QSplitter */
-    addWidget( leftW );
-    addWidget( rightPanel );
-
-    leftW->setMaximumWidth( 250 );
-    setCollapsible( 1, false );
-
-    QList<int> sizeList;
-    sizeList << 180 << 420 ;
-    setSizes( sizeList );
-    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
-
-    /* In case we want to keep the splitter informations */
-    settings->beginGroup( "playlist" );
-    restoreState( settings->value("splitterSizes").toByteArray());
-    resize( settings->value("size", QSize(600, 300)).toSize());
-    move( settings->value("pos", QPoint( 0, 400)).toPoint());
-    settings->endGroup();
-}
-
-void PlaylistWidget::setArt( QString url )
-{
-    if( url.isNull() )
-    {
-        art->setPixmap( QPixmap( ":/noart.png" ) );
-        emit artSet( url );
-    }
-    else if( prevArt != url )
-    {
-        art->setPixmap( QPixmap( url ) );
-        prevArt = url;
-        emit artSet( url );
-    }
-}
-
-QSize PlaylistWidget::sizeHint() const
-{
-   return QSize( 600 , 300 );
-}
-
-PlaylistWidget::~PlaylistWidget()
-{}
-
-void PlaylistWidget::savingSettings( QSettings *settings )
-{
-    settings->beginGroup( "playlist" );
-    settings->setValue( "pos", pos() );
-    settings->setValue( "size", size() );
-    settings->setValue("splitterSizes", saveState() );
-    settings->endGroup();
-}
 
 /**********************************************************************
  * Speed control widget
index 70a90a1d1edaa3477ae6d3cdeeedcf43a18d1c8e..893d4504d969292d4fe4a9220221257e26b2a0fc 100644 (file)
@@ -229,39 +229,6 @@ signals:
 };
 
 
-/******************** Playlist Widgets ****************/
-#include <QModelIndex>
-#include <QSplitter>
-class QSignalMapper;
-class PLSelector;
-class PLPanel;
-class QPushButton;
-class QSettings;
-
-class PlaylistWidget : public QSplitter
-{
-    Q_OBJECT;
-public:
-    PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) ;
-    virtual ~PlaylistWidget();
-    QSize sizeHint() const;
-    void savingSettings( QSettings *settings );
-private:
-    PLSelector *selector;
-    PLPanel *rightPanel;
-    QPushButton *addButton;
-    QLabel *art;
-    QString prevArt;
-protected:
-    intf_thread_t *p_intf;
-private slots:
-    void setArt( QString );
-signals:
-    void rootChanged( int );
-    void artSet( QString );
-};
-
-
 /******************** Speed Control Widgets ****************/
 class SpeedControlWidget : public QFrame
 {
index 60de0b0483fdcb6cd9ae8605cc295a3b956b71eb..1ac3c18474c969f73182a8ae603312a0dff5daeb 100644 (file)
 #include <vlc/vlc.h>
 
 #include "qt4.hpp"
-#include "../interface_widgets.hpp"
+#include "components/playlist/playlist.hpp"
 
 #include <QModelIndex>
 #include <QWidget>
 #include <QString>
 
+class QSignalMapper;
 class QTreeView;
 class PLModel;
 class QPushButton;
@@ -56,7 +57,6 @@ public slots:
     virtual void setRoot( int ) = 0;
 };
 
-class PlaylistWidget;
 
 class StandardPLPanel: public PLPanel
 {
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
new file mode 100644 (file)
index 0000000..8f07844
--- /dev/null
@@ -0,0 +1,134 @@
+/*****************************************************************************
+ * interface_widgets.cpp : Custom widgets for the main interface
+ ****************************************************************************
+ * Copyright ( C ) 2006 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Rafaël Carré <funman@videolanorg>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "components/playlist/panels.hpp"
+#include "components/playlist/selector.hpp"
+#include "components/playlist/playlist.hpp"
+
+#include <QSettings>
+#include <QLabel>
+#include <QSpacerItem>
+#include <QCursor>
+#include <QPushButton>
+#include <QVBoxLayout>
+
+/**********************************************************************
+ * Playlist Widget. The embedded playlist
+ **********************************************************************/
+
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) :
+                                p_intf ( _p_i )
+{
+    /* Left Part and design */
+    QWidget *leftW = new QWidget( this );
+    QVBoxLayout *left = new QVBoxLayout( leftW );
+
+    /* Source Selector */
+    selector = new PLSelector( this, p_intf, THEPL );
+    left->addWidget( selector );
+
+    /* Art label */
+    art = new QLabel( "" );
+    art->setMinimumHeight( 128 );
+    art->setMinimumWidth( 128 );
+    art->setMaximumHeight( 128 );
+    art->setMaximumWidth( 128 );
+    art->setScaledContents( true );
+    art->setPixmap( QPixmap( ":/noart.png" ) );
+    left->addWidget( art );
+
+    /* Initialisation of the playlist */
+    playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
+                                                THEPL->p_local_category );
+
+    rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
+                              p_intf, THEPL, p_root ) );
+
+    /* Connects */
+    CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
+
+    CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
+             artSet( QString ) , this, setArt( QString ) );
+    /* Forward removal requests from the selector to the main panel */
+    CONNECT( qobject_cast<PLSelector *>( selector )->model,
+             shouldRemove( int ),
+             qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
+
+    connect( selector, SIGNAL( activated( int ) ),
+             this, SIGNAL( rootChanged( int ) ) );
+    emit rootChanged( p_root->i_id );
+
+    /* Add the two sides of the QSplitter */
+    addWidget( leftW );
+    addWidget( rightPanel );
+
+    leftW->setMaximumWidth( 250 );
+    setCollapsible( 1, false );
+
+    QList<int> sizeList;
+    sizeList << 180 << 420 ;
+    setSizes( sizeList );
+    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
+
+    /* In case we want to keep the splitter informations */
+    settings->beginGroup( "playlist" );
+    restoreState( settings->value("splitterSizes").toByteArray());
+    resize( settings->value("size", QSize(600, 300)).toSize());
+    move( settings->value("pos", QPoint( 0, 400)).toPoint());
+    settings->endGroup();
+}
+
+void PlaylistWidget::setArt( QString url )
+{
+    if( url.isNull() )
+    {
+        art->setPixmap( QPixmap( ":/noart.png" ) );
+        emit artSet( url );
+    }
+    else if( prevArt != url )
+    {
+        art->setPixmap( QPixmap( url ) );
+        prevArt = url;
+        emit artSet( url );
+    }
+}
+
+QSize PlaylistWidget::sizeHint() const
+{
+   return QSize( 600 , 300 );
+}
+
+PlaylistWidget::~PlaylistWidget()
+{}
+
+void PlaylistWidget::savingSettings( QSettings *settings )
+{
+    settings->beginGroup( "playlist" );
+    settings->setValue( "pos", pos() );
+    settings->setValue( "size", size() );
+    settings->setValue("splitterSizes", saveState() );
+    settings->endGroup();
+}
+
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
new file mode 100644 (file)
index 0000000..c7370db
--- /dev/null
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * interface_widgets.hpp : Playlist Widgets
+ ****************************************************************************
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Rafaël Carré <funman@videolanorg>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef _PLAYLISTWIDGET_H_
+#define _PLAYLISTWIDGET_H_
+
+#include <vlc/vlc.h>
+#include "qt4.hpp"
+
+#include <QSplitter>
+
+class QLabel;
+class PLSelector;
+class PLPanel;
+class QPushButton;
+class QSettings;
+
+class PlaylistWidget : public QSplitter
+{
+    Q_OBJECT;
+public:
+    PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) ;
+    virtual ~PlaylistWidget();
+    QSize sizeHint() const;
+    void savingSettings( QSettings *settings );
+private:
+    PLSelector *selector;
+    PLPanel *rightPanel;
+    QPushButton *addButton;
+    QLabel *art;
+    QString prevArt;
+protected:
+    intf_thread_t *p_intf;
+private slots:
+    void setArt( QString );
+signals:
+    void rootChanged( int );
+    void artSet( QString );
+};
+
+#endif
index 35ddc7f943a7ccfaf593723e1b4d90cb8fa182c4..e6d962cfe84e549232353554a8eb9256cc71a85a 100644 (file)
@@ -40,6 +40,7 @@
 #include <QLabel>
 #include <QSpacerItem>
 #include <QMenu>
+#include <QSignalMapper>
 
 #include <assert.h>
 
@@ -67,12 +68,14 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     view->setDropIndicatorShown( true );
     view->setAutoScroll( true );
 
-    view->header()->resizeSection( 0, 230 );
+    /* Configure the size of the header */
+    view->header()->resizeSection( 0, 200 );
     view->header()->resizeSection( 1, 80 );
     view->header()->setSortIndicatorShown( true );
     view->header()->setClickable( true );
     view->header()->setContextMenuPolicy( Qt::CustomContextMenu );
 
+    /* Connections for the TreeView */
     CONNECT( view, activated( const QModelIndex& ) ,
              model,activateItem( const QModelIndex& ) );
     CONNECT( view, rightClicked( QModelIndex , QPoint ),
@@ -88,11 +91,14 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     /* Buttons configuration */
     QHBoxLayout *buttons = new QHBoxLayout;
 
-    addButton = new QPushButton( QIcon( ":/pixmaps/playlist_add.png" ), "", this );
-    addButton->setMaximumWidth( 25 );
+    /* Add item to the playlist button */
+    addButton = new QPushButton;
+    addButton->setIcon( QIcon( ":/pixmaps/playlist_add.png" ) );
+    addButton->setMaximumWidth( 30 );
     BUTTONACT( addButton, popupAdd() );
     buttons->addWidget( addButton );
 
+    /* Random 2-state button */
     randomButton = new QPushButton( this );
     if( model->hasRandom() )
     {
@@ -107,9 +113,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     BUTTONACT( randomButton, toggleRandom() );
     buttons->addWidget( randomButton );
 
-    QSpacerItem *spacer = new QSpacerItem( 10, 20 );
-    buttons->addItem( spacer );
-
+    /* Repeat 3-state button */
     repeatButton = new QPushButton( this );
     if( model->hasRepeat() )
     {
@@ -129,24 +133,33 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     BUTTONACT( repeatButton, toggleRepeat() );
     buttons->addWidget( repeatButton );
 
+    /* A Spacer and the search possibilities */
+    QSpacerItem *spacer = new QSpacerItem( 10, 20 );
+    buttons->addItem( spacer );
+
     QLabel *filter = new QLabel( qtr(I_PL_SEARCH) + " " );
     buttons->addWidget( filter );
+
     searchLine = new  ClickLineEdit( qtr(I_PL_FILTER), 0 );
+    searchLine->setMinimumWidth( 80 );
     CONNECT( searchLine, textChanged(QString), this, search(QString));
     buttons->addWidget( searchLine ); filter->setBuddy( searchLine );
 
-    QPushButton *clear = new QPushButton( qfu( "CL") );
+    QPushButton *clear = new QPushButton;
+    clear->setText( qfu( "CL") );
     clear->setMaximumWidth( 30 );
     clear->setToolTip( qtr( "Clear" ));
     BUTTONACT( clear, clearFilter() );
     buttons->addWidget( clear );
 
+    /* Finish the layout */
     layout->addWidget( view );
     layout->addLayout( buttons );
 //    layout->addWidget( bar );
     setLayout( layout );
 }
 
+/* Function to toggle between the Repeat states */
 void StandardPLPanel::toggleRepeat()
 {
     if( model->hasRepeat() )
@@ -169,6 +182,7 @@ void StandardPLPanel::toggleRepeat()
     }
 }
 
+/* Function to toggle between the Random states */
 void StandardPLPanel::toggleRandom()
 {
     bool prev = model->hasRandom();
@@ -206,6 +220,7 @@ void StandardPLPanel::setCurrentRootId( int _new )
         addButton->setEnabled( false );
 }
 
+/* PopupAdd Menu for the Add Menu */
 void StandardPLPanel::popupAdd()
 {
     QMenu popup;
@@ -225,22 +240,24 @@ void StandardPLPanel::popupAdd()
         popup.addAction( qtr(I_PL_ADVADD), THEDP, SLOT( MLAppendDialog() ) );
         popup.addAction( qtr(I_PL_ADDDIR), THEDP, SLOT( MLAppendDir() ) );
     }
-    popup.exec( QCursor::pos() );
+    popup.exec( QCursor::pos() - addButton->mapFromGlobal( QCursor::pos() )
+                        + QPoint( 0, addButton->height() ) );
 }
 
-void StandardPLPanel::popupSelectColumn( QPoint )
+void StandardPLPanel::popupSelectColumn( QPoint pos )
 {
     ContextUpdateMapper = new QSignalMapper(this);
 
     QMenu selectColMenu;
 
 #define ADD_META_ACTION( meta ) { \
-   QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) );     \
-   option->setCheckable( true );                                           \
-   option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta );   \
-   ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta );      \
-   CONNECT( option, triggered(), ContextUpdateMapper, map() );             \
-   }
+    QAction* option = selectColMenu.addAction( qfu(VLC_META_##meta) );      \
+    option->setCheckable( true );                                           \
+    option->setChecked( model->shownFlags() & VLC_META_ENGINE_##meta );     \
+    ContextUpdateMapper->setMapping( option, VLC_META_ENGINE_##meta );      \
+    CONNECT( option, triggered(), ContextUpdateMapper, map() );             \
+}
+
     CONNECT( ContextUpdateMapper, mapped( int ),  model, viewchanged( int ) );
 
     ADD_META_ACTION( TITLE );
@@ -255,13 +272,15 @@ void StandardPLPanel::popupSelectColumn( QPoint )
 #undef ADD_META_ACTION
 
     selectColMenu.exec( QCursor::pos() );
- }
+}
 
+/* ClearFilter LineEdit */
 void StandardPLPanel::clearFilter()
 {
     searchLine->setText( "" );
 }
 
+/* Search in the playlist */
 void StandardPLPanel::search( QString searchText )
 {
     model->search( searchText );
@@ -290,6 +309,8 @@ void StandardPLPanel::removeItem( int i_id )
     model->removeItem( i_id );
 }
 
+/* Delete and Suppr key remove the selection 
+   FilterKey function and code function */
 void StandardPLPanel::keyPressEvent( QKeyEvent *e )
 {
     switch( e->key() )
index 09d47c3f3cd87dc57c3b204fefd850990de6222d..a01c326c58cdc2efb30b1bd38a2a544d64da4121 100644 (file)
@@ -24,7 +24,7 @@
 #include "dialogs/playlist.hpp"
 
 #include "main_interface.hpp"
-#include "components/interface_widgets.hpp"
+#include "components/playlist/playlist.hpp"
 #include "dialogs_provider.hpp"
 #include "menus.hpp"
 
index 8764aa163009e782d8c606cac875270309d78d9d..64eaab258b6b4ff4dcdf7581d992b4972b53ce28 100644 (file)
@@ -29,6 +29,7 @@
 #include "util/customwidgets.hpp"
 #include "dialogs_provider.hpp"
 #include "components/interface_widgets.hpp"
+#include "components/playlist/playlist.hpp"
 #include "dialogs/extended.hpp"
 #include "dialogs/playlist.hpp"
 #include "menus.hpp"