X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fmain_interface.cpp;h=f96deb8c50867601d8b3b845082f17704e108644;hb=34302f8205005d20ebdece81e46e210bb6982172;hp=c3a33c250de77bdd7150c51bc1708c37d0ebd3e4;hpb=74ef05f32740e93237f8ce8fd1a90641cb4aa1e6;p=vlc diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index c3a33c250d..f96deb8c50 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -57,7 +57,6 @@ #include #include #include -#include #include #include @@ -81,13 +80,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) { /* Variables initialisation */ // need_components_update = false; - bgWidget = NULL; - videoWidget = NULL; - playlistWidget = NULL; - sysTray = NULL; - videoIsActive = false; - playlistVisible = false; - input_name = ""; + bgWidget = NULL; + videoWidget = NULL; + playlistWidget = NULL; + sysTray = NULL; + videoIsActive = false; + playlistVisible = false; + input_name = ""; + fullscreenControls = NULL; /* Ask for privacy */ askForPrivacy(); @@ -109,7 +109,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) i_visualmode = config_GetInt( p_intf, "qt-display-mode" ); /* Set the other interface settings */ - settings = new QSettings( "vlc", "vlc-qt-interface" ); + settings = getSettings(); settings->beginGroup( "MainWindow" ); //TODO: I don't like that code @@ -211,30 +211,19 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); /* Register callback for the intf-popupmenu variable */ - playlist_t *p_playlist = pl_Yield( p_intf ); - var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - pl_Release( p_intf ); + var_AddCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); /* VideoWidget connect mess to avoid different threads speaking to each other */ CONNECT( this, askReleaseVideo( void * ), this, releaseVideoSlot( void * ) ); - CONNECT( this, askVideoToResize( unsigned int, unsigned int ), - videoWidget, SetSizing( unsigned int, unsigned int ) ); + if( videoWidget ) + CONNECT( this, askVideoToResize( unsigned int, unsigned int ), + videoWidget, SetSizing( unsigned int, unsigned int ) ); CONNECT( this, askUpdate(), this, doComponentsUpdate() ); - CONNECT( controls, advancedControlsToggled( bool ), - this, doComponentsUpdate() ); - - CONNECT( fullscreenControls, advancedControlsToggled( bool ), - this, doComponentsUpdate() ); - - CONNECT( THEMIM->getIM(), inputUnset(), - fullscreenControls, unregFullscreenCallback() ); - - /* Size and placement of interface */ - QVLCTools::restoreWidgetPosition(settings,this,QSize(350,60)); + QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); /* Playlist */ @@ -260,7 +249,7 @@ MainInterface::~MainInterface() msg_Dbg( p_intf, "Destroying the main interface" ); if( playlistWidget ) - playlistWidget->savingSettings( settings ); + playlistWidget->savingSettings(); settings->beginGroup( "MainWindow" ); @@ -276,14 +265,11 @@ MainInterface::~MainInterface() settings->setValue( "backgroundSize", bgWidget->size() ); settings->endGroup(); - delete settings; var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); /* Unregister callback for the intf-popupmenu variable */ - playlist_t *p_playlist = pl_Yield( p_intf ); - var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - pl_Release( p_intf ); + var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); p_intf->b_interaction = false; var_DelCallback( p_intf, "interaction", InteractCallback, this ); @@ -305,10 +291,13 @@ inline void MainInterface::createStatusBar() timeLabel = new TimeLabel; timeLabel->setText( " --:--/--:-- " ); timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter ); + timeLabel->setToolTip( qtr( "Toggle between elapsed and remaining time" ) ); nameLabel = new QLabel; nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard ); speedLabel = new SpeedLabel( p_intf, "1.00x" ); + speedLabel->setToolTip( + qtr( "Current playback speed.\nRight click to adjust" ) ); speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu ); /* Styling those labels */ @@ -316,13 +305,10 @@ inline void MainInterface::createStatusBar() speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel ); nameLabel->setFrameStyle( QFrame::Sunken | QFrame::StyledPanel); - pgBar = new QProgressBar; - pgBar->hide(); /* and adding those */ statusBar()->addWidget( nameLabel, 8 ); statusBar()->addPermanentWidget( speedLabel, 0 ); - statusBar()->addPermanentWidget( pgBar, 0 ); statusBar()->addPermanentWidget( timeLabel, 0 ); /* timeLabel behaviour: @@ -390,16 +376,22 @@ void MainInterface::handleMainUi( QSettings *settings ) mainLayout->setMargin( 0 ); /* Create the CONTROLS Widget */ - /* bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); */ + bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); controls = new ControlsWidget( p_intf, this, settings->value( "adv-controls", false ).toBool(), - config_GetInt( p_intf, "qt-blingbling" ) ); + b_shiny ); + CONNECT( controls, advancedControlsToggled( bool ), + this, doComponentsUpdate() ); /* Create the FULLSCREEN CONTROLS Widget */ - /* bool b_shiny = config_GetInt( p_intf, "qt-blingbling" ); */ - fullscreenControls = new FullscreenControllerWidget( p_intf, this, - settings->value( "adv-controls", false ).toBool(), - config_GetInt( p_intf, "qt-blingbling" ) ); + if( config_GetInt( p_intf, "qt-fs-controller" ) ) + { + fullscreenControls = new FullscreenControllerWidget( p_intf, this, + settings->value( "adv-controls", false ).toBool(), + b_shiny ); + CONNECT( fullscreenControls, advancedControlsToggled( bool ), + this, doComponentsUpdate() ); + } /* Add the controls Widget to the main Widget */ mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom ); @@ -420,27 +412,25 @@ void MainInterface::handleMainUi( QSettings *settings ) visualSelector->hide(); #endif - /* And video Outputs */ - if( i_visualmode == QT_ALWAYS_VIDEO_MODE || - i_visualmode == QT_MINIMAL_MODE ) + /* Bg Cone */ + bgWidget = new BackgroundWidget( p_intf ); + bgWidget->resize( + settings->value( "backgroundSize", QSize( 300, 200 ) ).toSize() ); + bgWidget->updateGeometry(); + mainLayout->insertWidget( 0, bgWidget ); + CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); + + if( i_visualmode != QT_ALWAYS_VIDEO_MODE && + i_visualmode != QT_MINIMAL_MODE ) { - bgWidget = new BackgroundWidget( p_intf ); - bgWidget->resize( - settings->value( "backgroundSize", QSize( 300, 150 ) ).toSize() ); - bgWidget->updateGeometry(); - mainLayout->insertWidget( 0, bgWidget ); - CONNECT( this, askBgWidgetToToggle(), bgWidget, toggle() ); + bgWidget->hide(); } + /* And video Outputs */ if( videoEmbeddedFlag ) { videoWidget = new VideoWidget( p_intf ); - mainLayout->insertWidget( 0, videoWidget ); - - var_Create( p_intf, "window_widget", VLC_VAR_ADDRESS ); - vlc_value_t val; - val.p_address = this; - var_Set( p_intf, "window_widget", val ); + mainLayout->insertWidget( 0, videoWidget, 10 ); } /* Finish the sizing */ @@ -455,7 +445,7 @@ inline void MainInterface::askForPrivacy() if( config_GetInt( p_intf, "qt-privacy-ask") ) { QList controls; - if( privacyDialog( controls ) == QDialog::Accepted ) + if( privacyDialog( &controls ) == QDialog::Accepted ) { QList::Iterator i; for( i = controls.begin() ; i != controls.end() ; i++ ) @@ -471,11 +461,11 @@ inline void MainInterface::askForPrivacy() } } -int MainInterface::privacyDialog( QList controls ) +int MainInterface::privacyDialog( QList *controls ) { QDialog *privacy = new QDialog(); - privacy->setWindowTitle( qtr( "Privacy and Network policies" ) ); + privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) ); QGridLayout *gLayout = new QGridLayout( privacy ); @@ -485,7 +475,7 @@ int MainInterface::privacyDialog( QList controls ) "

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

\n " "

VLC media player can request limited information on " - "the Internet, especially to get CD covers and songs metadata or to know " + "the Internet, especially to get CD covers or to know " "if updates are available.

\n" "

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

\n" @@ -511,7 +501,7 @@ int MainInterface::privacyDialog( QList controls ) { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, options, false, optionsLayout, line ); \ - controls.append( control ); \ + controls->append( control ); \ } #define CONFIG_GENERIC_NOBOOL( option, type ) \ @@ -520,17 +510,16 @@ int MainInterface::privacyDialog( QList controls ) { \ control = new type ## ConfigControl( VLC_OBJECT(p_intf), \ p_config, options, optionsLayout, line ); \ - controls.append( control ); \ + controls->append( control ); \ } CONFIG_GENERIC( "album-art", IntegerList ); line++; - CONFIG_GENERIC_NOBOOL( "fetch-meta", Bool ); line++; #ifdef UPDATE_CHECK CONFIG_GENERIC_NOBOOL( "qt-updates-notif", Bool ); line++; CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); line++; #endif - QPushButton *ok = new QPushButton( qtr( "Ok" ) ); + QPushButton *ok = new QPushButton( qtr( "OK" ) ); gLayout->addWidget( ok, 2, 2 ); @@ -658,13 +647,11 @@ private: * Thou shall not call/resize/hide widgets from on another thread. * This is wrong, and this is TEH reason to emit signals on those Video Functions **/ -/* function called from ::DoRequest in order to show a nice VideoWidget - at the good size */ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, int *pi_y, unsigned int *pi_width, unsigned int *pi_height ) { - bool bgWasVisible = false; + bgWasVisible = false; /* Request the videoWidget */ void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height ); @@ -691,24 +678,19 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, #endif videoIsActive = true; - emit askVideoToResize( *pi_width, *pi_height ); +// emit askVideoToResize( *pi_width, *pi_height ); emit askUpdate(); - fullscreenControls->regFullscreenCallback( p_nvout ); + if( fullscreenControls ) fullscreenControls->attachVout( p_nvout ); } return ret; } -/* function called from ::DoRequest in order to show a nice VideoWidget - at the good size */ -void MainInterface::requestNotEmbeddedVideo( vout_thread_t *p_nvout ) -{ - fullscreenControls->regFullscreenCallback( p_nvout ); -} - void MainInterface::releaseVideo( void *p_win ) { - emit askReleaseVideo( p_win ); + if( fullscreenControls ) fullscreenControls->detachVout(); + if( p_win ) + emit askReleaseVideo( p_win ); } void MainInterface::releaseVideoSlot( void *p_win ) @@ -716,8 +698,11 @@ void MainInterface::releaseVideoSlot( void *p_win ) videoWidget->release( p_win ); videoWidget->hide(); - if( bgWidget )// WRONG + if( bgWasVisible ) + { + bgWasVisible = false; bgWidget->show(); + } adjustSize(); videoIsActive = false; @@ -817,6 +802,14 @@ void MainInterface::undockPlaylist() void MainInterface::toggleMinimalView() { + /* HACK for minimalView, see menus.cpp */ + if( !menuBar()->isVisible() ) QVLCMenu::minimalViewAction->toggle(); + if( i_visualmode != QT_ALWAYS_VIDEO_MODE && + i_visualmode != QT_MINIMAL_MODE ) + { + if( videoWidget->isHidden() ) emit askBgWidgetToToggle(); + } + TOGGLEV( menuBar() ); TOGGLEV( controls ); TOGGLEV( statusBar() ); @@ -836,6 +829,7 @@ void MainInterface::doComponentsUpdate() void MainInterface::toggleAdvanced() { controls->toggleAdvanced(); + fullscreenControls->toggleAdvanced(); } /* Get the visibility status of the controls (hidden or not, advanced or not) */ @@ -902,13 +896,18 @@ void MainInterface::setName( QString name ) void MainInterface::setStatus( int status ) { - msg_Dbg( p_intf, "I was here, updating your status" ); + msg_Dbg( p_intf, "Updating the stream status: %i", status ); + /* Forward the status to the controls to toggle Play/Pause */ controls->setStatus( status ); - fullscreenControls->setStatus( status ); - controls->updateInput(); - fullscreenControls->updateInput(); + + if( fullscreenControls ) + { + fullscreenControls->setStatus( status ); + fullscreenControls->updateInput(); + } + speedControl->setEnable( THEMIM->getIM()->hasInput() ); /* And in the systray for the menu */