Commit 8ad11518 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt: state machine fixes part 1

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2a455044
...@@ -96,7 +96,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -96,7 +96,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
playlistVisible = false; // FIXME remove playlistVisible = false; // FIXME remove
input_name = ""; input_name = "";
stackCentralOldState = HIDDEN_TAB;
i_bg_height = 0; i_bg_height = 0;
/* Ask for Privacy */ /* Ask for Privacy */
...@@ -138,6 +137,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -138,6 +137,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize(); mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize();
mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize(); mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize();
/************** /**************
* Status Bar * * Status Bar *
**************/ **************/
...@@ -178,6 +178,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -178,6 +178,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
********************/ ********************/
MainInputManager::getInstance( p_intf ); MainInputManager::getInstance( p_intf );
#ifdef WIN32
createTaskBarButtons();
#endif
/************************************************************ /************************************************************
* Connect the input manager to the GUI elements it manages * * Connect the input manager to the GUI elements it manages *
************************************************************/ ************************************************************/
...@@ -247,7 +251,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -247,7 +251,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
CONNECT( this, askUpdate(), this, doComponentsUpdate() ); CONNECT( this, askUpdate(), this, doComponentsUpdate() );
CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() ); CONNECT( THEDP, toolBarConfUpdated(), this, recreateToolbars() );
/* Size and placement of interface */ /* Enable the popup menu in the MI */
setContextMenuPolicy( Qt::CustomContextMenu );
CONNECT( this, customContextMenuRequested( const QPoint& ),
this, popupMenu( const QPoint& ) );
/** END of CONNECTS**/
/**** FINAL SIZING and placement of interface */
settings->beginGroup( "MainWindow" ); settings->beginGroup( "MainWindow" );
QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
...@@ -265,18 +277,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -265,18 +277,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
} }
} }
bool b_pl_visible = settings->value( "playlist-visible", 0 ).toInt(); msg_Dbg( p_intf, "%i", stackCentralOldState );
settings->endGroup();
/* Playlist */ /* Playlist */
if( b_pl_visible ) togglePlaylist(); if( settings->value( "playlist-visible", 0 ).toInt() )
togglePlaylist();
/* Enable the popup menu in the MI */ settings->endGroup();
setContextMenuPolicy( Qt::CustomContextMenu );
CONNECT( this, customContextMenuRequested( const QPoint& ),
this, popupMenu( const QPoint& ) );
debug();
/* Final sizing and showing */ /* Final sizing and showing */
setVisible( !b_hideAfterCreation ); setVisible( !b_hideAfterCreation );
...@@ -295,9 +300,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -295,9 +300,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
updateGeometry(); updateGeometry();
resize( sizeHint() ); resize( sizeHint() );
#ifdef WIN32
createTaskBarButtons();
#endif
} }
MainInterface::~MainInterface() MainInterface::~MainInterface()
...@@ -399,11 +401,6 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -399,11 +401,6 @@ void MainInterface::createMainWidget( QSettings *settings )
bgWidget->updateGeometry(); bgWidget->updateGeometry();
stackCentralW->insertWidget( BACKG_TAB, bgWidget ); stackCentralW->insertWidget( BACKG_TAB, bgWidget );
if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
i_visualmode != QT_MINIMAL_MODE )
{
stackCentralW->hide();
}
/* And video Outputs */ /* And video Outputs */
if( videoEmbeddedFlag ) if( videoEmbeddedFlag )
...@@ -412,6 +409,20 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -412,6 +409,20 @@ 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 );
if( i_visualmode != QT_ALWAYS_VIDEO_MODE &&
i_visualmode != QT_MINIMAL_MODE )
{
hideStackWidget();
stackCentralOldState = HIDDEN_TAB;
}
else
{
showTab( BACKG_TAB );
stackCentralOldState = BACKG_TAB;
}
/* 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 );
...@@ -450,6 +461,28 @@ void MainInterface::createMainWidget( QSettings *settings ) ...@@ -450,6 +461,28 @@ void MainInterface::createMainWidget( QSettings *settings )
} }
} }
inline void MainInterface::initSystray()
{
#ifndef HAVE_MAEMO
bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
if( config_GetInt( p_intf, "qt-start-minimized") > 0 )
{
if( b_systrayAvailable )
{
b_systrayWanted = true;
b_hideAfterCreation = true;
}
else
msg_Err( p_intf, "cannot start minimized without system tray bar" );
}
if( b_systrayAvailable && b_systrayWanted )
createSystray();
#endif
}
inline void MainInterface::createStatusBar() inline void MainInterface::createStatusBar()
{ {
/**************** /****************
...@@ -571,27 +604,6 @@ void MainInterface::createTaskBarButtons() ...@@ -571,27 +604,6 @@ void MainInterface::createTaskBarButtons()
#endif #endif
inline void MainInterface::initSystray()
{
#ifndef HAVE_MAEMO
bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable();
bool b_systrayWanted = config_GetInt( p_intf, "qt-system-tray" );
if( config_GetInt( p_intf, "qt-start-minimized") > 0 )
{
if( b_systrayAvailable )
{
b_systrayWanted = true;
b_hideAfterCreation = true;
}
else
msg_Err( p_intf, "cannot start minimized without system tray bar" );
}
if( b_systrayAvailable && b_systrayWanted )
createSystray();
#endif
}
/********************************************************************** /**********************************************************************
...@@ -722,6 +734,37 @@ void MainInterface::debug() ...@@ -722,6 +734,37 @@ void MainInterface::debug()
#endif #endif
} }
inline void MainInterface::showTab( int i_tab )
{
msg_Warn( p_intf, "stackCentralOldState %i", stackCentralOldState );
stackCentralOldState = stackCentralW->isVisible() ? stackCentralW->currentIndex()
: HIDDEN_TAB;
msg_Dbg( p_intf, "State chnage %i", stackCentralW->currentIndex() );
if( i_visualmode == QT_NORMAL_MODE )
{
stackCentralW->setVisible( i_tab != HIDDEN_TAB );
}
else
if( i_tab == HIDDEN_TAB ) i_tab == BACKG_TAB;
stackCentralW->setCurrentIndex( i_tab );
}
inline void MainInterface::restoreStackOldWidget()
{
msg_Warn( p_intf, "stackCentralOldState %i", stackCentralOldState );
int temp = stackCentralW->isVisible() ? stackCentralW->currentIndex()
: HIDDEN_TAB;
stackCentralW->setCurrentIndex( stackCentralOldState );
if( i_visualmode == QT_NORMAL_MODE )
stackCentralW->setVisible( stackCentralOldState != HIDDEN_TAB );
stackCentralOldState = temp;
msg_Dbg( p_intf, "Here %i %i", temp, stackCentralW->currentIndex() );
}
void MainInterface::destroyPopupMenu() void MainInterface::destroyPopupMenu()
{ {
QVLCMenu::PopupMenu( p_intf, false ); QVLCMenu::PopupMenu( p_intf, false );
...@@ -804,13 +847,7 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y, ...@@ -804,13 +847,7 @@ void MainInterface::getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
} }
} }
inline void MainInterface::showTab( int i_tab )
{
stackCentralOldState = stackCentralW->currentIndex();
stackCentralW->setCurrentIndex( i_tab );
if( stackCentralW->isHidden() ) stackCentralW->show();
}
/* Asynchronous call from the WindowClose function */ /* Asynchronous call from the WindowClose function */
void MainInterface::releaseVideo( void ) void MainInterface::releaseVideo( void )
...@@ -823,19 +860,10 @@ void MainInterface::releaseVideoSlot( void ) ...@@ -823,19 +860,10 @@ void MainInterface::releaseVideoSlot( void )
{ {
videoWidget->release( ); videoWidget->release( );
/* Restore the previous State */ restoreStackOldWidget();
if( stackCentralOldState == BACKG_TAB )
{
showBg();
}
else
{
stackCentralW->hide();
stackCentralOldState == -1;
}
/* Try to resize, except when you are in Fullscreen mode */ /* Try to resize, except when you are in Fullscreen mode */
doComponentsUpdate(); // doComponentsUpdate();
} }
/* Asynchronous call from WindowControl function */ /* Asynchronous call from WindowControl function */
...@@ -877,50 +905,61 @@ int MainInterface::controlVideo( int i_query, va_list args ) ...@@ -877,50 +905,61 @@ int MainInterface::controlVideo( int i_query, va_list args )
/** /**
* Toggle the playlist widget or dialog * Toggle the playlist widget or dialog
**/ **/
void MainInterface::togglePlaylist() void MainInterface::createPlaylist( bool b_show )
{ {
/* CREATION playlistWidget = new PlaylistWidget( p_intf );
If no playlist exist, then create one and attach it to the DockPL*/
if( !playlistWidget )
{
playlistWidget = new PlaylistWidget( p_intf );
i_pl_dock = PL_BOTTOM; i_pl_dock = PL_BOTTOM;
/*i_pl_dock = (pl_dock_e)getSettings() /* i_pl_dock = (pl_dock_e)getSettings()
->value( "pl-dock-status", PL_UNDOCKED ).toInt();*/ ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */
if( i_pl_dock == PL_UNDOCKED ) if( i_pl_dock == PL_UNDOCKED )
{ {
playlistWidget->setWindowFlags( Qt::Window ); playlistWidget->setWindowFlags( Qt::Window );
/* This will restore the geometry but will not work for position, /* This will restore the geometry but will not work for position,
because of parenting */ because of parenting */
QVLCTools::restoreWidgetPosition( p_intf, "Playlist", QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
playlistWidget, QSize( 600, 300 ) ); playlistWidget, QSize( 600, 300 ) );
} }
else else
{ {
stackCentralW->insertWidget(PLAYL_TAB, playlistWidget ); msg_Warn( p_intf, "Here 12 %i", stackCentralW->currentIndex() );
stackCentralW->setCurrentWidget( playlistWidget ); stackCentralW->insertWidget( PLAYL_TAB, playlistWidget );
stackCentralW->show(); msg_Warn( p_intf, "Here 12 %i", stackCentralW->currentIndex() );
} }
if( b_show )
{
playlistVisible = true; playlistVisible = true;
stackCentralW->show();
}
}
playlistWidget->show(); void MainInterface::togglePlaylist()
{
msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState );
if( !playlistWidget )
{
createPlaylist( true );
} }
else msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState );
if( i_pl_dock != PL_UNDOCKED )
{ {
/* toggle the visibility of the playlist */ /* Playlist not visible */
if( stackCentralW->currentIndex() != PLAYL_TAB ) if( stackCentralW->currentIndex() != PLAYL_TAB )
{ {
stackCentralW->insertWidget(PLAYL_TAB, playlistWidget ); msg_Warn( p_intf, "Here 42" );
stackCentralW->setCurrentWidget( playlistWidget ); showTab( PLAYL_TAB );
stackCentralW->show(); stackCentralW->show();
} }
else else
stackCentralW->setCurrentIndex( VIDEO_TAB ); {
playlistVisible = !playlistVisible; restoreStackOldWidget();
//doComponentsUpdate(); //resize( sizeHint() ); }
playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB );
//doComponentsUpdate(); //resize( sizeHint() );
} }
} }
......
...@@ -118,8 +118,10 @@ private: ...@@ -118,8 +118,10 @@ private:
bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); } bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
void showTab( int i_tab ); void showTab( int i_tab );
void restoreStackOldWidget();
void showVideo() { showTab( VIDEO_TAB ); } void showVideo() { showTab( VIDEO_TAB ); }
void showBg() { showTab( BACKG_TAB ); } void showBg() { showTab( BACKG_TAB ); }
void hideStackWidget() { showTab( HIDDEN_TAB ); }
QSettings *settings; QSettings *settings;
#ifndef HAVE_MAEMO #ifndef HAVE_MAEMO
...@@ -147,8 +149,8 @@ private: ...@@ -147,8 +149,8 @@ private:
enum { enum {
HIDDEN_TAB = -1, HIDDEN_TAB = -1,
BACKG_TAB = 0, BACKG_TAB = 0,
VIDEO_TAB, VIDEO_TAB = 1,
PLAYL_TAB, PLAYL_TAB = 2,
}; };
int stackCentralOldState; int stackCentralOldState;
...@@ -171,6 +173,7 @@ private: ...@@ -171,6 +173,7 @@ private:
LPTASKBARLIST3 p_taskbl; LPTASKBARLIST3 p_taskbl;
void createTaskBarButtons(); void createTaskBarButtons();
#endif #endif
void createPlaylist( bool );
public slots: public slots:
void undockPlaylist(); void undockPlaylist();
......
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