]> git.sesse.net Git - vlc/commitdiff
* Add random/loop buttons
authorClément Stenac <zorglub@videolan.org>
Sun, 6 Aug 2006 17:12:01 +0000 (17:12 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 6 Aug 2006 17:12:01 +0000 (17:12 +0000)
* Improve hilighting

modules/gui/qt4/components/playlist/panels.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/dialogs/playlist.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/menus.cpp
modules/gui/qt4/playlist_model.cpp
modules/gui/qt4/playlist_model.hpp
modules/gui/qt4/util/qvlcframe.hpp

index 3d0c9c9e5abe83fdd5e944928f2f1a64cf84a39d..9bb2c53ad406f42a2fe237cfceaf8412d5f8dd04 100644 (file)
@@ -31,6 +31,7 @@
 
 class QTreeView;
 class PLModel;
+class QPushButton;
 
 /**
  * \todo Share a single model between views using a filterproxy
@@ -62,10 +63,13 @@ public:
 private:
     PLModel *model;
     QTreeView *view;
+    QPushButton *repeatButton , *randomButton;
 public slots:
     virtual void setRoot( int );
 private slots:
     void handleExpansion( const QModelIndex& );
+    void toggleRandom();
+    void toggleRepeat();
 };
 
 #endif
index d510b3023aa4e5c8d9739cabf6a665cbd937adc3..27cc33a8f00101a867831e2d6b975ea26d80951a 100644 (file)
@@ -24,6 +24,8 @@
 #include "playlist_model.hpp"
 #include "components/playlist/panels.hpp"
 #include <QTreeView>
+#include <QPushButton>
+#include <QHBoxLayout>
 #include <QVBoxLayout>
 #include <QHeaderView>
 #include "qt4.hpp"
@@ -35,7 +37,6 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
                                   PLPanel( _parent, _p_intf )
 {
     model = new PLModel( p_playlist, p_root, -1, this );
-    model->Rebuild();
     view = new QTreeView( 0 );
     view->setModel(model);
     view->header()->resizeSection( 0, 300 );
@@ -47,24 +48,66 @@ StandardPLPanel::StandardPLPanel( QWidget *_parent, intf_thread_t *_p_intf,
              SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ),
              this, SLOT( handleExpansion( const QModelIndex& ) ) );
 
+    model->Rebuild();
+
     QVBoxLayout *layout = new QVBoxLayout();
     layout->setSpacing( 0 ); layout->setMargin( 0 );
+
+    QHBoxLayout *buttons = new QHBoxLayout();
+    repeatButton = new QPushButton( this );
+    buttons->addWidget( repeatButton );
+    randomButton = new QPushButton( this );
+    buttons->addWidget( randomButton );
+
+    if( model->hasRandom() ) randomButton->setText( qtr( "Random" ) );
+    else randomButton->setText( qtr( "No random" ) );
+
+    if( model->hasRepeat() ) repeatButton->setText( qtr( "Repeat One" ) );
+    else if( model->hasLoop() ) repeatButton->setText( qtr( "Repeat All" ) );
+    else repeatButton->setText( qtr( "No Repeat" ) );
+
+    connect( repeatButton, SIGNAL( clicked() ), this, SLOT( toggleRepeat() ));
+    connect( randomButton, SIGNAL( clicked() ), this, SLOT( toggleRandom() ));
+
     layout->addWidget( view );
+    layout->addLayout( buttons );
     setLayout( layout );
 }
 
+void StandardPLPanel::toggleRepeat()
+{
+    if( model->hasRepeat() )
+    {
+        model->setRepeat( false ); model->setLoop( true );
+        repeatButton->setText( qtr( "Repeat All" ) );
+    }
+    else if( model->hasLoop() )
+    {
+        model->setRepeat( false ) ; model->setLoop( false );
+        repeatButton->setText( qtr( "No Repeat" ) );
+    }
+    else
+    {
+        model->setRepeat( true );
+        repeatButton->setText( qtr( "Repeat One" ) );
+    }
+}
+
+void StandardPLPanel::toggleRandom()
+{
+    bool prev = model->hasRandom();
+    model->setRandom( !prev );
+    randomButton->setText( prev ? qtr( "No Random" ) : qtr( "Random" ) );
+}
+
 void StandardPLPanel::handleExpansion( const QModelIndex &index )
 {
-    fprintf( stderr, "Checking expansion\n" );
     QModelIndex parent;
     if( model->isCurrent( index ) )
     {
-        fprintf( stderr, "It is the current one\n" ) ;
         parent = index;
         while( parent.isValid() )
         {
-            fprintf( stderr, "Expanding %s\n",
-         (model->data( parent, Qt::DisplayRole )).toString().toUtf8().data() );
             view->setExpanded( parent, true );
             parent = model->parent( parent );
         }
index cd8aacab3746b608272d5a98ff1f93fcde629ca8..9f549f2b20ae5b6f3e73c6aa4564fa2584427b33 100644 (file)
 #include "components/playlist/panels.hpp"
 #include "components/playlist/selector.hpp"
 #include <QHBoxLayout>
+#include "menus.hpp"
 
 PlaylistDialog *PlaylistDialog::instance = NULL;
 
-PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
+PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
 {
     setWindowTitle( qtr( "Playlist" ) );
-    selector = new PLSelector( this, p_intf, THEPL );
-    selector->setMaximumWidth( 150 );
+    QWidget *main = new QWidget( this );
+    setCentralWidget( main );
+    QVLCMenu::createPlMenuBar( menuBar(), p_intf );
 
-    rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this, p_intf,
-                                   THEPL, THEPL->p_local_category ) );
+    selector = new PLSelector( centralWidget(), p_intf, THEPL );
+    selector->setMaximumWidth( 140 );
+
+    rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( centralWidget(),
+                              p_intf, THEPL, THEPL->p_local_category ) );
     connect( selector, SIGNAL( activated( int ) ),
              rightPanel, SLOT( setRoot( int ) ) );
 
     QHBoxLayout *layout = new QHBoxLayout();
     layout->addWidget( selector, 0 );
     layout->addWidget( rightPanel, 10 );
+    centralWidget()->setLayout( layout );
     readSettings( "playlist", QSize( 600,300 ) );
-    setLayout( layout );
 }
 
 PlaylistDialog::~PlaylistDialog()
index 9a393732cefdeee864199c2d85f24518c12dfaf8..11de34f8cc036773a37824742bf26bfb83e22988 100644 (file)
@@ -29,7 +29,7 @@
 class PLSelector;
 class PLPanel;
 
-class PlaylistDialog : public QVLCFrame
+class PlaylistDialog : public QVLCMW
 {
     Q_OBJECT;
 public:
index 808187a7eedb25ff1caf442dab3fdecaf5cf40b1..fcd175f6b5e79da4b6d731490ac17dac24be8146 100644 (file)
@@ -51,8 +51,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     ui.hboxLayout->insertWidget( 0, slider );
     ui.prevButton->setText( "" );
     ui.nextButton->setText( "" );
-    ui.playButton->setText( "" ); 
-    ui.stopButton->setText( "" ); 
+    ui.playButton->setText( "" );
+    ui.stopButton->setText( "" );
     ui.prevButton->setIcon( QIcon( ":/pixmaps/previous.png" ) );
     ui.nextButton->setIcon( QIcon( ":/pixmaps/next.png" ) );
     ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
index 572f14e54d83df19c8dd50d7fc81bb115c5cadd4..4d374fdd7d7158c3e12e054d26cdc9555a7b55ec 100644 (file)
@@ -135,6 +135,8 @@ void QVLCMenu::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
                            SLOT( simpleAppendDialog() ) );
     manageMenu->addSeparator();
     manageMenu->addMenu( SDMenu( p_intf ) );
+
+    bar->addMenu( manageMenu );
 }
 
 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf )
index 450b5ce29b9ebc59540ff60fd96ce8fcf29b6bb4..d2b886a626493a7b339a9cb94327d3f95f5b146e 100644 (file)
@@ -325,6 +325,36 @@ int PLModel::rowCount(const QModelIndex &parent) const
     return parentItem->childCount();
 }
 
+/************************* General playlist status ***********************/
+
+bool PLModel::hasRandom()
+{
+    if( var_GetBool( p_playlist, "random" ) ) return true;
+    return false;
+}
+bool PLModel::hasRepeat()
+{
+    if( var_GetBool( p_playlist, "repeat" ) ) return true;
+    return false;
+}
+bool PLModel::hasLoop()
+{
+    if( var_GetBool( p_playlist, "loop" ) ) return true;
+    return false;
+}
+void PLModel::setLoop( bool on )
+{
+    var_SetBool( p_playlist, "loop", on ? VLC_TRUE:VLC_FALSE );
+}
+void PLModel::setRepeat( bool on )
+{
+    var_SetBool( p_playlist, "repeat", on ? VLC_TRUE:VLC_FALSE );
+}
+void PLModel::setRandom( bool on )
+{
+    var_SetBool( p_playlist, "random", on ? VLC_TRUE:VLC_FALSE );
+}
+
 /************************* Lookups *****************************/
 
 PLItem *PLModel::FindById( PLItem *root, int i_id )
@@ -467,12 +497,22 @@ void PLModel::Rebuild()
     qDeleteAll( rootItem->children );
     /* Recreate from root */
     UpdateNodeChildren( rootItem );
+    if( p_playlist->status.p_item )
+    {
+        fprintf( stderr, "Playlist is playing" );
+        PLItem *currentItem = FindByInput( rootItem,
+                                     p_playlist->status.p_item->p_input->i_id );
+        if( currentItem )
+        {
+            fprintf( stderr, "Updating item\n" );
+            UpdateTreeItem( p_playlist->status.p_item, currentItem,
+                            true, false );
+        }
+    }
     PL_UNLOCK;
 
     /* And signal the view */
     emit layoutChanged();
-    /// \todo  Force current item to be updated
-
     addCallbacks();
 }
 
index 3a4156b631f3656495934dbd908e6cf091d52599..9b0cbc1d2b00cc23040be9acc66058038ba61ab6 100644 (file)
@@ -118,6 +118,7 @@ public:
     int i_items_to_append;
     void Rebuild();
     void rebuildRoot( playlist_item_t * );
+    bool hasRandom(); bool hasLoop(); bool hasRepeat();
 private:
     void addCallbacks();
     void delCallbacks();
@@ -148,6 +149,9 @@ private:
     int i_cached_input_id;
 public slots:
     void activateItem( const QModelIndex &index );
+    void setRandom( bool );
+    void setLoop( bool );
+    void setRepeat( bool );
 friend class PLItem;
 };
 
index c7b5af4300e0c8e4539a8ef4c7a339a8ce1bf06d..b3acf986965d81bfc84ff52f71bcf630e5ffc747 100644 (file)
@@ -130,6 +130,11 @@ public:
         QVLCFrame::fixStyle( this );
     }
     virtual ~QVLCMW() {};
+    void toggleVisible()
+    {
+        if( isVisible() ) hide();
+        else show();
+    }
 protected:
     intf_thread_t *p_intf;
     QSize mainSize;
@@ -138,10 +143,8 @@ protected:
     {
         QSettings settings( "VideoLAN", "VLC" );
         settings.beginGroup( name );
-        mainSize = settings.value( "size", defSize ).toSize();
-        QPoint npos = settings.value( "pos", QPoint( 0,0 ) ).toPoint();
-        if( npos.x() > 0 )
-            move( npos );
+        resize( settings.value( "size", defSize ).toSize() );
+        move( settings.value( "pos", QPoint( 0,0 ) ).toPoint() );
         settings.endGroup();
     }
     void readSettings( QString name )