📄 main_interface.cpp
字号:
/* Add the controls Widget to the main Widget */ mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom ); /* Create the Speed Control Widget */ speedControl = new SpeedControlWidget( p_intf ); speedControlMenu = new QMenu( this ); QWidgetAction *widgetAction = new QWidgetAction( speedControl ); widgetAction->setDefaultWidget( speedControl ); speedControlMenu->addAction( widgetAction ); /* Visualisation */ /* Disabled for now, they SUCK */ #if 0 visualSelector = new VisualSelector( p_intf ); mainLayout->insertWidget( 0, visualSelector ); visualSelector->hide(); #endif /* 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->hide(); } /* And video Outputs */ if( videoEmbeddedFlag ) { videoWidget = new VideoWidget( p_intf ); mainLayout->insertWidget( 0, videoWidget, 10 ); } /* Finish the sizing */ main->updateGeometry();}inline void MainInterface::askForPrivacy(){ /** * Ask for the network policy on FIRST STARTUP **/ if( config_GetInt( p_intf, "qt-privacy-ask") ) { QList<ConfigControl *> controls; if( privacyDialog( &controls ) == QDialog::Accepted ) { QList<ConfigControl *>::Iterator i; for( i = controls.begin() ; i != controls.end() ; i++ ) { ConfigControl *c = qobject_cast<ConfigControl *>(*i); c->doApply( p_intf ); } 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 ); } }}int MainInterface::privacyDialog( QList<ConfigControl *> *controls ){ QDialog *privacy = new QDialog(); privacy->setWindowTitle( qtr( "Privacy and Network Policies" ) ); QGridLayout *gLayout = new QGridLayout( privacy ); QGroupBox *blabla = new QGroupBox( qtr( "Privacy and Network Warning" ) ); QGridLayout *blablaLayout = new QGridLayout( blabla ); QLabel *text = new QLabel( qtr( "<p>The <i>VideoLAN Team</i> doesn't like when an application goes " "online without authorization.</p>\n " "<p><i>VLC media player</i> can request limited information on " "the Internet, especially to get CD covers or to know " "if updates are available.</p>\n" "<p><i>VLC media player</i> <b>DOES NOT</b> send or collect <b>ANY</b> " "information, even anonymously, about your usage.</p>\n" "<p>Therefore please check the following options, the default being " "almost no access on the web.</p>\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++; CONFIG_GENERIC_NOBOOL( "qt-updates-days", Integer ); 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 **********************************************************************//* This function is probably wrong, but we don't have many many choices... Since we can't know from the playlist Widget if we are inside a dock or not, because the playlist Widget can be called by THEDP, as a separate windows for the skins. Maybe the other solution is to redefine the sizeHint() of the playlist and ask _parent->isFloating()... If you think this would be better, please FIXME it...*/QSize MainInterface::sizeHint() const{ int nwidth = controls->sizeHint().width(); int nheight = controls->isVisible() ? controls->size().height() + menuBar()->size().height() + statusBar()->size().height() : 0 ; if( VISIBLE( bgWidget ) ) { nheight += bgWidget->size().height(); nwidth = bgWidget->size().width(); } else if( videoIsActive && videoWidget->isVisible() ) { nheight += videoWidget->sizeHint().height(); nwidth = videoWidget->sizeHint().width(); }#if 0 if( !dockPL->isFloating() && dockPL->isVisible() && dockPL->widget() ) { nheight += dockPL->size().height(); nwidth = __MAX( nwidth, dockPL->size().width() ); msg_Warn( p_intf, "3 %i %i", nheight, nwidth ); }#endif return QSize( nwidth, nheight );}void MainInterface::toggleFSC(){ if( !fullscreenControls ) return; IMEvent *eShow = new IMEvent( FullscreenControlToggle_Type, 0 ); QApplication::postEvent( fullscreenControls, static_cast<QEvent *>(eShow) );}void MainInterface::debug(){#ifndef NDEBUG msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); if( videoWidget && videoWidget->isVisible() ) { msg_Dbg( p_intf, "size: %i - %i", size().height(), size().width() ); msg_Dbg( p_intf, "sizeHint: %i - %i", sizeHint().height(), sizeHint().width() ); }#endif}/**************************************************************************** * Small right-click menu for rate control ****************************************************************************/void MainInterface::showSpeedMenu( QPoint pos ){ speedControlMenu->exec( QCursor::pos() - pos + QPoint( 0, speedLabel->height() ) );}/**************************************************************************** * Video Handling ****************************************************************************//* This event is used to deal with the fullscreen and always on top issue conflict (bug in wx) */class SetVideoOnTopQtEvent : public QEvent{public: SetVideoOnTopQtEvent( bool _onTop ) : QEvent( (QEvent::Type)SetVideoOnTopEvent_Type ), onTop( _onTop) {} bool OnTop() const { return onTop; }private: bool onTop;};/** * README * 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 **/void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x, int *pi_y, unsigned int *pi_width, unsigned int *pi_height ){ /* Request the videoWidget */ void *ret = videoWidget->request( p_nvout,pi_x, pi_y, pi_width, pi_height ); if( ret ) /* The videoWidget is available */ { /* Did we have a bg ? Hide it! */ if( VISIBLE( bgWidget) ) { bgWasVisible = true; emit askBgWidgetToToggle(); } else bgWasVisible = false; /* Consider the video active now */ videoIsActive = true; emit askUpdate(); if( fullscreenControls ) fullscreenControls->attachVout( p_nvout ); } return ret;}/* Call from the WindowClose function */void MainInterface::releaseVideo( void *p_win ){ if( fullscreenControls ) fullscreenControls->detachVout(); if( p_win ) emit askReleaseVideo( p_win );}/* Function that is CONNECTED to the previous emit */void MainInterface::releaseVideoSlot( void *p_win ){ videoWidget->release( p_win ); if( bgWasVisible ) { /* Reset the bg state */ bgWasVisible = false; bgWidget->show(); } videoIsActive = false; /* Try to resize, except when you are in Fullscreen mode */ if( !isFullScreen() ) doComponentsUpdate();}/* Call from WindowControl function */int MainInterface::controlVideo( void *p_window, int i_query, va_list args ){ int i_ret = VLC_SUCCESS; switch( i_query ) { case VOUT_GET_SIZE: { unsigned int *pi_width = va_arg( args, unsigned int * ); unsigned int *pi_height = va_arg( args, unsigned int * ); *pi_width = videoWidget->videoSize.width(); *pi_height = videoWidget->videoSize.height(); break; } case VOUT_SET_SIZE: { unsigned int i_width = va_arg( args, unsigned int ); unsigned int i_height = va_arg( args, unsigned int ); emit askVideoToResize( i_width, i_height ); emit askUpdate(); break; } case VOUT_SET_STAY_ON_TOP: { int i_arg = va_arg( args, int ); QApplication::postEvent( this, new SetVideoOnTopQtEvent( i_arg ) ); break; } default: i_ret = VLC_EGENERIC; msg_Warn( p_intf, "unsupported control query" ); break; } return i_ret;}/***************************************************************************** * Playlist, Visualisation and Menus handling *****************************************************************************//** * Toggle the playlist widget or dialog **/void MainInterface::togglePlaylist(){ /* CREATION If no playlist exist, then create one and attach it to the DockPL*/ if( !playlistWidget ) { playlistWidget = new PlaylistWidget( p_intf, this ); i_pl_dock = PL_UNDOCKED;/* i_pl_dock = (pl_dock_e)getSettings() ->value( "pl-dock-status", PL_UNDOCKED ).toInt(); */ if( i_pl_dock == PL_UNDOCKED ) { playlistWidget->setWindowFlags( Qt::Window ); QVLCTools::restoreWidgetPosition( p_intf, "Playlist", playlistWidget, QSize( 600, 300 ) ); } else { mainLayout->insertWidget( 4, playlistWidget ); } playlistVisible = true; playlistWidget->show(); } else { /* toggle the visibility of the playlist */ TOGGLEV( playlistWidget ); playlistVisible = !playlistVisible; //doComponentsUpdate(); //resize( sizeHint() ); }}/* Function called from the menu to undock the playlist */void MainInterface::undockPlaylist(){// dockPL->setFloating( true );// adjustSize();}void MainInterface::dockPlaylist( pl_dock_e i_pos ){}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 ) { /* NORMAL MODE then */ if( videoWidget->isHidden() ) emit askBgWidgetToToggle(); else { /* If video is visible, then toggle the status of bgWidget */ bgWasVisible = !bgWasVisible; } } TOGGLEV( menuBar() ); TOGGLEV( controls ); TOGGLEV( statusBar() ); doComponentsUpdate();}/* Video widget cannot do this synchronously as it runs in another thread *//* Well, could it, actually ? Probably dangerous ... *//* This function is called: - toggling of minimal View - through askUpdate() by Vout thread request video and resize video (zoom) - Advanced buttons toggled */void MainInterface::doComponentsUpdate(){ msg_Dbg( p_intf, "Updating the geometry" ); /* Here we resize to sizeHint() and not adjustsize because we want the videoWidget to be exactly the correctSize */ resize( sizeHint() ); // adjustSize() ;#ifndef NDEBUG debug();#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -