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

Qt: use a single state variable and debug

This also fixes the non returning to the correct size because of too high minimumSize();
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 56cf048f
...@@ -86,7 +86,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -86,7 +86,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
#ifndef HAVE_MAEMO #ifndef HAVE_MAEMO
sysTray = NULL; sysTray = NULL;
#endif #endif
videoIsActive = false;
playlistVisible = false; playlistVisible = false;
input_name = ""; input_name = "";
fullscreenControls = NULL; fullscreenControls = NULL;
...@@ -95,7 +94,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -95,7 +94,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
inputC = NULL; inputC = NULL;
b_shouldHide = false; b_shouldHide = false;
bgWasVisible = false; stackCentralOldState = HIDDEN_TAB;
i_bg_height = 0; i_bg_height = 0;
/* Ask for privacy */ /* Ask for privacy */
...@@ -294,7 +293,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -294,7 +293,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
updateGeometry(); updateGeometry();
resize( sizeHint() ); resize( sizeHint() );
#ifdef WIN32 #ifdef WIN32
createTaskBarButtons(); createTaskBarButtons();
#endif #endif
...@@ -305,7 +303,7 @@ MainInterface::~MainInterface() ...@@ -305,7 +303,7 @@ MainInterface::~MainInterface()
msg_Dbg( p_intf, "Destroying the main interface" ); msg_Dbg( p_intf, "Destroying the main interface" );
/* Unsure we hide the videoWidget before destroying it */ /* Unsure we hide the videoWidget before destroying it */
if( videoIsActive ) if( stackCentralOldState == VIDEO_TAB )
{ {
showBg(); showBg();
} }
...@@ -389,19 +387,12 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -389,19 +387,12 @@ void MainInterface::createMainWidget( QSettings *settings )
/* Margins, spacing */ /* Margins, spacing */
main->setContentsMargins( 0, 0, 0, 0 ); main->setContentsMargins( 0, 0, 0, 0 );
// main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum );
mainLayout->setSpacing( 0 ); mainLayout->setSpacing( 0 );
mainLayout->setMargin( 0 ); mainLayout->setMargin( 0 );
/* Visualisation */ /* */
/* Disabled for now, they SUCK */
#if 0
visualSelector = new VisualSelector( p_intf );
mainLayout->insertWidget( 0, visualSelector );
visualSelector->hide();
#endif
stackCentralW = new QStackedWidget( main ); stackCentralW = new QStackedWidget( main );
/* Bg Cone */ /* Bg Cone */
bgWidget = new BackgroundWidget( p_intf ); bgWidget = new BackgroundWidget( p_intf );
bgWidget->resize( bgWidget->resize(
...@@ -422,7 +413,6 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -422,7 +413,6 @@ void MainInterface::createMainWidget( QSettings *settings )
stackCentralW->insertWidget( VIDEO_TAB, videoWidget ); stackCentralW->insertWidget( VIDEO_TAB, videoWidget );
} }
mainLayout->insertWidget( 1, stackCentralW, 100 ); mainLayout->insertWidget( 1, stackCentralW, 100 );
/* Create the CONTROLS Widget */ /* Create the CONTROLS Widget */
controls = new ControlsWidget( p_intf, controls = new ControlsWidget( p_intf,
settings->value( "adv-controls", false ).toBool(), this ); settings->value( "adv-controls", false ).toBool(), this );
...@@ -437,6 +427,14 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -437,6 +427,14 @@ void MainInterface::createMainWidget( QSettings *settings )
mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3, mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3,
controls ); controls );
/* Visualisation */
/* Disabled for now, they SUCK */
#if 0
visualSelector = new VisualSelector( p_intf );
mainLayout->insertWidget( 0, visualSelector );
visualSelector->hide();
#endif
/* Finish the sizing */ /* Finish the sizing */
main->updateGeometry(); main->updateGeometry();
...@@ -780,13 +778,14 @@ void MainInterface::doComponentsUpdate() ...@@ -780,13 +778,14 @@ void MainInterface::doComponentsUpdate()
msg_Err( p_intf, "Updating the geometry" ); msg_Err( p_intf, "Updating the geometry" );
/* Here we resize to sizeHint() and not adjustsize because we want /* Here we resize to sizeHint() and not adjustsize because we want
the videoWidget to be exactly the correctSize */ the videoWidget to be exactly the correctSize */
//mainLayout->invalidate();
// setMinimumSize( 0, 0 );
#if 1 #if 1
debug(); debug();
#endif #endif
/* This is WRONG */
setMinimumSize( 0, 0 );
resize( sizeHint() ); resize( sizeHint() );
//adjustSize() ; //adjustSize() ;
} }
...@@ -798,6 +797,9 @@ void MainInterface::debug() ...@@ -798,6 +797,9 @@ void MainInterface::debug()
else else
msg_Dbg( p_intf, "CentralStack inVisible" ); msg_Dbg( p_intf, "CentralStack inVisible" );
//msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->sizeHint().height(), stackCentralW->sizeHint().width() ); //msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->sizeHint().height(), stackCentralW->sizeHint().width() );
msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->size().height(), size().width() );
msg_Dbg( p_intf, "Stack Size: %i - %i", stackCentralW->widget( VIDEO_TAB )->size().height(), stackCentralW->widget( VIDEO_TAB )->size().width() );
msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() );
msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() );
//msg_Dbg( p_intf, "maximumsize: %i - %i", maximumSize().height(), maximumSize().width() ); //msg_Dbg( p_intf, "maximumsize: %i - %i", maximumSize().height(), maximumSize().width() );
...@@ -890,21 +892,10 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -890,21 +892,10 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
*p_id = ret; *p_id = ret;
if( ret ) /* The videoWidget is available */ if( ret ) /* The videoWidget is available */
{ {
/* Did we have a bg ? Hide it! */
if( stackCentralW->isVisible() &&
stackCentralW->currentIndex() == BACKG_TAB )
{
showBg();
bgWasVisible = true;
}
else
bgWasVisible = false;
/* ask videoWidget to show */ /* ask videoWidget to show */
videoWidget->SetSizing( *pi_width, *pi_height ); videoWidget->SetSizing( *pi_width, *pi_height );
/* Consider the video active now */ /* Consider the video active now */
videoIsActive = true;
showVideo(); showVideo();
stackCentralW->resize( *pi_width, *pi_height ); stackCentralW->resize( *pi_width, *pi_height );
...@@ -915,6 +906,8 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -915,6 +906,8 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
inline void MainInterface::showTab( int i_tab ) inline void MainInterface::showTab( int i_tab )
{ {
stackCentralOldState = stackCentralW->currentIndex();
stackCentralW->setCurrentIndex( i_tab ); stackCentralW->setCurrentIndex( i_tab );
if( stackCentralW->isHidden() ) stackCentralW->show(); if( stackCentralW->isHidden() ) stackCentralW->show();
} }
...@@ -930,19 +923,17 @@ void MainInterface::releaseVideoSlot( void ) ...@@ -930,19 +923,17 @@ void MainInterface::releaseVideoSlot( void )
{ {
videoWidget->release( ); videoWidget->release( );
if( bgWasVisible ) /* Restore the previous State */
if( stackCentralOldState == BACKG_TAB )
{ {
/* Reset the bg state */
bgWasVisible = false;
showBg(); showBg();
} }
else { else
{
stackCentralW->hide(); stackCentralW->hide();
stackCentralW->setMinimumSize(QSize(0, 0)); stackCentralOldState == -1;
} }
videoIsActive = false;
/* Try to resize, except when you are in Fullscreen mode */ /* Try to resize, except when you are in Fullscreen mode */
doComponentsUpdate(); doComponentsUpdate();
} }
...@@ -1056,8 +1047,11 @@ void MainInterface::toggleMinimalView( bool b_switch ) ...@@ -1056,8 +1047,11 @@ void MainInterface::toggleMinimalView( bool b_switch )
} }
else else
{ {
/* If video is visible, then toggle the status of bgWidget */ /* If video is visible, then toggle the status of bgWidget */ //bgWasVisible = !bgWasVisible;
bgWasVisible = !bgWasVisible; if( stackCentralOldState == BACKG_TAB )
stackCentralOldState = HIDDEN_TAB;
else
stackCentralOldState = BACKG_TAB;
} }
} }
......
...@@ -60,11 +60,7 @@ enum { ...@@ -60,11 +60,7 @@ enum {
CONTROLS_HIDDEN = 0x2, CONTROLS_HIDDEN = 0x2,
CONTROLS_ADVANCED = 0x4, CONTROLS_ADVANCED = 0x4,
}; };
enum {
BACKG_TAB,
VIDEO_TAB,
PLAYL_TAB,
};
typedef enum pl_dock_e { typedef enum pl_dock_e {
PL_UNDOCKED, PL_UNDOCKED,
...@@ -151,12 +147,20 @@ private: ...@@ -151,12 +147,20 @@ private:
QLabel *cryptedLabel; QLabel *cryptedLabel;
/* Status and flags */ /* Status and flags */
bool videoIsActive; ///< Having a video now / THEMIM->hasV enum {
HIDDEN_TAB = -1,
BACKG_TAB = 0,
VIDEO_TAB,
PLAYL_TAB,
};
int stackCentralOldState;
// bool videoIsActive; ///< Having a video now / THEMIM->hasV
bool videoEmbeddedFlag; ///< Want an external Video Window bool videoEmbeddedFlag; ///< Want an external Video Window
bool playlistVisible; ///< Is the playlist visible ? bool playlistVisible; ///< Is the playlist visible ?
bool visualSelectorEnabled; bool visualSelectorEnabled;
bool notificationEnabled; /// Systray Notifications bool notificationEnabled; /// Systray Notifications
bool bgWasVisible;
bool b_keep_size; ///< persistent resizeable window bool b_keep_size; ///< persistent resizeable window
QSize mainBasedSize; ///< based Wnd (normal mode only) QSize mainBasedSize; ///< based Wnd (normal mode only)
QSize mainVideoSize; ///< Wnd with video (all modes) QSize mainVideoSize; ///< Wnd with video (all modes)
......
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