Commit 1e01594c authored by Clément Stenac's avatar Clément Stenac

New system for handling elements in the main interface

Still full of bugs, please don't remove debug
parent 6b61e7bd
...@@ -42,12 +42,11 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*, ...@@ -42,12 +42,11 @@ static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
static void DoRelease( intf_thread_t *, void * ); static void DoRelease( intf_thread_t *, void * );
static int DoControl( intf_thread_t *, void *, int, va_list ); static int DoControl( intf_thread_t *, void *, int, va_list );
bool need_update;
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i ) 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;
setFrameStyle(QFrame::Panel | QFrame::Raised);
setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
} }
...@@ -74,6 +73,7 @@ VideoWidget::~VideoWidget() ...@@ -74,6 +73,7 @@ VideoWidget::~VideoWidget()
QSize VideoWidget::sizeHint() const QSize VideoWidget::sizeHint() const
{ {
fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
return widgetSize; return widgetSize;
} }
...@@ -101,9 +101,8 @@ void VideoWidget::release( void *p_win ) ...@@ -101,9 +101,8 @@ void VideoWidget::release( void *p_win )
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) : BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
QFrame( NULL ), p_intf( _p_i ) QFrame( NULL ), p_intf( _p_i )
{ {
setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
DrawBackground(); DrawBackground();
CONNECT( THEMIM->getIM(), audioStarted(), this, hasAudio() );
CONNECT( THEMIM->getIM(), audioStarted(), this, hasVideo() );
} }
BackgroundWidget::~BackgroundWidget() BackgroundWidget::~BackgroundWidget()
...@@ -140,23 +139,10 @@ int BackgroundWidget::CleanBackground() ...@@ -140,23 +139,10 @@ int BackgroundWidget::CleanBackground()
QSize BackgroundWidget::sizeHint() const QSize BackgroundWidget::sizeHint() const
{ {
fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
return widgetSize; return widgetSize;
} }
void BackgroundWidget::hasAudio()
{
/* We have video already, do nothing */
if( THEMIM->getIM()->b_has_video )
{
}
else
{
/* Show the panel to the user */
fprintf( stderr, "Showing panel\n" );
}
}
void BackgroundWidget::resizeEvent( QResizeEvent *e ) void BackgroundWidget::resizeEvent( QResizeEvent *e )
{ {
if( e->size().height() < ICON_SIZE -1 ) if( e->size().height() < ICON_SIZE -1 )
...@@ -174,6 +160,7 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e ) ...@@ -174,6 +160,7 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e )
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL), PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
p_intf( _p_intf ) p_intf( _p_intf )
{ {
setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
selector = new PLSelector( this, p_intf, THEPL ); selector = new PLSelector( this, p_intf, THEPL );
selector->setMaximumWidth( 130 ); selector->setMaximumWidth( 130 );
...@@ -197,6 +184,7 @@ PlaylistWidget::~PlaylistWidget() ...@@ -197,6 +184,7 @@ PlaylistWidget::~PlaylistWidget()
QSize PlaylistWidget::sizeHint() const QSize PlaylistWidget::sizeHint() const
{ {
fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );
return widgetSize; return widgetSize;
} }
...@@ -57,8 +57,6 @@ private: ...@@ -57,8 +57,6 @@ private:
QWidget *frame; QWidget *frame;
intf_thread_t *p_intf; intf_thread_t *p_intf;
vlc_mutex_t lock; vlc_mutex_t lock;
private slots:
void update();
}; };
/******************** Background Widget ****************/ /******************** Background Widget ****************/
...@@ -78,9 +76,6 @@ private: ...@@ -78,9 +76,6 @@ private:
int DrawBackground(); int DrawBackground();
int CleanBackground(); int CleanBackground();
intf_thread_t *p_intf; intf_thread_t *p_intf;
private slots:
void hasAudio();
void hasVideo();
}; };
......
...@@ -64,12 +64,18 @@ static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a ) ...@@ -64,12 +64,18 @@ static int DoControl( intf_thread_t *p_intf, void *p_win, int i_q, va_list a )
return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a ); return p_intf->p_sys->p_mi->controlVideo( p_win, i_q, a );
} }
bool embeddedPlaylistWasActive;
bool videoIsActive;
MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
{ {
settings = new QSettings( "VideoLAN", "VLC" ); settings = new QSettings( "VideoLAN", "VLC" );
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
need_components_update = false; need_components_update = false;
bgWidget = NULL; videoWidget = NULL; playlistWidget = NULL;
embeddedPlaylistWasActive = false;
videoIsActive= false;
setWindowTitle( QString::fromUtf8( _("VLC media player") ) ); setWindowTitle( QString::fromUtf8( _("VLC media player") ) );
handleMainUi( settings ); handleMainUi( settings );
...@@ -176,11 +182,11 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -176,11 +182,11 @@ void MainInterface::handleMainUi( QSettings *settings )
if( config_GetInt( p_intf, "qt-always-video" )) if( config_GetInt( p_intf, "qt-always-video" ))
{ {
bgWidget = new BackgroundWidget( p_intf ); // bgWidget = new BackgroundWidget( p_intf );
bgWidget->widgetSize = settings->value( "backgroundSize", // bgWidget->widgetSize = settings->value( "backgroundSize",
QSize( 200, 200 ) ).toSize(); // QSize( 200, 200 ) ).toSize();
ui.vboxLayout->insertWidget( 0, bgWidget ); // ui.vboxLayout->insertWidget( 0, bgWidget );
bgWidget->hide(); // bgWidget->hide();
} }
} }
...@@ -201,29 +207,63 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -201,29 +207,63 @@ void MainInterface::handleMainUi( QSettings *settings )
void MainInterface::calculateInterfaceSize() void MainInterface::calculateInterfaceSize()
{ {
int width = 0, height = 0; int width = 0, height = 0;
if( bgWidget->isVisible() ) fprintf( stderr, "Calculating size\n" );
if( bgWidget && bgWidget->isVisible() )
{ {
width += bgWidget->widgetSize.width(); width = bgWidget->widgetSize.width();
height += bgWidget->widgetSize.height(); height = bgWidget->widgetSize.height();
assert( !playlistWidget->isVisible() ); assert( !playlistWidget->isVisible() );
} }
if( playlistWidget->isVisible() ) else if( playlistWidget && playlistWidget->isVisible() )
{ {
width += playlistWidget->widgetSize.width(); width = playlistWidget->widgetSize.width();
height += playlistWidget->widgetSize.height(); height = playlistWidget->widgetSize.height();
fprintf( stderr, "Have %ix%i playlist\n", width, height );
} }
mainSize.setWidth( width + videoWidget->widgetSize.width() + else if( videoIsActive )
addSize.width() ); {
mainSize.setHeight( height + videoWidget->widgetSize.height() + width = videoWidget->widgetSize.width() ;
addSize.height() ); height = videoWidget->widgetSize.height();
fprintf( stderr, "Video Size %ix%i\n", videoWidget->widgetSize.width(), videoWidget->widgetSize.height() );
}
mainSize.setWidth( width + addSize.width() );
mainSize.setHeight( height + addSize.height() );
} }
/// To update !!
void MainInterface::resizeEvent( QResizeEvent *e ) void MainInterface::resizeEvent( QResizeEvent *e )
{ {
videoWidget->widgetSize.setHeight( e->size().height() - addSize.height() ); fprintf( stderr, "Resize event to %ix%i\n", e->size().width(), e->size().height() );
videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() ); /* Width : Always passed to all children. We are guaranteed it will
p_intf->p_sys->p_video->updateGeometry() ; * not go below PREF_W
* Height : Only passed to the only visible child
*/
if( videoWidget )
{
videoWidget->widgetSize.setWidth( e->size().width() -
addSize.width() );
if( videoIsActive )
{
videoWidget->widgetSize.setHeight( e->size().height() -
addSize.height() );
videoWidget->updateGeometry();
}
fprintf( stderr, "Video set to %ix%\ni", videoWidget->widgetSize.width(), videoWidget->widgetSize.height() );
}
if( playlistWidget )
{
playlistWidget->widgetSize.setWidth( e->size().width() -
addSize.width() );
if( playlistWidget->isVisible() )
{
playlistWidget->widgetSize.setHeight( e->size().height() -
addSize.height() );
playlistWidget->updateGeometry();
}
fprintf( stderr, "Playlist set to %ix%i\n",playlistWidget->widgetSize.width(), playlistWidget->widgetSize.height() );
}
// videoWidget->widgetSize.setHeight( e->size().height() - addSize.height() );
// videoWidget->widgetSize.setWidth( e->size().width() - addSize.width() );
// videoWidget->updateGeometry() ;
} }
void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
...@@ -231,9 +271,18 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, ...@@ -231,9 +271,18 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
unsigned int *pi_height ) unsigned int *pi_height )
{ {
void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height ); void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height );
if( ret )
{
videoIsActive = true;
if( playlistWidget && playlistWidget->isVisible() )
{
embeddedPlaylistWasActive = true;
playlistWidget->hide();
}
videoWidget->widgetSize = QSize( *pi_width, *pi_height ); videoWidget->widgetSize = QSize( *pi_width, *pi_height );
videoWidget->updateGeometry(); /// FIXME: Needed ? videoWidget->updateGeometry(); /// FIXME: Needed ?
need_components_update = true; need_components_update = true;
}
return ret; return ret;
} }
...@@ -242,8 +291,14 @@ void MainInterface::releaseVideo( void *p_win ) ...@@ -242,8 +291,14 @@ void MainInterface::releaseVideo( void *p_win )
videoWidget->release( p_win ); videoWidget->release( p_win );
videoWidget->widgetSize = QSize( 1, 1 ); videoWidget->widgetSize = QSize( 1, 1 );
videoWidget->updateGeometry(); videoWidget->updateGeometry();
if( embeddedPlaylistWasActive )
{
playlistWidget->show();
}
videoIsActive = false;
need_components_update = true; need_components_update = true;
} }
int MainInterface::controlVideo( void *p_window, int i_query, va_list args ) int MainInterface::controlVideo( void *p_window, int i_query, va_list args )
{ {
int i_ret = VLC_EGENERIC; int i_ret = VLC_EGENERIC;
...@@ -286,7 +341,6 @@ void MainInterface::playlist() ...@@ -286,7 +341,6 @@ void MainInterface::playlist()
if( playlistWidget ) if( playlistWidget )
{ {
/// \todo Destroy it /// \todo Destroy it
} }
THEDP->playlistDialog(); THEDP->playlistDialog();
return; return;
...@@ -297,12 +351,28 @@ void MainInterface::playlist() ...@@ -297,12 +351,28 @@ void MainInterface::playlist()
PlaylistDialog::killInstance(); PlaylistDialog::killInstance();
playlistWidget = new PlaylistWidget( p_intf ); playlistWidget = new PlaylistWidget( p_intf );
ui.vboxLayout->insertWidget( 0, playlistWidget ); ui.vboxLayout->insertWidget( 0, playlistWidget );
fprintf( stderr, "BUG ! Do not set size if it has already been changed\n" );
playlistWidget->widgetSize = settings->value( "playlistSize", playlistWidget->widgetSize = settings->value( "playlistSize",
QSize( 600, 300 ) ).toSize(); QSize( 600, 300 ) ).toSize();
playlistWidget->hide();
} }
/// Todo, reset its size ? /// Todo, reset its size ?
if( playlistWidget->isVisible() ) playlistWidget->show(); if( playlistWidget->isVisible() )
else playlistWidget->hide(); {
fprintf( stderr, "hiding playlist\n" );
playlistWidget->hide();
if( videoIsActive )
{
videoWidget->show();
}
}
else
{
fprintf( stderr, "showing playlist\n" );
playlistWidget->show();
if( videoIsActive )
videoWidget->hide();
}
calculateInterfaceSize(); calculateInterfaceSize();
resize( mainSize ); resize( mainSize );
...@@ -310,7 +380,8 @@ void MainInterface::playlist() ...@@ -310,7 +380,8 @@ void MainInterface::playlist()
void MainInterface::doComponentsUpdate() void MainInterface::doComponentsUpdate()
{ {
calculateInterfaceSize();
resize( mainSize );
} }
/************************************************************************ /************************************************************************
......
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