]> git.sesse.net Git - vlc/commitdiff
Qt4 - SHould Fix -- Videos are always started with an incredibly small size.
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 16 Dec 2007 04:49:40 +0000 (04:49 +0000)
committerJean-Baptiste Kempf <jb@videolan.org>
Sun, 16 Dec 2007 04:49:40 +0000 (04:49 +0000)
 -- There is no "auto size" feature as in the wx interface to
 automatically resize the interface so the video is displayed in its
 native size.
  -- The interface doesn't resize itself down to its minimal size when
  video playback is stopped and the control widgets re-organise themselves
  in a weird way.
Should fix part of playlist resizing.

modules/gui/qt4/components/interface_widgets.cpp
modules/gui/qt4/components/interface_widgets.hpp
modules/gui/qt4/main_interface.cpp
modules/gui/qt4/main_interface.hpp
modules/gui/qt4/qt4.hpp

index 20c86c2d094bc7cd9f70305dd96ea49488886e2a..ccfc4db23335e40258aa79644422c8c0ce51f54a 100644 (file)
@@ -55,9 +55,10 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
 {
     vlc_mutex_init( p_intf, &lock );
     p_vout = NULL;
-
-    CONNECT( this, askResize(), this, SetMinSize() );
-    CONNECT( this, askVideoToShow(), this, show() );
+    hide(); setMinimumSize( 16, 16 );
+   // CONNECT( this, askResize( int, int ), this, SetSizing( int, int ) );
+    CONNECT( this, askVideoWidgetToShow(), this, show() );
     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
 }
 
@@ -86,23 +87,29 @@ QSize VideoWidget::sizeHint() const
     return widgetSize;
 }
 
+/**
+ * Request the video to avoid the conflicts 
+ **/
 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
                            unsigned int *pi_width, unsigned int *pi_height )
 {
-    emit askVideoToShow();
+    emit askVideoWidgetToShow();
     if( p_vout )
     {
         msg_Dbg( p_intf, "embedded video already in use" );
         return NULL;
     }
     p_vout = p_nvout;
-    emit askResize();
     return ( void* )winId();
 }
 
-void VideoWidget::SetMinSize()
+/* Set the Widget to the correct Size */
+void VideoWidget::SetSizing( unsigned int w, unsigned int h )
 {
-    setMinimumSize( 16, 16 );
+    resize( w, h );
+    //updateGeometry(); // Needed for deinterlace
+    msg_Dbg( p_intf, "%i %i", sizeHint().height(), sizeHint().width() );
+    emit askResize();
 }
 
 void VideoWidget::release( void *p_win )
@@ -563,7 +570,7 @@ ControlsWidget::ControlsWidget( intf_thread_t *_p_i,
                               VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
 
     /* Volume control connection */
-    resize( QSize( 400, 60 ) );
+    //resize( QSize( 300, 60 ) );
     CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
     msg_Dbg( p_intf, "controls size: %i - %i", size().width(), size().height() );
 }
index 3516f2e2e6783c914bfc638634f112bd0b4ad87c..3bfd51301c0081a2afa3d66fa909a0b908ca4960 100644 (file)
@@ -66,9 +66,9 @@ private:
     vlc_mutex_t lock;
 signals:
     void askResize();
-    void askVideoToShow();
-private slots:
-    void SetMinSize();
+    void askVideoWidgetToShow();
+public slots:
+    void SetSizing( unsigned int, unsigned int );
 };
 
 /******************** Background Widget ****************/
index 537ab8f7b82fda7388fd418bcfc5f498d3cdc312..280b96b2429ac5bb05b46c694dae08662e99de26 100644 (file)
@@ -91,25 +91,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     videoIsActive = false;
     input_name = "";
 
-    /**
-     * Ask for the network policy on FIRST STARTUP
-     **/
-    if( config_GetInt( p_intf, "privacy-ask") )
-    {
-        QList<ConfigControl *> controls;
-        if( privacyDialog( controls ) == QDialog::Accepted )
-        {
-            QList<ConfigControl *>::Iterator i;
-            for(  i = controls.begin() ; i != controls.end() ; i++ )
-            {
-                ConfigControl *c = qobject_cast<ConfigControl *>(*i);
-                c->doApply( p_intf );
-            }
-
-            config_PutInt( p_intf,  "privacy-ask" , 0 );
-            config_SaveConfigFile( p_intf, NULL );
-        }
-    }
+    /* Ask for privacy */
+    privacy();
 
     /**
      *  Configuration and settings
@@ -161,7 +144,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /****************
      *  Status Bar  *
      ****************/
-
     /* Widgets Creation*/
     b_remainingTime = false;
     timeLabel = new TimeLabel;
@@ -218,24 +200,26 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     if( config_GetInt( p_intf, "qt-minimal-view" ) )
         toggleMinimalView();
 
-    /* Init input manager */
+    /********************
+     * Input Manager    *
+     ********************/
     MainInputManager::getInstance( p_intf );
-    ON_TIMEOUT( updateOnTimer() );
-    //ON_TIMEOUT( debug() ):;
-
+    
     /********************
      * Various CONNECTs *
      ********************/
-
     /* Connect the input manager to the GUI elements it manages */
+    
     /* It is also connected to the control->slider, see the ControlsWidget */
     CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
              this, setDisplayPosition( float, int, int ) );
-
+    /* Change the SpeedRate in the Status */
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
 
     /**
      * Connects on nameChanged()
+     * Those connects are not merged because different options can trigger
+     * them down.
      */
     /* Naming in the controller statusbar */
     CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
@@ -253,7 +237,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
              setVLCWindowsTitle( QString ) );
     }
 
-    /** CONNECTS on PLAY_STATUS **/
+    /**
+     * CONNECTS on PLAY_STATUS 
+     **/
     /* Status on the main controller */
     CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
     /* and in the systray */
@@ -263,6 +249,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
                  updateSystrayTooltipStatus( int ) );
     }
 
+    /** OnTimeOut **/
+    // TODO
+    ON_TIMEOUT( updateOnTimer() );
+    //ON_TIMEOUT( debug() );
+
     /**
      * Callbacks
      **/
@@ -280,13 +271,17 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
         vlc_object_release( p_playlist );
     }
 
+    /* VideoWidget connect mess to avoid different threads speaking to each other */
     CONNECT( this, askReleaseVideo( void * ), this, releaseVideoSlot( void * ) );
+    CONNECT( this, askVideoToResize( unsigned int, unsigned int ), 
+             videoWidget, SetSizing( unsigned int, unsigned int ) );
+    CONNECT( this, askUpdate(), this, doComponentsUpdate() );
 
     CONNECT( dockPL, topLevelChanged( bool ), this, doComponentsUpdate() );
     CONNECT( controls, advancedControlsToggled( bool ), 
              this, doComponentsUpdate() );
 
-    resize( settings->value( "size", QSize( 300, 80 ) ).toSize() );
+    resize( settings->value( "size", QSize( 350, 60 ) ).toSize() );
     updateGeometry();
     settings->endGroup();
 }
@@ -354,7 +349,7 @@ void MainInterface::handleMainUi( QSettings *settings )
 
     /* Margins, spacing */
     main->setContentsMargins( 0, 0, 0, 0 );
-    main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
+   // main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
     mainLayout->setMargin( 0 );
 
     /* Create the CONTROLS Widget */
@@ -397,7 +392,8 @@ void MainInterface::handleMainUi( QSettings *settings )
     if( videoEmbeddedFlag )
     {
         videoWidget = new VideoWidget( p_intf );
-        videoWidget->widgetSize = QSize( 1, 1 );
+        //videoWidget->widgetSize = QSize( 16, 16 );
+        //videoWidget->hide();
         //videoWidget->resize( videoWidget->widgetSize );
         mainLayout->insertWidget( 0, videoWidget );
 
@@ -410,6 +406,29 @@ void MainInterface::handleMainUi( QSettings *settings )
     updateGeometry();
 }
 
+inline void MainInterface::privacy()
+{
+    /**
+     * Ask for the network policy on FIRST STARTUP
+     **/
+    if( config_GetInt( p_intf, "privacy-ask") )
+    {
+        QList<ConfigControl *> controls;
+        if( privacyDialog( controls ) == QDialog::Accepted )
+        {
+            QList<ConfigControl *>::Iterator i;
+            for(  i = controls.begin() ; i != controls.end() ; i++ )
+            {
+                ConfigControl *c = qobject_cast<ConfigControl *>(*i);
+                c->doApply( p_intf );
+            }
+
+            config_PutInt( p_intf,  "privacy-ask" , 0 );
+            config_SaveConfigFile( p_intf, NULL );
+        }
+    }
+}
+
 int MainInterface::privacyDialog( QList<ConfigControl *> controls )
 {
     QDialog *privacy = new QDialog( this );
@@ -496,18 +515,31 @@ void MainInterface::debug()
 */
 QSize MainInterface::sizeHint() const
 {
-    QSize tempSize = controls->sizeHint() +
-        QSize( 100, menuBar()->size().height() + statusBar()->size().height() );
+    int nwidth = controls->sizeHint().width();
+    int nheight = controls->sizeHint().height();
+                + menuBar()->size().height() 
+                + statusBar()->size().height();
 
+    msg_Dbg( p_intf, "1 %i %i", nheight, nwidth );
     if( VISIBLE( bgWidget ) )
-        tempSize += bgWidget->sizeHint();
+    {
+        nheight += bgWidget->size().height();
+        nwidth  = bgWidget->size().width();
+    }
     else if( videoIsActive )
-        tempSize += videoWidget->size();
-
+    {
+        nheight += videoWidget->size().height();
+        nwidth  = videoWidget->size().width();
+        msg_Dbg( p_intf, "2 %i %i", nheight, nwidth );
+    }
     if( !dockPL->isFloating() && dockPL->widget() )
-        tempSize += dockPL->widget()->size();
-
-    return tempSize;
+    {
+        nheight += dockPL->size().height();
+        nwidth = MAX( nwidth, dockPL->size().width() );
+        msg_Dbg( p_intf, "3 %i %i", nheight, nwidth );
+    }
+    msg_Dbg( p_intf, "4 %i %i", nheight, nwidth );
+    return QSize( nwidth, nheight );
 }
 
 #if 0
@@ -559,36 +591,42 @@ private:
     bool onTop;
 };
 
+/* function called from ::DoRequest in order to show a nice VideoWidget
+    at the good size */
 void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
                                    int *pi_y, unsigned int *pi_width,
                                    unsigned int *pi_height )
 {
+    bool bgWasVisible = false;
+
+    /* Request the videoWidget */
     void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
-    if( ret )
+    if( ret ) /* The videoWidget is available */
     {
-        videoIsActive = true;
-        bool bgWasVisible = false;
-
-        /* Did we have a bg ? */
+        /* Did we have a bg ? Hide it! */
         if( VISIBLE( bgWidget) )
         {
             bgWasVisible = true;
             emit askBgWidgetToToggle();
         }
 
-        if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
+        /*if( THEMIM->getIM()->hasVideo() || !bgWasVisible )
         {
             videoWidget->widgetSize = QSize( *pi_width, *pi_height );
         }
         else /* Background widget available, use its size */
-        {
+        /*{
             /* Ok, our visualizations are bad, so don't do this for the moment
              * use the requested size anyway */
             // videoWidget->widgetSize = bgWidget->widgeTSize;
-            videoWidget->widgetSize = QSize( *pi_width, *pi_height );
-        }
-        videoWidget->updateGeometry(); // Needed for deinterlace
-        updateGeometry();
+          /*  videoWidget->widgetSize = QSize( *pi_width, *pi_height );
+        }*/
+
+        videoWidget->widgetSize = QSize( *pi_width, *pi_height );
+        emit askVideoToResize( *pi_width, *pi_height );
+
+        videoIsActive = true;
+        emit askUpdate();
     }
     return ret;
 }
@@ -603,11 +641,11 @@ void MainInterface::releaseVideoSlot( void *p_win )
     videoWidget->release( p_win );
     videoWidget->hide();
 
-    if( bgWidget )
+    if( bgWidget )// WORONG
         bgWidget->show();
 
     videoIsActive = false;
-    updateGeometry();
+    emit askUpdate();
 }
 
 int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
@@ -707,7 +745,9 @@ void MainInterface::toggleMinimalView()
 /* Well, could it, actually ? Probably dangerous ... */
 void MainInterface::doComponentsUpdate()
 {
+    msg_Dbg( p_intf, "coi " );
     updateGeometry();
+    resize( sizeHint() );
 }
 
 /* toggling advanced controls buttons */
@@ -767,7 +807,6 @@ void MainInterface::setDisplayPosition( float pos, int time, int length )
 void MainInterface::toggleTimeDisplay()
 {
     b_remainingTime = !b_remainingTime;
-    //b_remainingTime = ( b_remainingTime ? false : true );
 }
 
 void MainInterface::setName( QString name )
index 00887a6e2f51aed0ff0661cd422ff499db8f7274..ecf166e80e00f3ad81ad8d4ae9b8cd827baf350b 100644 (file)
@@ -96,7 +96,9 @@ private:
     bool                 need_components_update;
 
     void handleMainUi( QSettings* );
+    void privacy();
     void handleSystray();
+    //void buildStatus();
 
     void createSystray();
     int privacyDialog( QList<ConfigControl *> controls );
@@ -159,8 +161,10 @@ private slots:
     void showSpeedMenu( QPoint );
 signals:
     void askReleaseVideo( void * );
+    void askVideoToResize( unsigned int, unsigned int );
     void askVideoToToggle();
     void askBgWidgetToToggle();
+    void askUpdate();
 };
 
 #endif
index 7670514801884e3a386ac79b931cbd30c2cc8d93..18a5452f453325e998a2dbb3c26e34405608d03a 100644 (file)
@@ -92,6 +92,8 @@ struct intf_sys_t
 
 #define TOGGLEV( x ) { if( x->isVisible() ) x->hide();          \
             else  x->show(); }
+            
+#define MAX(A,B) ( (A) > (B) ? (A):(B))
 
 static int DialogEvent_Type = QEvent::User + 1;
 //static int PLUndockEvent_Type = QEvent::User + 2;