⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_interface.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 3 页
字号:
}/* toggling advanced controls buttons */void MainInterface::toggleAdvanced(){    controls->toggleAdvanced();    if( fullscreenControls ) fullscreenControls->toggleAdvanced();}/* Get the visibility status of the controls (hidden or not, advanced or not) */int MainInterface::getControlsVisibilityStatus(){    return( (controls->isVisible() ? CONTROLS_VISIBLE : CONTROLS_HIDDEN )                + CONTROLS_ADVANCED * controls->b_advancedVisible );}#if 0void MainInterface::visual(){    if( !VISIBLE( visualSelector) )    {        visualSelector->show();        if( !THEMIM->getIM()->hasVideo() )        {            /* Show the background widget */        }        visualSelectorEnabled = true;    }    else    {        /* Stop any currently running visualization */        visualSelector->hide();        visualSelectorEnabled = false;    }    doComponentsUpdate();}#endif/************************************************************************ * Other stuff ************************************************************************/void MainInterface::setDisplayPosition( float pos, int time, int length ){    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];    secstotimestr( psz_length, length );    secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time                                                           : time );    QString timestr;    timestr.sprintf( "%s/%s", psz_time,                            ( !length && time ) ? "--:--" : psz_length );    /* Add a minus to remaining time*/    if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );    else timeLabel->setText( " "+timestr+" " );}void MainInterface::toggleTimeDisplay(){    b_remainingTime = !b_remainingTime;}void MainInterface::setName( QString name ){    input_name = name; /* store it for the QSystray use */    /* Display it in the status bar, but also as a Tooltip in case it doesn't       fit in the label */    nameLabel->setText( " " + name + " " );    nameLabel->setToolTip( " " + name +" " );}void MainInterface::setStatus( int status ){    msg_Dbg( p_intf, "Updating the stream status: %i", 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 */    if( sysTray )        QVLCMenu::updateSystrayMenu( this, p_intf );}void MainInterface::setRate( int rate ){    QString str;    str.setNum( ( 1000 / (double)rate ), 'f', 2 );    str.append( "x" );    speedLabel->setText( str );    speedLabel->setToolTip( str );    speedControl->updateControls( rate );}void MainInterface::updateOnTimer(){    /* No event for dying */    if( intf_ShouldDie( p_intf ) )    {        QApplication::closeAllWindows();        QApplication::quit();    }}/***************************************************************************** * Systray Icon and Systray Menu *****************************************************************************//** * Create a SystemTray icon and a menu that would go with it. * Connects to a click handler on the icon. **/void MainInterface::createSystray(){    QIcon iconVLC;    if( QDate::currentDate().dayOfYear() >= 354 )        iconVLC =  QIcon( QPixmap( ":/vlc128-christmas.png" ) );    else        iconVLC =  QIcon( QPixmap( ":/vlc128.png" ) );    sysTray = new QSystemTrayIcon( iconVLC, this );    sysTray->setToolTip( qtr( "VLC media player" ));    systrayMenu = new QMenu( qtr( "VLC media player" ), this );    systrayMenu->setIcon( iconVLC );    QVLCMenu::updateSystrayMenu( this, p_intf, true );    sysTray->show();    CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),            this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );}/** * Updates the Systray Icon's menu and toggle the main interface */void MainInterface::toggleUpdateSystrayMenu(){    /* If hidden, show it */    if( isHidden() )    {        show();        activateWindow();    }    else if( isMinimized() )    {        /* Minimized */        showNormal();        activateWindow();    }    else    {        /* Visible */#ifdef WIN32        /* check if any visible window is above vlc in the z-order,         * but ignore the ones always on top */        WINDOWINFO wi;        HWND hwnd;        wi.cbSize = sizeof( WINDOWINFO );        for( hwnd = GetNextWindow( internalWinId(), GW_HWNDPREV );                hwnd && !IsWindowVisible( hwnd );                hwnd = GetNextWindow( hwnd, GW_HWNDPREV ) );        if( !hwnd || !GetWindowInfo( hwnd, &wi ) ||                (wi.dwExStyle&WS_EX_TOPMOST) )#else        if( isActiveWindow() )#endif        {            hide();        }        else        {            activateWindow();        }    }    QVLCMenu::updateSystrayMenu( this, p_intf );}void MainInterface::handleSystrayClick(                                    QSystemTrayIcon::ActivationReason reason ){    switch( reason )    {        case QSystemTrayIcon::Trigger:            toggleUpdateSystrayMenu();            break;        case QSystemTrayIcon::MiddleClick:            sysTray->showMessage( qtr( "VLC media player" ),                    qtr( "Control menu for the player" ),                    QSystemTrayIcon::Information, 3000 );            break;    }}/** * Updates the name of the systray Icon tooltip. * Doesn't check if the systray exists, check before you call it. **/void MainInterface::updateSystrayTooltipName( QString name ){    if( name.isEmpty() )    {        sysTray->setToolTip( qtr( "VLC media player" ) );    }    else    {        sysTray->setToolTip( name );        if( notificationEnabled && ( isHidden() || isMinimized() ) )        {            sysTray->showMessage( qtr( "VLC media player" ), name,                    QSystemTrayIcon::NoIcon, 3000 );        }    }}/** * Updates the status of the systray Icon tooltip. * Doesn't check if the systray exists, check before you call it. **/void MainInterface::updateSystrayTooltipStatus( int i_status ){    switch( i_status )    {        case  0:        case  END_S:            {                sysTray->setToolTip( qtr( "VLC media player" ) );                break;            }        case PLAYING_S:            {                sysTray->setToolTip( input_name );                break;            }        case PAUSE_S:            {                sysTray->setToolTip( input_name + " - "                        + qtr( "Paused") );                break;            }    }}/************************************************************************ * D&D Events ************************************************************************/void MainInterface::dropEvent(QDropEvent *event){     const QMimeData *mimeData = event->mimeData();     /* D&D of a subtitles file, add it on the fly */     if( mimeData->urls().size() == 1 )     {        if( THEMIM->getIM()->hasInput() )        {            if( input_AddSubtitles( THEMIM->getInput(),                                    qtu( toNativeSeparators(                                         mimeData->urls()[0].toLocalFile() ) ),                                    true ) )            {                event->acceptProposedAction();                return;            }        }     }     bool first = true;     foreach( QUrl url, mimeData->urls() )     {        QString s = toNativeSeparators( url.toLocalFile() );        if( s.length() > 0 ) {            playlist_Add( THEPL, qtu(s), NULL,                          PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),                          PLAYLIST_END, true, false );            first = false;        }     }     event->acceptProposedAction();}void MainInterface::dragEnterEvent(QDragEnterEvent *event){     event->acceptProposedAction();}void MainInterface::dragMoveEvent(QDragMoveEvent *event){     event->acceptProposedAction();}void MainInterface::dragLeaveEvent(QDragLeaveEvent *event){     event->accept();}/************************************************************************ * Events stuff ************************************************************************/void MainInterface::customEvent( QEvent *event ){#if 0    if( event->type() == PLDockEvent_Type )    {        PlaylistDialog::killInstance();        playlistEmbeddedFlag = true;        menuBar()->clear();        QVLCMenu::createMenuBar(this, p_intf, true, visualSelectorEnabled);        togglePlaylist();    }#endif    /*else */    if ( event->type() == SetVideoOnTopEvent_Type )    {        SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;        if( p_event->OnTop() )            setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);        else            setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);        show(); /* necessary to apply window flags?? */    }}void MainInterface::keyPressEvent( QKeyEvent *e ){    if( ( e->modifiers() &  Qt::ControlModifier ) && ( e->key() == Qt::Key_H )          && menuBar()->isHidden() )    {        toggleMinimalView();        e->accept();    }    int i_vlck = qtEventToVLCKey( e );    if( i_vlck > 0 )    {        var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );        e->accept();    }    else        e->ignore();}void MainInterface::wheelEvent( QWheelEvent *e ){    int i_vlckey = qtWheelEventToVLCKey( e );    var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlckey );    e->accept();}void MainInterface::closeEvent( QCloseEvent *e ){    hide();    THEDP->quit();}void MainInterface::toggleFullScreen( void ){    if( isFullScreen() )    {        showNormal();        emit askUpdate(); // Needed if video was launched after the F11    }    else        showFullScreen();}/***************************************************************************** * Callbacks *****************************************************************************/static int InteractCallback( vlc_object_t *p_this,                             const char *psz_var, vlc_value_t old_val,                             vlc_value_t new_val, void *param ){    intf_dialog_args_t *p_arg = new intf_dialog_args_t;    p_arg->p_dialog = (interaction_dialog_t *)(new_val.p_address);    DialogEvent *event = new DialogEvent( INTF_DIALOG_INTERACTION, 0, p_arg );    QApplication::postEvent( THEDP, static_cast<QEvent*>(event) );    return VLC_SUCCESS;}/***************************************************************************** * PopupMenuCB: callback triggered by the intf-popupmenu playlist variable. *  We don't show the menu directly here because we don't want the *  caller to block for a too long time. *****************************************************************************/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;    if( p_intf->pf_show_dialog )    {        p_intf->pf_show_dialog( p_intf, INTF_DIALOG_POPUPMENU,                                new_val.b_bool, 0 );    }    return VLC_SUCCESS;}/***************************************************************************** * 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;    p_intf->p_sys->p_mi->toggleFSC();    /* Show event */    return VLC_SUCCESS;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -