Qt4 - Remember playlist's size.
authorJean-Baptiste Kempf <jb@videolan.org>
Sat, 22 Dec 2007 03:20:11 +0000 (03:20 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sat, 22 Dec 2007 03:20:11 +0000 (03:20 +0000)
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/dialogs/playlist.cpp
modules/gui/qt4/main_interface.cpp

index b5edd8b..2a0a72c 100644 (file)
@@ -38,8 +38,8 @@
  * Playlist Widget. The embedded playlist
  **********************************************************************/
 
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) :
-                                p_intf ( _p_i )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *_parent ) :
+                                p_intf ( _p_i ), parent( _parent )
 {
     /* Left Part and design */
     QSplitter *leftW = new QSplitter( Qt::Vertical, this );
@@ -126,9 +126,9 @@ PlaylistWidget::~PlaylistWidget()
 void PlaylistWidget::savingSettings( QSettings *settings )
 {
     settings->beginGroup( "playlist" );
-    settings->setValue( "pos", pos() );
-    settings->setValue( "size", size() );
-    settings->setValue("splitterSizes", saveState() );
+    settings->setValue( "pos", parent->pos() );
+    settings->setValue( "size", parent->size() );
+    settings->setValue( "splitterSizes", saveState() );
     settings->endGroup();
 }
 
index c7370db..fb6df60 100644 (file)
@@ -41,7 +41,7 @@ class PlaylistWidget : public QSplitter
 {
     Q_OBJECT;
 public:
-    PlaylistWidget( intf_thread_t *_p_i, QSettings *settings ) ;
+    PlaylistWidget( intf_thread_t *_p_i, QSettings *settings, QWidget *parent ) ;
     virtual ~PlaylistWidget();
     QSize sizeHint() const;
     void savingSettings( QSettings *settings );
@@ -51,6 +51,7 @@ private:
     QPushButton *addButton;
     QLabel *art;
     QString prevArt;
+    QWidget *parent;
 protected:
     intf_thread_t *p_intf;
 private slots:
index 542e90f..52e64c9 100644 (file)
@@ -47,16 +47,14 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
 
     QHBoxLayout *l = new QHBoxLayout( centralWidget() );
     QSettings *settings = new QSettings( "vlc", "vlc-qt-interface" );
-    PlaylistWidget *plw = new PlaylistWidget( p_intf, settings );
+    PlaylistWidget *plw = new PlaylistWidget( p_intf, settings, this );
     l->addWidget( plw );
 
     readSettings( "playlist", QSize( 600,700 ) );
 }
 
 PlaylistDialog::~PlaylistDialog()
-{
-    writeSettings( "playlist" );
-}
+{}
 
 void PlaylistDialog::dropEvent( QDropEvent *event )
 {
index db7db1d..c21e59f 100644 (file)
@@ -397,9 +397,6 @@ void MainInterface::handleMainUi( QSettings *settings )
     if( videoEmbeddedFlag )
     {
         videoWidget = new VideoWidget( p_intf );
-        //videoWidget->widgetSize = QSize( 16, 16 );
-        //videoWidget->hide();
-        //videoWidget->resize( videoWidget->widgetSize );
         mainLayout->insertWidget( 0, videoWidget );
 
         p_intf->pf_request_window  = ::DoRequest;
@@ -702,7 +699,7 @@ void MainInterface::togglePlaylist()
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf, settings );
+        playlistWidget = new PlaylistWidget( p_intf, settings, dockPL );
 
         /* Add it to the parent DockWidget */
         dockPL->setWidget( playlistWidget );
@@ -718,6 +715,10 @@ void MainInterface::togglePlaylist()
             dockPL->setFloating( true );
         }
         settings->endGroup();
+        settings->beginGroup( "playlist" );
+        dockPL->move( settings->value( "pos", QPoint( 0,0 ) ).toPoint() );
+        dockPL->resize( settings->value( "size", QSize( 400, 300 ) ).toSize() );
+        settings->endGroup();
         dockPL->show();
     }
     else