Commit 1e01594c authored by zorglub's avatar zorglub
Browse files

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