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

📄 interface_widgets.cpp

📁 VLC Player Source Code
💻 CPP
📖 第 1 页 / 共 4 页
字号:
}/** * event handling * events: show, hide, start timer for hidding */void FullscreenControllerWidget::customEvent( QEvent *event ){    bool b_fs;    switch( event->type() )    {        case FullscreenControlToggle_Type:            vlc_mutex_lock( &lock );            b_fs = b_fullscreen;            vlc_mutex_unlock( &lock );            if( b_fs )#ifdef WIN32TRICK                if( b_fscHidden )#else                if( isHidden() )#endif                {                    p_hideTimer->stop();                    showFSC();                }                else                    hideFSC();            break;        case FullscreenControlShow_Type:            vlc_mutex_lock( &lock );            b_fs = b_fullscreen;            vlc_mutex_unlock( &lock );            if( b_fs )  // FIXME I am not sure about that one                showFSC();            break;        case FullscreenControlHide_Type:            hideFSC();            break;        case FullscreenControlPlanHide_Type:            if( !b_mouse_over ) // Only if the mouse is not over FSC                planHideFSC();            break;    }}/** * On mouse move * moving with FSC */void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event ){    if ( event->buttons() == Qt::LeftButton )    {        int i_moveX = event->globalX() - i_mouse_last_x;        int i_moveY = event->globalY() - i_mouse_last_y;        move( x() + i_moveX, y() + i_moveY );        i_mouse_last_x = event->globalX();        i_mouse_last_y = event->globalY();    }}/** * On mouse press * store position of cursor */void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event ){    i_mouse_last_x = event->globalX();    i_mouse_last_y = event->globalY();}/** * On mouse go above FSC */void FullscreenControllerWidget::enterEvent( QEvent *event ){    b_mouse_over = true;    p_hideTimer->stop();#if HAVE_TRANSPARENCY    p_slowHideTimer->stop();#endif}/** * On mouse go out from FSC */void FullscreenControllerWidget::leaveEvent( QEvent *event ){    planHideFSC();    b_mouse_over = false;}/** * When you get pressed key, send it to video output * FIXME: clearing focus by clearFocus() to not getting * key press events didnt work */void FullscreenControllerWidget::keyPressEvent( QKeyEvent *event ){    int i_vlck = qtEventToVLCKey( event );    if( i_vlck > 0 )    {        var_SetInteger( p_intf->p_libvlc, "key-pressed", i_vlck );        event->accept();    }    else        event->ignore();}/* */static int FullscreenControllerWidgetFullscreenChanged( vlc_object_t *vlc_object, const char *variable,                                                        vlc_value_t old_val, vlc_value_t new_val,                                                        void *data ){    vout_thread_t *p_vout = (vout_thread_t *) vlc_object;    FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;    p_fs->fullscreenChanged( p_vout, new_val.b_bool, var_GetInteger( p_vout, "mouse-hide-timeout" ) );    return VLC_SUCCESS;}/* */static int FullscreenControllerWidgetMouseMoved( vlc_object_t *vlc_object, const char *variable,                                                 vlc_value_t old_val, vlc_value_t new_val,                                                 void *data ){    FullscreenControllerWidget *p_fs = (FullscreenControllerWidget *)data;    /* Show event */    IMEvent *eShow = new IMEvent( FullscreenControlShow_Type, 0 );    QApplication::postEvent( p_fs, static_cast<QEvent *>(eShow) );    /* Plan hide event */    IMEvent *eHide = new IMEvent( FullscreenControlPlanHide_Type, 0 );    QApplication::postEvent( p_fs, static_cast<QEvent *>(eHide) );    return VLC_SUCCESS;}/** * It is called when video start */void FullscreenControllerWidget::attachVout( vout_thread_t *p_nvout ){    assert( p_nvout && !p_vout );    p_vout = p_nvout;    vlc_mutex_lock( &lock );    var_AddCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this ); /* I miss a add and fire */    fullscreenChanged( p_vout, var_GetBool( p_vout, "fullscreen" ), var_GetInteger( p_vout, "mouse-hide-timeout" ) );    vlc_mutex_unlock( &lock );}/** * It is called after turn off video. */void FullscreenControllerWidget::detachVout(){    if( p_vout )    {        var_DelCallback( p_vout, "fullscreen", FullscreenControllerWidgetFullscreenChanged, this );        vlc_mutex_lock( &lock );        fullscreenChanged( p_vout, false, 0 );        vlc_mutex_unlock( &lock );        p_vout = NULL;    }}/** * Register and unregister callback for mouse moving */void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout, bool b_fs, int i_timeout ){    vlc_mutex_lock( &lock );    if( b_fs && !b_fullscreen )    {        b_fullscreen = true;        i_hide_timeout = i_timeout;        var_AddCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );    }    else if( !b_fs && b_fullscreen )    {        b_fullscreen = false;        i_hide_timeout = i_timeout;        var_DelCallback( p_vout, "mouse-moved", FullscreenControllerWidgetMouseMoved, this );        /* Force fs hidding */        IMEvent *eHide = new IMEvent( FullscreenControlHide_Type, 0 );        QApplication::postEvent( this, static_cast<QEvent *>(eHide) );    }    vlc_mutex_unlock( &lock );}/********************************************************************** * Speed control widget **********************************************************************/SpeedControlWidget::SpeedControlWidget( intf_thread_t *_p_i ) :                             QFrame( NULL ), p_intf( _p_i ){    QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );    sizePolicy.setHorizontalStretch( 0 );    sizePolicy.setVerticalStretch( 0 );    speedSlider = new QSlider;    speedSlider->setSizePolicy( sizePolicy );    speedSlider->setMaximumSize( QSize( 80, 200 ) );    speedSlider->setOrientation( Qt::Vertical );    speedSlider->setTickPosition( QSlider::TicksRight );    speedSlider->setRange( -24, 24 );    speedSlider->setSingleStep( 1 );    speedSlider->setPageStep( 1 );    speedSlider->setTickInterval( 12 );    CONNECT( speedSlider, valueChanged( int ), this, updateRate( int ) );    QToolButton *normalSpeedButton = new QToolButton( this );    normalSpeedButton->setMaximumSize( QSize( 26, 20 ) );    normalSpeedButton->setAutoRaise( true );    normalSpeedButton->setText( "1x" );    normalSpeedButton->setToolTip( qtr( "Revert to normal play speed" ) );    CONNECT( normalSpeedButton, clicked(), this, resetRate() );    QVBoxLayout *speedControlLayout = new QVBoxLayout;    speedControlLayout->setLayoutMargins( 4, 4, 4, 4, 4 );    speedControlLayout->setSpacing( 4 );    speedControlLayout->addWidget( speedSlider );    speedControlLayout->addWidget( normalSpeedButton );    setLayout( speedControlLayout );}SpeedControlWidget::~SpeedControlWidget(){}void SpeedControlWidget::setEnable( bool b_enable ){    speedSlider->setEnabled( b_enable );}void SpeedControlWidget::updateControls( int rate ){    if( speedSlider->isSliderDown() )    {        //We don't want to change anything if the user is using the slider        return;    }    double value = 12 * log( (double)INPUT_RATE_DEFAULT / rate ) / log( 2 );    int sliderValue = (int) ( ( value > 0 ) ? value + .5 : value - .5 );    if( sliderValue < speedSlider->minimum() )    {        sliderValue = speedSlider->minimum();    }    else if( sliderValue > speedSlider->maximum() )    {        sliderValue = speedSlider->maximum();    }    //Block signals to avoid feedback loop    speedSlider->blockSignals( true );    speedSlider->setValue( sliderValue );    speedSlider->blockSignals( false );}void SpeedControlWidget::updateRate( int sliderValue ){    double speed = pow( 2, (double)sliderValue / 12 );    int rate = INPUT_RATE_DEFAULT / speed;    THEMIM->getIM()->setRate(rate);}void SpeedControlWidget::resetRate(){    THEMIM->getIM()->setRate(INPUT_RATE_DEFAULT);}static int downloadCoverCallback( vlc_object_t *p_this,                                  char const *psz_var,                                  vlc_value_t oldvar, vlc_value_t newvar,                                  void *data ){    if( !strcmp( psz_var, "item-change" ) )    {        CoverArtLabel *art = static_cast< CoverArtLabel* >( data );        if( art )            art->requestUpdate();    }    return VLC_SUCCESS;}CoverArtLabel::CoverArtLabel( vlc_object_t *_p_this, input_item_t *_p_input )        : p_this( _p_this), p_input( _p_input ), prevArt(){    setContextMenuPolicy( Qt::ActionsContextMenu );    CONNECT( this, updateRequested(), this, doUpdate() );    playlist_t *p_playlist = pl_Yield( p_this );    var_AddCallback( p_playlist, "item-change",                     downloadCoverCallback, this );    pl_Release( p_this );    setMinimumHeight( 128 );    setMinimumWidth( 128 );    setMaximumHeight( 128 );    setMaximumWidth( 128 );    setScaledContents( true );    doUpdate();}void CoverArtLabel::downloadCover(){    if( p_input )    {        playlist_t *p_playlist = pl_Yield( p_this );        playlist_AskForArtEnqueue( p_playlist, p_input );        pl_Release( p_this );    }}void CoverArtLabel::doUpdate(){    if( !p_input )    {        setPixmap( QPixmap( ":/noart.png" ) );        QList< QAction* > artActions = actions();        if( !artActions.isEmpty() )            foreach( QAction *act, artActions )                removeAction( act );        prevArt = "";    }    else    {        char *psz_meta = input_item_GetArtURL( p_input );        if( psz_meta && !strncmp( psz_meta, "file://", 7 ) )        {            QString artUrl = qfu( psz_meta ).replace( "file://", "" );            if( artUrl != prevArt )            {                QPixmap pix;                if( pix.load( artUrl ) )                    setPixmap( pix );                else                {                    msg_Dbg( p_this, "Qt could not load image '%s'",                             qtu( artUrl ) );                    setPixmap( QPixmap( ":/noart.png" ) );                }            }            QList< QAction* > artActions = actions();            if( !artActions.isEmpty() )            {                foreach( QAction *act, artActions )                    removeAction( act );            }            prevArt = artUrl;        }        else        {            if( prevArt != "" )                setPixmap( QPixmap( ":/noart.png" ) );            prevArt = "";            QList< QAction* > artActions = actions();            if( artActions.isEmpty() )            {                QAction *action = new QAction( qtr( "Download cover art" ),                                               this );                addAction( action );                CONNECT( action, triggered(),                         this, downloadCover() );            }        }        free( psz_meta );    }}

⌨️ 快捷键说明

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