Fix Playlist resizing and positionning.
authorJean-Baptiste Kempf <jb@videolan.org>
Mon, 25 Aug 2008 05:28:07 +0000 (22:28 -0700)
committerJean-Baptiste Kempf <jb@videolan.org>
Mon, 25 Aug 2008 05:28:07 +0000 (22:28 -0700)
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/ui/sout.ui

index c55b0dc..3712d17 100644 (file)
@@ -134,11 +134,6 @@ void PlaylistWidget::setArt( QString url )
     }
 }
 
     }
 }
 
-QSize PlaylistWidget::sizeHint() const
-{
-   return QSize( 600 , 300 );
-}
-
 PlaylistWidget::~PlaylistWidget()
 {
     getSettings()->beginGroup("playlistdialog");
 PlaylistWidget::~PlaylistWidget()
 {
     getSettings()->beginGroup("playlistdialog");
index 8401688..d1cf059 100644 (file)
@@ -47,7 +47,6 @@ class PlaylistWidget : public QSplitter
 public:
     PlaylistWidget( intf_thread_t *_p_i, QWidget *parent ) ;
     virtual ~PlaylistWidget();
 public:
     PlaylistWidget( intf_thread_t *_p_i, QWidget *parent ) ;
     virtual ~PlaylistWidget();
-    QSize sizeHint() const;
 private:
     PLSelector *selector;
     PLPanel *rightPanel;
 private:
     PLSelector *selector;
     PLPanel *rightPanel;
index faed371..2652226 100644 (file)
@@ -222,7 +222,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     if( settings->value( "playlist-visible", 0 ).toInt() ) togglePlaylist();
     settings->endGroup();
 
     if( settings->value( "playlist-visible", 0 ).toInt() ) togglePlaylist();
     settings->endGroup();
 
-
     /* Final sizing and showing */
     setMinimumWidth( __MAX( controls->sizeHint().width(),
                             menuBar()->sizeHint().width() ) );
     /* Final sizing and showing */
     setMinimumWidth( __MAX( controls->sizeHint().width(),
                             menuBar()->sizeHint().width() ) );
@@ -248,11 +247,14 @@ MainInterface::~MainInterface()
     msg_Dbg( p_intf, "Destroying the main interface" );
 
     if( playlistWidget )
     msg_Dbg( p_intf, "Destroying the main interface" );
 
     if( playlistWidget )
-        playlistWidget->savingSettings();
+    {
+        if( !isDocked() )
+            QVLCTools::saveWidgetPosition( p_intf, "Playlist", playlistWidget );
+    }
 
     settings->beginGroup( "MainWindow" );
 
 
     settings->beginGroup( "MainWindow" );
 
-    // settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) );
+    settings->setValue( "pl-dock-status", (int)i_pl_dock );
     settings->setValue( "playlist-visible", (int)playlistVisible );
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
     settings->setValue( "playlist-visible", (int)playlistVisible );
     settings->setValue( "adv-controls",
                         getControlsVisibilityStatus() & CONTROLS_ADVANCED );
@@ -586,8 +588,6 @@ void MainInterface::toggleFSC()
    QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) );
 }
 
    QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) );
 }
 
-
-//FIXME remove me at the end...
 void MainInterface::debug()
 {
 #ifndef NDEBUG
 void MainInterface::debug()
 {
 #ifndef NDEBUG
@@ -733,46 +733,36 @@ int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
  **/
 void MainInterface::togglePlaylist()
 {
  **/
 void MainInterface::togglePlaylist()
 {
-    THEDP->playlistDialog();
-#if 0
     /* CREATION
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
     /* CREATION
     If no playlist exist, then create one and attach it to the DockPL*/
     if( !playlistWidget )
     {
-        playlistWidget = new PlaylistWidget( p_intf, settings, dockPL );
-
-        /* Add it to the parent DockWidget */
-        dockPL->setWidget( playlistWidget );
+        playlistWidget = new PlaylistWidget( p_intf, this );
 
 
-        /* Add the dock to the main Interface */
-        addDockWidget( Qt::BottomDockWidgetArea, dockPL );
+        i_pl_dock = (pl_dock_e)getSettings()
+                         ->value( "pl-dock-status", PL_UNDOCKED ).toInt();
+        if( i_pl_dock == PL_UNDOCKED )
+        {
+            playlistWidget->setWindowFlags( Qt::Window );
 
 
-        /* Make the playlist floating is requested. Default is not. */
-        settings->beginGroup( "MainWindow" );
-        if( settings->value( "playlist-floats", 1 ).toInt() )
+            QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
+                    playlistWidget, QSize( 600, 300 ) );
+        }
+        else
         {
         {
-            msg_Dbg( p_intf, "we don't want the playlist inside");
-            dockPL->setFloating( true );
+            mainLayout->insertWidget( 4, playlistWidget );
         }
         }
-        settings->endGroup();
-        settings->beginGroup( "playlist" );
-        dockPL->move( settings->value( "pos", QPoint( 0,0 ) ).toPoint() );
-        QSize newSize = settings->value( "size", QSize( 400, 300 ) ).toSize();
-        if( newSize.isValid() )
-            dockPL->resize( newSize );
-        settings->endGroup();
-
-        dockPL->show();
         playlistVisible = true;
         playlistVisible = true;
+
+        playlistWidget->show();
     }
     else
     {
     /* toggle the visibility of the playlist */
     }
     else
     {
     /* toggle the visibility of the playlist */
-       TOGGLEV( dockPL );
+       TOGGLEV( playlistWidget );
        resize( sizeHint() );
        playlistVisible = !playlistVisible;
     }
        resize( sizeHint() );
        playlistVisible = !playlistVisible;
     }
-    #endif
 }
 
 /* Function called from the menu to undock the playlist */
 }
 
 /* Function called from the menu to undock the playlist */
@@ -782,6 +772,10 @@ void MainInterface::undockPlaylist()
     adjustSize();
 }
 
     adjustSize();
 }
 
+void MainInterface::dockPlaylist( pl_dock_e i_pos )
+{
+}
+
 void MainInterface::toggleMinimalView()
 {
     /* HACK for minimalView, see menus.cpp */
 void MainInterface::toggleMinimalView()
 {
     /* HACK for minimalView, see menus.cpp */
index 1d7c026..2efeebc 100644 (file)
@@ -51,12 +51,19 @@ class QMenu;
 class QSize;
 //class QDockWidet;
 
 class QSize;
 //class QDockWidet;
 
-enum{
+enum {
     CONTROLS_HIDDEN = 0x0,
     CONTROLS_VISIBLE = 0x1,
     CONTROLS_ADVANCED = 0x2
 };
 
     CONTROLS_HIDDEN = 0x0,
     CONTROLS_VISIBLE = 0x1,
     CONTROLS_ADVANCED = 0x2
 };
 
+typedef enum pl_dock_e {
+    PL_UNDOCKED,
+    PL_BOTTOM,
+    PL_RIGHT,
+    PL_LEFT
+} pl_dock_e;
+
 class MainInterface : public QVLCMW
 {
     Q_OBJECT;
 class MainInterface : public QVLCMW
 {
     Q_OBJECT;
@@ -114,12 +121,10 @@ private:
 
     /* Video */
     VideoWidget         *videoWidget;
 
     /* Video */
     VideoWidget         *videoWidget;
-    //    QSize                savedVideoSize;
 
     BackgroundWidget    *bgWidget;
     VisualSelector      *visualSelector;
     PlaylistWidget      *playlistWidget;
 
     BackgroundWidget    *bgWidget;
     VisualSelector      *visualSelector;
     PlaylistWidget      *playlistWidget;
-//    QDockWidget         *dockPL;
 
     bool                 videoIsActive; ///< Having a video now / THEMIM->hasV
     bool                 videoEmbeddedFlag; ///< Want an external Video Window
 
     bool                 videoIsActive; ///< Having a video now / THEMIM->hasV
     bool                 videoEmbeddedFlag; ///< Want an external Video Window
@@ -129,6 +134,8 @@ private:
     bool                 b_remainingTime; /* Show elapsed or remaining time */
     bool                 bgWasVisible;
     int                  i_visualmode; ///< Visual Mode
     bool                 b_remainingTime; /* Show elapsed or remaining time */
     bool                 bgWasVisible;
     int                  i_visualmode; ///< Visual Mode
+    pl_dock_e            i_pl_dock;
+    bool                 isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
 
     input_thread_t      *p_input;    ///< Main input associated to the playlist
 
 
     input_thread_t      *p_input;    ///< Main input associated to the playlist
 
@@ -143,6 +150,7 @@ private:
 
 public slots:
     void undockPlaylist();
 
 public slots:
     void undockPlaylist();
+    void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
     void toggleMinimalView();
     void togglePlaylist();
     void toggleUpdateSystrayMenu();
     void toggleMinimalView();
     void togglePlaylist();
     void toggleUpdateSystrayMenu();
index 2f99cd3..e171087 100644 (file)
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>644</width>
     <x>0</x>
     <y>0</y>
     <width>644</width>
-    <height>784</height>
+    <height>799</height>
    </rect>
   </property>
   <property name="windowTitle" >
    </rect>
   </property>
   <property name="windowTitle" >
           <property name="wordWrap" >
            <bool>true</bool>
           </property>
           <property name="wordWrap" >
            <bool>true</bool>
           </property>
+          <property name="buddy" >
+           <cstring>UDPOutput</cstring>
+          </property>
          </widget>
         </item>
         <item row="5" column="1" >
          </widget>
         </item>
         <item row="5" column="1" >
        <rect>
         <x>0</x>
         <y>0</y>
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>624</width>
-        <height>129</height>
+        <width>628</width>
+        <height>135</height>
        </rect>
       </property>
       <attribute name="title" >
        </rect>
       </property>
       <attribute name="title" >