Commit cd7c0d1e authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - SHould Fix -- Videos are always started with an incredibly small size.

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