X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fmain_interface.cpp;h=0ee6864c308b03d84955c1c9fc91552e2b4fed1e;hb=175d1beb96ca494f8bfdee0ad488b303ef55e9ec;hp=697438d60309806ab6ea3ae7d75ad076fb33046f;hpb=d28d12946380cbbff3dae12e8303746bf67b154f;p=vlc diff --git a/modules/gui/qt4/main_interface.cpp b/modules/gui/qt4/main_interface.cpp index 697438d603..0ee6864c30 100644 --- a/modules/gui/qt4/main_interface.cpp +++ b/modules/gui/qt4/main_interface.cpp @@ -76,32 +76,19 @@ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ); static int InteractCallback( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void *); -/* Video handling */ -static void *DoRequest( intf_thread_t *p_intf, vout_thread_t *p_vout, - int *pi1, int *pi2, unsigned int*pi3,unsigned int*pi4) -{ - return p_intf->p_sys->p_mi->requestVideo( p_vout, pi1, pi2, pi3, pi4 ); -} -static void DoRelease( intf_thread_t *p_intf, void *p_win ) -{ - return p_intf->p_sys->p_mi->releaseVideo( p_win ); -} -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 ); -} 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(); @@ -123,7 +110,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 @@ -138,14 +125,14 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) #if 0 /* Create a Dock to get the playlist */ -/* dockPL = new QDockWidget( qtr( "Playlist" ), this ); + 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();*/ + dockPL->hide(); #endif /************ @@ -220,37 +207,25 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) **/ var_Create( p_intf, "interaction", VLC_VAR_ADDRESS ); var_AddCallback( p_intf, "interaction", InteractCallback, this ); - p_intf->b_interaction = VLC_TRUE; + p_intf->b_interaction = true; + + var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); /* Register callback for the intf-popupmenu variable */ - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( p_playlist != NULL ) - { - var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - var_AddCallback( p_playlist, "intf-show", IntfShowCB, p_intf ); - vlc_object_release( p_playlist ); - } + 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() ); - /* Size and placement of interface */ - move( settings->value( "pos", QPoint( 0, 0 ) ).toPoint() ); + QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) ); - QSize newSize = settings->value( "size", QSize( 350, 60 ) ).toSize(); - if( newSize.isValid() ) - resize( newSize ); - else - msg_Warn( p_intf, "Invalid size in constructor" ); /* Playlist */ if( settings->value( "playlist-visible", 0 ).toInt() ) togglePlaylist(); @@ -274,38 +249,32 @@ MainInterface::~MainInterface() { msg_Dbg( p_intf, "Destroying the main interface" ); - if( playlistWidget ) playlistWidget->savingSettings( settings ); + if( playlistWidget ) + playlistWidget->savingSettings(); settings->beginGroup( "MainWindow" ); -// settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) ); + + // settings->setValue( "playlist-floats", (int)(dockPL->isFloating()) ); settings->setValue( "playlist-visible", (int)playlistVisible ); settings->setValue( "adv-controls", getControlsVisibilityStatus() & CONTROLS_ADVANCED ); - settings->setValue( "pos", pos() ); + if( !videoIsActive ) - settings->setValue( "size", size() ); + QVLCTools::saveWidgetPosition(settings, this); + if( bgWidget ) 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 = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - if( p_playlist != NULL ) - { - var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - var_DelCallback( p_playlist, "intf-show", IntfShowCB, p_intf ); - vlc_object_release( p_playlist ); - } + var_DelCallback( p_intf->p_libvlc, "intf-popupmenu", PopupMenuCB, p_intf ); - p_intf->b_interaction = VLC_FALSE; + p_intf->b_interaction = false; var_DelCallback( p_intf, "interaction", InteractCallback, this ); - p_intf->pf_request_window = NULL; - p_intf->pf_release_window = NULL; - p_intf->pf_control_window = NULL; p_intf->p_sys->p_mi = NULL; } @@ -323,10 +292,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 */ @@ -404,13 +376,26 @@ void MainInterface::handleMainUi( QSettings *settings ) /* Margins, spacing */ main->setContentsMargins( 0, 0, 0, 0 ); main->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Maximum ); + mainLayout->setSpacing( 0 ); 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 */ + 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 ); @@ -431,26 +416,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 ); - - p_intf->pf_request_window = ::DoRequest; - p_intf->pf_release_window = ::DoRelease; - p_intf->pf_control_window = ::DoControl; + mainLayout->insertWidget( 0, videoWidget, 10 ); } /* Finish the sizing */ @@ -483,9 +467,9 @@ inline void MainInterface::askForPrivacy() int MainInterface::privacyDialog( QList controls ) { - QDialog *privacy = new QDialog( this ); + QDialog *privacy = new QDialog(); - privacy->setWindowTitle( qtr( "Privacy and Network policies" ) ); + privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) ); QGridLayout *gLayout = new QGridLayout( privacy ); @@ -495,7 +479,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" @@ -534,14 +518,12 @@ int MainInterface::privacyDialog( QList controls ) } 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 - CONFIG_GENERIC( "security-policy", IntegerList ); line++; - QPushButton *ok = new QPushButton( qtr( "Ok" ) ); + QPushButton *ok = new QPushButton( qtr( "OK" ) ); gLayout->addWidget( ok, 2, 2 ); @@ -626,7 +608,7 @@ void MainInterface::debug() { msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); - if( videoWidget->isVisible() ) + if( videoWidget && videoWidget->isVisible() ) { // sleep( 10 ); msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); @@ -669,13 +651,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 ); @@ -687,29 +667,32 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, bgWasVisible = true; emit askBgWidgetToToggle(); } - - /*if( THEMIM->getIM()->hasVideo() || !bgWasVisible ) +#if 0 + if( THEMIM->getIM()->hasVideo() || !bgWasVisible ) { videoWidget->widgetSize = QSize( *pi_width, *pi_height ); } else /* Background widget available, use its size */ - /*{ + { /* Ok, our visualizations are bad, so don't do this for the moment * use the requested size anyway */ // videoWidget->widgetSize = bgWidget->widgeTSize; - /* videoWidget->widgetSize = QSize( *pi_width, *pi_height ); - }*/ - + videoWidget->widgetSize = QSize( *pi_width, *pi_height ); + } +#endif videoIsActive = true; - emit askVideoToResize( *pi_width, *pi_height ); +// emit askVideoToResize( *pi_width, *pi_height ); emit askUpdate(); + + if( fullscreenControls ) fullscreenControls->attachVout( p_nvout ); } return ret; } -void MainInterface::releaseVideo( void *p_win ) +void MainInterface::releaseVideo( vout_thread_t *p_vout, void *p_win ) { + if( fullscreenControls ) fullscreenControls->detachVout( p_vout ); emit askReleaseVideo( p_win ); } @@ -718,8 +701,11 @@ void MainInterface::releaseVideoSlot( void *p_win ) videoWidget->release( p_win ); videoWidget->hide(); - if( bgWidget )// WORONG + if( bgWasVisible ) + { + bgWasVisible = false; bgWidget->show(); + } adjustSize(); videoIsActive = false; @@ -819,6 +805,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 ) + { + emit askBgWidgetToToggle(); + } + TOGGLEV( menuBar() ); TOGGLEV( controls ); TOGGLEV( statusBar() ); @@ -838,6 +832,7 @@ void MainInterface::doComponentsUpdate() void MainInterface::toggleAdvanced() { controls->toggleAdvanced(); + fullscreenControls->toggleAdvanced(); } /* Get the visibility status of the controls (hidden or not, advanced or not) */ @@ -905,10 +900,17 @@ void MainInterface::setName( QString name ) void MainInterface::setStatus( int status ) { msg_Dbg( p_intf, "I was here, updating your status" ); + /* Forward the status to the controls to toggle Play/Pause */ controls->setStatus( status ); - controls->updateInput(); + + if( fullscreenControls ) + { + fullscreenControls->setStatus( status ); + fullscreenControls->updateInput(); + } + speedControl->setEnable( THEMIM->getIM()->hasInput() ); /* And in the systray for the menu */ @@ -1088,7 +1090,7 @@ void MainInterface::dropEvent(QDropEvent *event) { if( input_AddSubtitles( THEMIM->getInput(), qtu( mimeData->urls()[0].toString() ), - VLC_TRUE ) ) + true ) ) { event->acceptProposedAction(); return; @@ -1096,12 +1098,13 @@ void MainInterface::dropEvent(QDropEvent *event) } } bool first = true; - foreach( QUrl url, mimeData->urls() ) { - QString s = url.toString(); + foreach( QUrl url, mimeData->urls() ) + { + QString s = url.toLocalFile(); if( s.length() > 0 ) { playlist_Add( THEPL, qtu(s), NULL, PLAYLIST_APPEND | (first ? PLAYLIST_GO:0), - PLAYLIST_END, VLC_TRUE, VLC_FALSE ); + PLAYLIST_END, true, false ); first = false; } } @@ -1210,7 +1213,6 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ) { intf_thread_t *p_intf = (intf_thread_t *)param; - msg_Dbg( p_this, "Menu Requested" ); // DEBUG to track the non disparition of the menu... if( p_intf->pf_show_dialog ) { @@ -1222,13 +1224,12 @@ static int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, } /***************************************************************************** - * IntfShowCB: callback triggered by the intf-show playlist variable. + * IntfShowCB: callback triggered by the intf-show libvlc variable. *****************************************************************************/ static int IntfShowCB( vlc_object_t *p_this, const char *psz_variable, vlc_value_t old_val, vlc_value_t new_val, void *param ) { intf_thread_t *p_intf = (intf_thread_t *)param; - msg_Dbg( p_this, "Intf Show Requested" ); // DEBUG to track the non disparition of the menu... p_intf->p_sys->p_mi->requestLayoutUpdate(); return VLC_SUCCESS;