intf.cpp

来自「VLC媒体播放程序」· C++ 代码 · 共 510 行 · 第 1/2 页

CPP
510
字号
}/***************************************************************************** * DateDisplay: display date ***************************************************************************** * This function displays the current date in the date label. *****************************************************************************/void IntfWindow::DateDisplay( int i_range ){    if( p_intf->p_sys->p_input )    {        char psz_time[ MSTRTIME_MAX_SIZE ];        vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );        p_date->setText( input_OffsetToTime( p_intf->p_sys->p_input, psz_time,           ( p_intf->p_sys->p_input->stream.p_selected_area->i_size * i_range )               / SLIDER_MAX ) );        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );    }}/***************************************************************************** * FileOpen: open a file ***************************************************************************** * This function opens a file requester and adds the selected file to * the playlist. *****************************************************************************/void IntfWindow::FileOpen( void ){    playlist_t *p_playlist;    QString file = QFileDialog::getOpenFileName( QString::null,                                                 QString::null, this );    if( file.isEmpty() )    {        statusBar()->message( "No file loaded", 2000 );    }    else    {        p_playlist = (playlist_t *)                vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );        if( p_playlist == NULL )        {            return;        }        playlist_Add( p_playlist, file.latin1(), file.latin1(),                      PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );        vlc_object_release( p_playlist );    }}/***************************************************************************** * FileQuit: terminate vlc *****************************************************************************/void IntfWindow::FileQuit( void ){    p_intf->p_vlc->b_die = VLC_TRUE;}/***************************************************************************** * About: display the "about" box ***************************************************************************** * This function displays a simple "about" box with copyright information. *****************************************************************************/void IntfWindow::About( void ){    QMessageBox::about( this, "About",        "VideoLAN Client\n"        "(C) 1996, 1997, 1998, 1999, 2000, 2001, 2002 - the VideoLAN Team\n"        "\n"        "This is the VideoLAN client, a DVD and MPEG player.\n"        "It can play MPEG and MPEG 2 files from a file "            "or from a network source.\n"        "\n"        "More information: http://www.videolan.org/" );}/***************************************************************************** * Manage: manage main thread messages ***************************************************************************** * In this function, called approx. 10 times a second, we check what the * main program wanted to tell us. *****************************************************************************/void IntfWindow::Manage( void ){    /* Update the input */    if( p_intf->p_sys->p_input == NULL )    {        p_intf->p_sys->p_input = (input_thread_t *)                vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );    }    else if( p_intf->p_sys->p_input->b_dead )    {        vlc_object_release( p_intf->p_sys->p_input );        p_intf->p_sys->p_input = NULL;    }    /* Manage the slider */    if( p_intf->p_sys->p_input && p_intf->p_sys->p_input->stream.b_seekable )    {        int i_value = p_slider->value();#define p_area p_intf->p_sys->p_input->stream.p_selected_area        /* If the user hasn't touched the slider since the last time,         * then the input can safely change it */        if( i_value == p_slider->oldvalue() )        {            i_value = ( SLIDER_MAX * p_area->i_tell ) / p_area->i_size;            p_slider->setValue( i_value );            p_slider->setOldValue( i_value );        }        /* Otherwise, send message to the input if the user has         * finished dragging the slider */        else if( p_slider->b_free )        {            off_t i_seek = ( i_value * p_area->i_size ) / SLIDER_MAX;            input_Seek( p_intf->p_sys->p_input, i_seek, INPUT_SEEK_SET );            /* Update the old value */            p_slider->setOldValue( i_value );        }#undef p_area    }    /* If the "display popup" flag has changed, popup the context menu */    if( p_intf->b_menu_change )    {        p_popup->popup( QCursor::pos() );        p_intf->b_menu_change = 0;    }    if( p_intf->b_die )    {        qApp->quit();    }}/***************************************************************************** * PlaybackPlay: play *****************************************************************************/void IntfWindow::PlaybackPlay( void ){    if( p_intf->p_sys->p_input != NULL )    {        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PLAY );    }}/***************************************************************************** * PlaybackPause: pause *****************************************************************************/void IntfWindow::PlaybackPause( void ){    if( p_intf->p_sys->p_input != NULL )    {        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );    }}/***************************************************************************** * PlaybackSlow: slow *****************************************************************************/void IntfWindow::PlaybackSlow( void ){    if( p_intf->p_sys->p_input != NULL )    {        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );    }}/***************************************************************************** * PlaybackFast: fast *****************************************************************************/void IntfWindow::PlaybackFast( void ){    if( p_intf->p_sys->p_input != NULL )    {        input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );    }}/***************************************************************************** * PlaylistPrev: previous playlist entry *****************************************************************************/void IntfWindow::PlaylistPrev( void ){    playlist_t *p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL )    {        return;    }    playlist_Prev( p_playlist );    vlc_object_release( p_playlist );}/***************************************************************************** * PlaylistNext: next playlist entry *****************************************************************************/void IntfWindow::PlaylistNext( void ){    playlist_t *p_playlist = (playlist_t *)        vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL )    {        return;    }    playlist_Next( p_playlist );    vlc_object_release( p_playlist );}/***************************************************************************** * IntfSlider: slider creator ***************************************************************************** * This function creates the slider, sets its default values, and connects * the interesting signals. *****************************************************************************/IntfSlider::IntfSlider( intf_thread_t *p_intf, QWidget *p_parent )           :QSlider( Horizontal, p_parent ){    this->p_intf = p_intf;    setRange( SLIDER_MIN, SLIDER_MAX );    setPageStep( SLIDER_STEP );    setValue( SLIDER_MIN );    setOldValue( SLIDER_MIN );    setTracking( TRUE );    b_free = TRUE;    connect( this, SIGNAL(sliderMoved(int)), this, SLOT(SlideStart()) );    connect( this, SIGNAL(sliderPressed()), this, SLOT(SlideStart()) );    connect( this, SIGNAL(sliderReleased()), this, SLOT(SlideStop()) );}/***************************************************************************** * ~IntfSlider: slider destructor ***************************************************************************** * This function is called when the interface slider is destroyed. *****************************************************************************/IntfSlider::~IntfSlider( void ){    /* We don't need to remove anything */}

⌨️ 快捷键说明

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