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

📄 intf.cpp

📁 video linux conference
💻 CPP
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * intf.cpp: Qt interface ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN * $Id: intf.cpp 10101 2005-03-02 16:47:31Z robux4 $ * * Authors: Samuel Hocevar <sam@zoy.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. *  * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <errno.h>                                                 /* ENOMEM */#include <stdlib.h>                                                /* free() */#include <string.h>                                            /* strerror() */#include <stdio.h>#include "intf.h"#define SLIDER_MIN    0x00000#define SLIDER_MAX    0x10000#define SLIDER_STEP   (SLIDER_MAX >> 4)/***************************************************************************** * intf_sys_t: description and status of Qt interface *****************************************************************************/struct intf_sys_t{    QApplication *p_app;    IntfWindow   *p_window;    input_thread_t *p_input;};/***************************************************************************** * Local prototype *****************************************************************************/static void Run ( intf_thread_t *p_intf );/***************************************************************************** * Open: initialize and create window *****************************************************************************/int E_(Open) ( vlc_object_t *p_this ){    intf_thread_t *p_intf = (intf_thread_t*) p_this;    char *pp_argv[] = { "" };    int   i_argc    = 1;    /* Allocate instance and initialize some members */    p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );    if( p_intf->p_sys == NULL )    {        msg_Err( p_intf, "out of memory" );        return 1;    }    p_intf->pf_run = Run;    /* Create the C++ objects */    p_intf->p_sys->p_app = new QApplication( i_argc, pp_argv );    p_intf->p_sys->p_window = new IntfWindow( p_intf );    /* Tell the world we are here */    p_intf->p_sys->p_window->setCaption( VOUT_TITLE " (Qt interface)" );    p_intf->p_sys->p_input = NULL;    return 0;}/***************************************************************************** * Close: destroy interface window *****************************************************************************/void E_(Close) ( vlc_object_t *p_this ){    intf_thread_t *p_intf = (intf_thread_t*) p_this;    if( p_intf->p_sys->p_input )    {        vlc_object_release( p_intf->p_sys->p_input );    }    /* Get rid of the C++ objects */    delete p_intf->p_sys->p_window;    delete p_intf->p_sys->p_app;    /* Destroy structure */    free( p_intf->p_sys );}/***************************************************************************** * Run: Qt thread ***************************************************************************** * This part of the interface is in a separate thread so that we can call * exec() from within it without annoying the rest of the program. *****************************************************************************/static void Run( intf_thread_t *p_intf ){    p_intf->p_sys->p_window->show();    p_intf->p_sys->p_app->exec();}/* following functions are local *//***************************************************************************** * IntfWindow: interface window creator ***************************************************************************** * This function creates the interface window, and populates it with a * menu bar, a toolbar and a slider. *****************************************************************************/IntfWindow::IntfWindow( intf_thread_t *p_intf )           :QMainWindow( 0 ){    setUsesTextLabel( TRUE );    this->p_intf = p_intf;    /*     * Create the toolbar     */    p_toolbar = new QToolBar( this, "toolbar" );    p_toolbar->setHorizontalStretchable( TRUE );    QIconSet * set = new QIconSet();    QPixmap pixmap = set->pixmap( QIconSet::Automatic, QIconSet::Normal );#define addbut( l, t, s ) new QToolButton( pixmap, l, t, this, s, p_toolbar );    addbut( "Open", "Open a File", SLOT(FileOpen()) );    addbut( "Disc", "Open a DVD or VCD", SLOT(Unimplemented()) );    addbut( "Net", "Select a Network Stream", SLOT(Unimplemented()) );    p_toolbar->addSeparator();    addbut( "Back", "Rewind Stream", SLOT(Unimplemented()) );    addbut( "Stop", "Stop Stream", SLOT(Unimplemented()) );    addbut( "Play", "Play Stream", SLOT(PlaybackPlay()) );    addbut( "Pause", "Pause Stream", SLOT(PlaybackPause()) );    addbut( "Slow", "Play Slower", SLOT(PlaybackSlow()) );    addbut( "Fast", "Play Faster", SLOT(PlaybackFast()) );    p_toolbar->addSeparator();    addbut( "Playlist", "Open Playlist", SLOT(Unimplemented()) );    addbut( "Prev", "Previous File", SLOT(PlaylistPrev()) );    addbut( "Next", "Next File", SLOT(PlaylistNext()) );#undef addbut    /*      * Create the menubar     */    QPopupMenu * p_tmpmenu = new QPopupMenu( this );#define instmp0( x, y )    p_tmpmenu->insertItem( x, this, y )#define instmp1( x, y, a ) p_tmpmenu->insertItem( x, this, y, a )    menuBar()->insertItem( "&File", p_tmpmenu );    instmp1( "&Open File...", SLOT(FileOpen()), Key_F3 );    instmp1( "Open &Disc...", SLOT(Unimplemented()), Key_F4 );    instmp1( "&Network Stream...", SLOT(Unimplemented()), Key_F5 );    p_tmpmenu->insertSeparator();    instmp1( "&Exit", SLOT(FileQuit()), CTRL+Key_Q );    p_tmpmenu = new QPopupMenu( this );    menuBar()->insertItem( "&View", p_tmpmenu );    instmp0( "&Playlist...", SLOT(Unimplemented()) );    instmp0( "&Modules...", SLOT(Unimplemented()) );    p_tmpmenu = new QPopupMenu( this );    menuBar()->insertItem( "&Settings", p_tmpmenu );    instmp0( "&Preferences...", SLOT(Unimplemented()) );    p_tmpmenu = new QPopupMenu( this );    menuBar()->insertItem( "&Help", p_tmpmenu );    instmp0( "&About...", SLOT(About()) );    /*     * Create the popup menu     */    p_popup = new QPopupMenu( /* floating menu */ );#define inspop0( x, y )    p_popup->insertItem( x, this, y )#define inspop1( x, y, a ) p_popup->insertItem( x, this, y, a )    inspop0( "&Play", SLOT(PlaybackPlay()) );    inspop0( "Pause", SLOT(PlaybackPause()) );    inspop0( "&Slow", SLOT(PlaybackSlow()) );    inspop0( "&Fast", SLOT(PlaybackFast()) );    p_popup->insertSeparator();    inspop1( "&Open File...", SLOT(FileOpen()), Key_F3 );    inspop1( "Open &Disc...", SLOT(Unimplemented()), Key_F4 );    inspop1( "&Network Stream...", SLOT(Unimplemented()), Key_F5 );    p_popup->insertSeparator();    inspop0( "&About...", SLOT(About()) );    inspop0( "&Exit", SLOT(FileQuit()) );    /* Activate the statusbar */    statusBar();    /* Add the vertical box */    QVBox * p_vbox = new QVBox( this );    setCentralWidget( p_vbox );        /* The horizontal box */        QHBox * p_hbox = new QHBox( p_vbox );            /* The date label */            p_date  = new QLabel( p_hbox );            p_date->setAlignment( AlignHCenter | AlignVCenter );            p_date->setText( "-:--:--" );            /* The status label */            QLabel *p_label  = new QLabel( p_hbox );            p_label->setAlignment( AlignHCenter | AlignVCenter );            p_label->setText( "Status: foo" );            /* The bar label */            p_label  = new QLabel( p_hbox );            p_label->setAlignment( AlignHCenter | AlignVCenter );            p_label->setText( "Bar: baz quux" );        /* Create the slider and connect it to the date label */        p_slider = new IntfSlider( p_intf, p_vbox );        connect( p_slider, SIGNAL(valueChanged(int)),                 this, SLOT(DateDisplay(int)) );    /* The timer */    QTimer *p_timer = new QTimer( this );    connect( p_timer, SIGNAL(timeout()), this, SLOT(Manage()) );    p_timer->start( INTF_IDLE_SLEEP / 1000 );    /* Everything worked fine */    resize( 620, 30 );}/***************************************************************************** * ~IntfWindow: interface window destructor ***************************************************************************** * This function is called when the interface window is destroyed. *****************************************************************************/IntfWindow::~IntfWindow( void ){    /* FIXME: remove everything cleanly */

⌨️ 快捷键说明

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