X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fmain_interface.cpp;h=5722ba571935b94290732ef7b250331e0e56934d;hb=e4cd963a4bf7a67a396a3185911d766add816efe;hp=d5d0d0d3227754ceddf44580d38e17d81cffbd81;hpb=5862064f44cad48d195a76583af0baac7bb520ed;p=vlc diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index d5d0d0d322..5722ba5719 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -32,6 +32,7 @@ #include "main_interface.hpp" #include "input_manager.hpp" #include "actions_manager.hpp" +#include "extensions_manager.hpp" // killInstance #include "util/customwidgets.hpp" #include "util/qt_dirs.hpp" @@ -40,6 +41,7 @@ #include "components/controller.hpp" #include "components/playlist/playlist.hpp" #include "dialogs/external.hpp" +#include "dialogs/firstrun.hpp" #include "menus.hpp" #include "recents.hpp" @@ -68,8 +70,9 @@ #include /* Wheel event */ #include -#include +#include +// #define DEBUG_INTF /* Callback prototypes */ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ); @@ -95,11 +98,10 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) playlistVisible = false; // FIXME remove input_name = ""; - stackCentralOldState = HIDDEN_TAB; i_bg_height = 0; - /* Ask for privacy */ - askForPrivacy(); + /* Ask for Privacy */ + FirstRun::CheckAndRun( this, p_intf ); /** * Configuration and settings @@ -110,19 +112,19 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) setAcceptDrops( true ); setWindowRole( "vlc-main" ); setWindowIcon( QApplication::windowIcon() ); - setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) ); + setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) ); /* Set The Video In emebedded Mode or not */ - videoEmbeddedFlag = config_GetInt( p_intf, "embedded-video" ); + videoEmbeddedFlag = var_InheritBool( p_intf, "embedded-video" ); /* Does the interface resize to video size or the opposite */ - b_keep_size = !config_GetInt( p_intf, "qt-video-autoresize" ); + b_keep_size = !var_InheritBool( p_intf, "qt-video-autoresize" ); /* Are we in the enhanced always-video mode or not ? */ - i_visualmode = config_GetInt( p_intf, "qt-display-mode" ); + i_visualmode = var_InheritInteger( p_intf, "qt-display-mode" ); - /* Do we want anoying popups or not */ - notificationEnabled = (bool)config_GetInt( p_intf, "qt-notification" ); + /* Do we want anoying popups or not */ + notificationEnabled = (bool)var_InheritBool( p_intf, "qt-notification" ); /* Set the other interface settings */ settings = getSettings(); @@ -137,6 +139,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) mainBasedSize = settings->value( "mainBasedSize", QSize( 350, 120 ) ).toSize(); mainVideoSize = settings->value( "mainVideoSize", QSize( 400, 300 ) ).toSize(); + /************** * Status Bar * **************/ @@ -155,18 +158,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, destroyPopupMenu() ); -#if 0 - /* Create a Dock to get the playlist */ - dockPL = new QDockWidget( qtr( "Playlist" ), this ); - dockPL->setSizePolicy( QSizePolicy::Preferred, - QSizePolicy::Expanding ); - dockPL->setFeatures( QDockWidget::AllDockWidgetFeatures ); - dockPL->setAllowedAreas( Qt::LeftDockWidgetArea - | Qt::RightDockWidgetArea - | Qt::BottomDockWidgetArea ); - dockPL->hide(); -#endif - /********************************* * Create the Systray Management * *********************************/ @@ -177,6 +168,12 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ********************/ MainInputManager::getInstance( p_intf ); +#ifdef WIN32 + himl = NULL; + p_taskbl = NULL; + taskbar_wmsg = RegisterWindowMessage("TaskbarButtonCreated"); +#endif + /************************************************************ * Connect the input manager to the GUI elements it manages * ************************************************************/ @@ -196,7 +193,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) } #endif /* and title of the Main Interface*/ - if( config_GetInt( p_intf, "qt-name-in-title" ) ) + if( var_InheritBool( p_intf, "qt-name-in-title" ) ) { CONNECT( THEMIM->getIM(), nameChanged( const QString& ), this, setVLCWindowsTitle( const QString& ) ); @@ -246,7 +243,15 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) CONNECT( this, askUpdate(), this, doComponentsUpdate() ); 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" ); QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); @@ -264,24 +269,20 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) } } - bool b_pl_visible = settings->value( "playlist-visible", 0 ).toInt(); - settings->endGroup(); + msg_Dbg( p_intf, "%i", stackCentralOldState ); /* Playlist */ - if( b_pl_visible ) togglePlaylist(); + int i_plVis = settings->value( "playlist-visible", 0 ).toInt(); - /* Enable the popup menu in the MI */ - setContextMenuPolicy( Qt::CustomContextMenu ); - CONNECT( this, customContextMenuRequested( const QPoint& ), - this, popupMenu( const QPoint& ) ); + settings->endGroup(); - debug(); + if( i_plVis ) togglePlaylist(); /* Final sizing and showing */ setVisible( !b_hideAfterCreation ); //setMinimumSize( QSize( 0, 0 ) ); -// setMinimumWidth( __MAX( controls->sizeHint().width(), - // menuBar()->sizeHint().width() ) ); + // setMinimumWidth( __MAX( controls->sizeHint().width(), + // menuBar()->sizeHint().width() ) ); debug(); /* And switch to minimal view if needed @@ -293,10 +294,6 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) qt-display-modes */ updateGeometry(); resize( sizeHint() ); - -#ifdef WIN32 - createTaskBarButtons(); -#endif } MainInterface::~MainInterface() @@ -327,6 +324,9 @@ MainInterface::~MainInterface() /* Be sure to kill the actionsManager... FIXME */ ActionsManager::killInstance(); + /* Idem, FIXME */ + ExtensionsManager::killInstance(); + /* Delete the FSC controller */ delete fullscreenControls; @@ -359,15 +359,17 @@ MainInterface::~MainInterface() *****************************/ void MainInterface::recreateToolbars() { - msg_Dbg( p_intf, "Recreating the toolbars" ); + //msg_Dbg( p_intf, "Recreating the toolbars" ); settings->beginGroup( "MainWindow" ); delete controls; delete inputC; + controls = new ControlsWidget( p_intf, false, this ); /* FIXME */ CONNECT( controls, advancedControlsToggled( bool ), this, doComponentsUpdate() ); CONNECT( controls, sizeChanged(), this, doComponentsUpdate() ); + inputC = new InputControlsWidget( p_intf, this ); mainLayout->insertWidget( 2, inputC ); @@ -385,8 +387,7 @@ void MainInterface::createMainWidget( QSettings *settings ) /* Margins, spacing */ main->setContentsMargins( 0, 0, 0, 0 ); - mainLayout->setSpacing( 0 ); - mainLayout->setMargin( 0 ); + mainLayout->setSpacing( 0 ); mainLayout->setMargin( 0 ); /* */ stackCentralW = new QStackedWidget( main ); @@ -398,11 +399,6 @@ void MainInterface::createMainWidget( QSettings *settings ) bgWidget->updateGeometry(); stackCentralW->insertWidget( BACKG_TAB, bgWidget ); - if( i_visualmode != QT_ALWAYS_VIDEO_MODE && - i_visualmode != QT_MINIMAL_MODE ) - { - stackCentralW->hide(); - } /* And video Outputs */ if( videoEmbeddedFlag ) @@ -411,6 +407,8 @@ void MainInterface::createMainWidget( QSettings *settings ) stackCentralW->insertWidget( VIDEO_TAB, videoWidget ); } mainLayout->insertWidget( 1, stackCentralW, 100 ); + + /* Create the CONTROLS Widget */ controls = new ControlsWidget( p_intf, settings->value( "adv-controls", false ).toBool(), this ); @@ -420,6 +418,19 @@ void MainInterface::createMainWidget( QSettings *settings ) this, doComponentsUpdate() ); inputC = new InputControlsWidget( p_intf, this ); + if( i_visualmode != QT_ALWAYS_VIDEO_MODE && + i_visualmode != QT_MINIMAL_MODE ) + { + hideStackWidget(); + stackCentralOldState = HIDDEN_TAB; + } + else + { + showTab( BACKG_TAB ); + stackCentralOldState = BACKG_TAB; + } + + //mainLayout->setRowStretch( 1, 10 ); mainLayout->insertWidget( 2, inputC ); mainLayout->insertWidget( settings->value( "ToolbarPos", 0 ).toInt() ? 0: 3, @@ -441,7 +452,7 @@ void MainInterface::createMainWidget( QSettings *settings ) if ( depth() > 8 ) #endif /* Create the FULLSCREEN CONTROLS Widget */ - if( config_GetInt( p_intf, "qt-fs-controller" ) ) + if( var_InheritBool( p_intf, "qt-fs-controller" ) ) { fullscreenControls = new FullscreenControllerWidget( p_intf, this ); CONNECT( fullscreenControls, keyPressed( QKeyEvent * ), @@ -449,6 +460,28 @@ void MainInterface::createMainWidget( QSettings *settings ) } } +inline void MainInterface::initSystray() +{ +#ifndef HAVE_MAEMO + bool b_systrayAvailable = QSystemTrayIcon::isSystemTrayAvailable(); + bool b_systrayWanted = var_InheritBool( p_intf, "qt-system-tray" ); + + if( var_InheritBool( p_intf, "qt-start-minimized") ) + { + 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() { /**************** @@ -486,20 +519,27 @@ inline void MainInterface::createStatusBar() #ifdef WIN32 void MainInterface::createTaskBarButtons() { + taskbar_wmsg = WM_NULL; /*Here is the code for the taskbar thumb buttons FIXME:We need pretty buttons in 16x16 px that are handled correctly by masks in Qt FIXME:the play button's picture doesn't changed to pause when clicked */ - OSVERSIONINFO winVer; - winVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if( GetVersionEx(&winVer) && winVer.dwMajorVersion > 5 ) + + CoInitialize( 0 ); + + if( S_OK == CoCreateInstance( &clsid_ITaskbarList, + NULL, CLSCTX_INPROC_SERVER, + &IID_ITaskbarList3, + (void **)&p_taskbl) ) { + p_taskbl->vt->HrInit(p_taskbl); + if(himl = ImageList_Create( 15, //cx - 18, //cy - ILC_COLOR,//flags - 4,//initial nb of images - 0//nb of images that can be added - )) + 18, //cy + ILC_COLOR,//flags + 4,//initial nb of images + 0//nb of images that can be added + )) { QPixmap img = QPixmap(":/toolbar/previous_b"); QPixmap img2 = QPixmap(":/toolbar/pause_b"); @@ -520,171 +560,114 @@ void MainInterface::createTaskBarButtons() msg_Err( p_intf, "ImageList_Add failed" ); } - CoInitialize( 0 ); - - if( S_OK == CoCreateInstance( &clsid_ITaskbarList, - NULL, CLSCTX_INPROC_SERVER, - &IID_ITaskbarList3, - (void **)&p_taskbl) ) + // Define an array of two buttons. These buttons provide images through an + // image list and also provide tooltips. + DWORD dwMask = THB_BITMAP | THB_FLAGS; + + THUMBBUTTON thbButtons[3]; + thbButtons[0].dwMask = dwMask; + thbButtons[0].iId = 0; + thbButtons[0].iBitmap = 0; + thbButtons[0].dwFlags = THBF_HIDDEN; + + thbButtons[1].dwMask = dwMask; + thbButtons[1].iId = 1; + thbButtons[1].iBitmap = 2; + thbButtons[1].dwFlags = THBF_HIDDEN; + + thbButtons[2].dwMask = dwMask; + thbButtons[2].iId = 2; + thbButtons[2].iBitmap = 3; + thbButtons[2].dwFlags = THBF_HIDDEN; + + HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, winId(), himl ); + if(S_OK != hr) + msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr ); + else { - p_taskbl->vt->HrInit(p_taskbl); - - int msg_value = RegisterWindowMessage("TaskbarButtonCreated"); - //msg_Info( p_intf, "msg value: %04x", msg_value ); - - // Define an array of two buttons. These buttons provide images through an - // image list and also provide tooltips. - DWORD dwMask = THB_BITMAP | THB_FLAGS; - - THUMBBUTTON thbButtons[2]; - thbButtons[0].dwMask = dwMask; - thbButtons[0].iId = 0; - thbButtons[0].iBitmap = 0; - thbButtons[0].dwFlags = THBF_HIDDEN; - - thbButtons[1].dwMask = dwMask; - thbButtons[1].iId = 1; - thbButtons[1].iBitmap = 2; - thbButtons[1].dwFlags = THBF_HIDDEN; - - thbButtons[2].dwMask = dwMask; - thbButtons[2].iId = 2; - thbButtons[2].iBitmap = 3; - thbButtons[2].dwFlags = THBF_HIDDEN; - - HRESULT hr = p_taskbl->vt->ThumbBarSetImageList(p_taskbl, GetForegroundWindow(), himl ); + hr = p_taskbl->vt->ThumbBarAddButtons(p_taskbl, winId(), 3, thbButtons); if(S_OK != hr) - msg_Err( p_intf, "ThumbBarSetImageList failed with error %08x", hr ); - if(S_OK != p_taskbl->vt->ThumbBarAddButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons)) - msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", GetLastError() ); - - CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) ); + msg_Err( p_intf, "ThumbBarAddButtons failed with error %08x", hr ); } + CONNECT( THEMIM->getIM(), statusChanged( int ), this, changeThumbbarButtons( int ) ); } else { himl = NULL; p_taskbl = NULL; } -} -#endif +} -inline void MainInterface::initSystray() +bool MainInterface::winEvent ( MSG * msg, long * result ) { -#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 (msg->message == taskbar_wmsg) { - if( b_systrayAvailable ) - { - b_systrayWanted = true; - b_hideAfterCreation = true; - } - else - msg_Err( p_intf, "cannot start minimized without system tray bar" ); + //We received the taskbarbuttoncreated, now we can really create th buttons + createTaskBarButtons(); } - if( b_systrayAvailable && b_systrayWanted ) - createSystray(); -#endif -} - -inline void MainInterface::askForPrivacy() -{ -#ifndef HAVE_MAEMO - /** - * Ask for the network policy on FIRST STARTUP - **/ - if( config_GetInt( p_intf, "qt-privacy-ask") ) + short cmd; + switch( msg->message ) { - QList controls; - if( privacyDialog( &controls ) == QDialog::Accepted ) - { - QList::Iterator i; - for( i = controls.begin() ; i != controls.end() ; i++ ) + case WM_COMMAND: + if (HIWORD(msg->wParam) == THBN_CLICKED) { - ConfigControl *c = qobject_cast(*i); - c->doApply( p_intf ); + switch(LOWORD(msg->wParam)) + { + case 0: + THEMIM->prev(); + break; + case 1: + THEMIM->togglePlayPause(); + break; + case 2: + THEMIM->next(); + break; + } } - - config_PutInt( p_intf, "qt-privacy-ask" , 0 ); - /* We have to save here because the user may not launch Prefs */ - config_SaveConfigFile( p_intf, NULL ); - } + break; + case WM_APPCOMMAND: + cmd = GET_APPCOMMAND_LPARAM(msg->lParam); + switch(cmd) + { + case APPCOMMAND_MEDIA_PLAY_PAUSE: + THEMIM->togglePlayPause(); + break; + case APPCOMMAND_MEDIA_PLAY: + THEMIM->play(); + break; + case APPCOMMAND_MEDIA_PAUSE: + THEMIM->pause(); + break; + case APPCOMMAND_MEDIA_PREVIOUSTRACK: + THEMIM->prev(); + break; + case APPCOMMAND_MEDIA_NEXTTRACK: + THEMIM->next(); + break; + case APPCOMMAND_MEDIA_STOP: + THEMIM->stop(); + break; + case APPCOMMAND_VOLUME_DOWN: + THEAM->AudioDown(); + break; + case APPCOMMAND_VOLUME_UP: + THEAM->AudioUp(); + break; + case APPCOMMAND_VOLUME_MUTE: + THEAM->toggleMuteAudio(); + break; + default: + msg_Dbg( p_intf, "unknown APPCOMMAND = %d", cmd); + break; + } + break; } -#endif + return false; } - -int MainInterface::privacyDialog( QList *controls ) -{ - QDialog *privacy = new QDialog( this ); - - privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) ); - privacy->setWindowRole( "vlc-privacy" ); - - QGridLayout *gLayout = new QGridLayout( privacy ); - - QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) ); - QGridLayout *blablaLayout = new QGridLayout( blabla ); - QLabel *text = new QLabel( qtr( - "

The VideoLAN Team doesn't like when an application goes " - "online without authorization.

\n " - "

VLC media player can retreive limited information from " - "the Internet in order to get CD covers or to check " - "for available updates.

\n" - "

VLC media player DOES NOT send or collect ANY " - "information, even anonymously, about your usage.

\n" - "

Therefore please select from the following options, the default being " - "almost no access to the web.

\n") ); - text->setWordWrap( true ); - text->setTextFormat( Qt::RichText ); - - blablaLayout->addWidget( text, 0, 0 ) ; - - QGroupBox *options = new QGroupBox; - QGridLayout *optionsLayout = new QGridLayout( options ); - - gLayout->addWidget( blabla, 0, 0, 1, 3 ); - gLayout->addWidget( options, 1, 0, 1, 3 ); - module_config_t *p_config; - ConfigControl *control; - int line = 0; - -#define CONFIG_GENERIC( option, type ) \ - p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ - if( p_config ) \ - { \ - control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ - p_config, options, false, optionsLayout, line ); \ - controls->append( control ); \ - } - -#define CONFIG_GENERIC_NOBOOL( option, type ) \ - p_config = config_FindConfig( VLC_OBJECT(p_intf), option ); \ - if( p_config ) \ - { \ - control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ - p_config, options, optionsLayout, line ); \ - controls->append( control ); \ - } - - CONFIG_GENERIC( "album-art", IntegerList ); line++; -#ifdef UPDATE_CHECK - CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++; #endif - QPushButton *ok = new QPushButton( qtr( "OK" ) ); - - gLayout->addWidget( ok, 2, 2 ); - - CONNECT( ok, clicked(), privacy, accept() ); - return privacy->exec(); -} - - /********************************************************************** * Handling of sizing of the components **********************************************************************/ @@ -773,7 +756,7 @@ void MainInterface::doComponentsUpdate() { if( isFullScreen() || isMaximized() ) return; - msg_Warn( p_intf, "Updating the geometry" ); +// msg_Warn( p_intf, "Updating the geometry" ); /* Here we resize to sizeHint() and not adjustsize because we want the videoWidget to be exactly the correctSize */ @@ -791,7 +774,12 @@ void MainInterface::debug() { #ifndef NDEBUG 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() ); + if( videoEmbeddedFlag ) + msg_Dbg( p_intf, "Stack Size: %i - %i", + stackCentralW->widget( VIDEO_TAB )->size().height(), + stackCentralW->widget( VIDEO_TAB )->size().width() ); + else + msg_Dbg( p_intf, "no embedded video" ); msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); @@ -813,6 +801,53 @@ void MainInterface::debug() #endif } +inline void MainInterface::showTab( int i_tab ) +{ +#ifdef DEBUG_INTF + msg_Err( p_intf, "showTab %i", i_tab ); + msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState ); +#endif + stackCentralOldState = stackCentralW->isVisible() ? stackCentralW->currentIndex() + : HIDDEN_TAB; +#ifdef DEBUG_INTF + msg_Warn( p_intf, "State change %i %i", stackCentralW->currentIndex(), i_tab ); +#endif + + if( i_visualmode == QT_NORMAL_MODE ) + { + stackCentralW->setVisible( i_tab != HIDDEN_TAB ); + doComponentsUpdate(); // resize the player + } + else + if( i_tab == HIDDEN_TAB ) i_tab == BACKG_TAB; + + stackCentralW->setCurrentIndex( i_tab ); + +#ifdef DEBUG_INTF + msg_Warn( p_intf, "New stackCentralOldState %i", stackCentralOldState ); +#endif +} + +inline void MainInterface::restoreStackOldWidget() +{ +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Old stackCentralOldState %i", stackCentralOldState ); +#endif + int temp = stackCentralW->isVisible() ? stackCentralW->currentIndex() + : HIDDEN_TAB; + stackCentralW->setCurrentIndex( stackCentralOldState ); + if( i_visualmode == QT_NORMAL_MODE ) + { + stackCentralW->setVisible( stackCentralOldState != HIDDEN_TAB ); + doComponentsUpdate(); // resize the player + } + + stackCentralOldState = temp; +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Debug %i %i", temp, stackCentralW->currentIndex() ); +#endif +} + void MainInterface::destroyPopupMenu() { QVLCMenu::PopupMenu( p_intf, false ); @@ -895,13 +930,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 */ void MainInterface::releaseVideo( void ) @@ -914,19 +943,10 @@ void MainInterface::releaseVideoSlot( void ) { videoWidget->release( ); - /* Restore the previous State */ - if( stackCentralOldState == BACKG_TAB ) - { - showBg(); - } - else - { - stackCentralW->hide(); - stackCentralOldState == -1; - } + restoreStackOldWidget(); /* Try to resize, except when you are in Fullscreen mode */ - doComponentsUpdate(); +// doComponentsUpdate(); } /* Asynchronous call from WindowControl function */ @@ -942,12 +962,13 @@ int MainInterface::controlVideo( int i_query, va_list args ) unsigned int i_height = va_arg( args, unsigned int ); emit askVideoToResize( i_width, i_height ); emit askUpdate(); - return VLC_SUCCESS; + return VLC_EGENERIC; } - case VOUT_WINDOW_SET_ON_TOP: + case VOUT_WINDOW_SET_STATE: { - int i_arg = va_arg( args, int ); - QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) ); + unsigned i_arg = va_arg( args, unsigned ); + unsigned on_top = i_arg & VOUT_WINDOW_STATE_ABOVE; + QApplication::postEvent( this, new SetVideoOnTopQtEvent( on_top ) ); return VLC_SUCCESS; } case VOUT_WINDOW_SET_FULLSCREEN: @@ -968,50 +989,68 @@ int MainInterface::controlVideo( int i_query, va_list args ) /** * Toggle the playlist widget or dialog **/ -void MainInterface::togglePlaylist() +void MainInterface::createPlaylist( bool b_show ) { - /* CREATION - If no playlist exist, then create one and attach it to the DockPL*/ - if( !playlistWidget ) - { - playlistWidget = new PlaylistWidget( p_intf ); + playlistWidget = new PlaylistWidget( p_intf, this ); - i_pl_dock = PL_BOTTOM; - /*i_pl_dock = (pl_dock_e)getSettings() - ->value( "pl-dock-status", PL_UNDOCKED ).toInt();*/ + i_pl_dock = PL_BOTTOM; + /* i_pl_dock = (pl_dock_e)getSettings() + ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */ - if( i_pl_dock == PL_UNDOCKED ) - { - playlistWidget->setWindowFlags( Qt::Window ); + if( i_pl_dock == PL_UNDOCKED ) + { + playlistWidget->setWindowFlags( Qt::Window ); - /* This will restore the geometry but will not work for position, - because of parenting */ - QVLCTools::restoreWidgetPosition( p_intf, "Playlist", - playlistWidget, QSize( 600, 300 ) ); - } - else - { - stackCentralW->insertWidget(PLAYL_TAB, playlistWidget ); - stackCentralW->setCurrentWidget( playlistWidget ); - stackCentralW->show(); - } + /* This will restore the geometry but will not work for position, + because of parenting */ + QVLCTools::restoreWidgetPosition( p_intf, "Playlist", + playlistWidget, QSize( 600, 300 ) ); + } + else + { +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() ); +#endif + stackCentralW->insertWidget( PLAYL_TAB, playlistWidget ); +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Here %i", stackCentralW->currentIndex() ); +#endif + } + + if( b_show ) + { playlistVisible = true; + stackCentralW->show(); + } +} - playlistWidget->show(); +void MainInterface::togglePlaylist() +{ +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState ); +#endif + if( !playlistWidget ) + { + createPlaylist( true ); } - else +#ifdef DEBUG_INTF + msg_Warn( p_intf, "Here toggling %i %i", stackCentralW->currentIndex(), stackCentralOldState ); + +#endif + if( i_pl_dock != PL_UNDOCKED ) { - /* toggle the visibility of the playlist */ + /* Playlist not visible */ if( stackCentralW->currentIndex() != PLAYL_TAB ) { - stackCentralW->insertWidget(PLAYL_TAB, playlistWidget ); - stackCentralW->setCurrentWidget( playlistWidget ); + showTab( PLAYL_TAB ); stackCentralW->show(); } else - stackCentralW->setCurrentIndex( VIDEO_TAB ); - playlistVisible = !playlistVisible; - //doComponentsUpdate(); //resize( sizeHint() ); + { + restoreStackOldWidget(); + } + playlistVisible = ( stackCentralW->currentIndex() == PLAYL_TAB ); + //doComponentsUpdate(); //resize( sizeHint() ); } } @@ -1453,7 +1492,7 @@ void MainInterface::toggleFullScreen( void ) void MainInterface::changeThumbbarButtons( int i_status) { #ifdef WIN32 - // Define an array of two buttons. These buttons provide images through an + // Define an array of three buttons. These buttons provide images through an // image list and also provide tooltips. DWORD dwMask = THB_BITMAP | THB_FLAGS; @@ -1474,14 +1513,6 @@ void MainInterface::changeThumbbarButtons( int i_status) switch( i_status ) { - case 0: - case END_S: - { - thbButtons[0].dwFlags = THBF_HIDDEN; - thbButtons[1].dwFlags = THBF_HIDDEN; - thbButtons[2].dwFlags = THBF_HIDDEN; - break; - } case PLAYING_S: { thbButtons[0].dwFlags = THBF_ENABLED; @@ -1492,15 +1523,16 @@ void MainInterface::changeThumbbarButtons( int i_status) } case PAUSE_S: { - //thbButtons[0].dwFlags = THBF_ENABLED; - //thbButtons[1].dwFlags = THBF_ENABLED; - //thbButtons[2].dwFlags = THBF_ENABLED; + thbButtons[0].dwFlags = THBF_ENABLED; + thbButtons[1].dwFlags = THBF_ENABLED; + thbButtons[2].dwFlags = THBF_ENABLED; thbButtons[1].iBitmap = 2; break; } + default: + return; } - - HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, GetForegroundWindow(), 3, thbButtons); + HRESULT hr = p_taskbl->vt->ThumbBarUpdateButtons(p_taskbl, this->winId(), 3, thbButtons); if(S_OK != hr) msg_Err( p_intf, "ThumbBarUpdateButtons failed with error %08x", hr ); #else