📄 interface.cpp
字号:
/*************************************************************************** interface.cpp - description ------------------- begin : Sun Mar 25 2001 copyright : (C) 2001 by andres email : dae@chez.com ***************************************************************************/#include "disc.h"#include "info.h"#include "interface.h"#include "net.h"#include "menu.h"#include "slider.h"#include "preferences.h"#include "languagemenu.h"#include <iostream>#include <kaction.h>#include <kfiledialog.h>#include <klocale.h>#include <kstdaction.h>#include <kurl.h>#include <kurldrag.h>#include <qcursor.h>#include <qdragobject.h>#include <qtimer.h>#include <kdialog.h>#include <kstatusbar.h>#define ID_STATUS_MSG 1#define ID_DATE 2#define ID_STREAM_SOURCE 3KInterface::KInterface( intf_thread_t *p_intf, QWidget *parent, const char *name ) : KMainWindow(parent,name){ setAcceptDrops(true); this->p_intf = p_intf; p_messagesWindow = new KMessagesWindow( p_intf, p_intf->p_sys->p_msg ); fDiskDialog = new KDiskDialog( this ); fNetDialog = new KNetDialog( this ); fTitleMenu = new KTitleMenu( p_intf, this ); fSlider = new KVLCSlider( QSlider::Horizontal, this ); fSlider->setMaxValue(10000); connect( fSlider, SIGNAL( userChanged( int ) ), this, SLOT( slotSliderMoved( int ) ) ); connect( fSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) ); connect( fSlider, SIGNAL( sliderMoved( int ) ), this, SLOT( slotSliderChanged( int ) ) ); setCentralWidget(fSlider); fTimer = new QTimer( this ); connect( fTimer, SIGNAL( timeout() ), this, SLOT( slotManage() ) ); resize( 400, 30 ); /////////////////////////////////////////////////////////////////// // call inits to invoke all other construction parts // XXX could we move this up ? initStatusBar(); initActions(); // add certain calls to the popup menu fileOpen->plug( fTitleMenu ); fileOpenRecent->plug( fTitleMenu ); diskOpen->plug( fTitleMenu ); streamOpen->plug( fTitleMenu ); play->plug( fTitleMenu ); pause->plug( fTitleMenu ); slow->plug( fTitleMenu ); fast->plug( fTitleMenu ); fileQuit->plug( fTitleMenu ); fTimer->start( 0, FALSE );}KInterface::~KInterface(){ ;}void KInterface::initActions(){ languages = new KActionMenu( _( "Languages" ), actionCollection(), _("language") ); languages->setEnabled( false ); languageCollection = new KActionCollection( this ); subtitleCollection = new KActionCollection( this ); subtitles = new KActionMenu( _( "Subtitles" ), actionCollection(), "subtitles" ); subtitles->setEnabled( false ); fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection()); fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection()); preferences = KStdAction::preferences(this, SLOT(slotShowPreferences()), actionCollection()); fileQuit = KStdAction::quit(this, SLOT(slotFileQuit()), actionCollection()); viewToolBar = KStdAction::showToolbar(this, SLOT(slotViewToolBar()), actionCollection()); viewStatusBar = KStdAction::showStatusbar(this, SLOT(slotViewStatusBar()), actionCollection()); diskOpen = new KAction( i18n( _("Open &Disk") ), 0, 0, this, SLOT( slotOpenDisk() ), actionCollection(), "open_disk" ); streamOpen = new KAction( i18n( _("Open &Stream") ), 0, 0, this, SLOT( slotOpenStream() ), actionCollection(), "open_stream" ); backward = new KAction( i18n( _("&Backward") ), 0, 0, this, SLOT( slotBackward() ), actionCollection(), "backward" ); stop = new KAction( i18n( _("&Stop") ), 0, 0, this, SLOT( slotStop() ), actionCollection(), "stop" ); play = new KAction( i18n( _("&Play") ), 0, 0, this, SLOT( slotPlay() ), actionCollection(), "play" ); pause = new KAction( i18n( _("P&ause") ), 0, 0, this, SLOT( slotPause() ), actionCollection(), "pause" ); slow = new KAction( i18n( _("&Slow") ), 0, 0, this, SLOT( slotSlow() ), actionCollection(), "slow" ); fast = new KAction( i18n( _("Fas&t") ), 0, 0, this, SLOT( slotFast() ), actionCollection(), "fast" ); prev = new KAction( i18n( _("Prev") ), 0, 0, this, SLOT( slotPrev() ), actionCollection(), "prev" ); next = new KAction( i18n( _("Next") ), 0, 0, this, SLOT( slotNext() ), actionCollection(), "next" ); messages = new KAction( _( "Messages..." ), 0, 0, this, SLOT( slotShowMessages() ), actionCollection(), "view_messages"); info = new KAction( _( "Stream info..." ), 0, 0, this, SLOT( slotShowInfo() ), actionCollection(), "view_stream_info"); info->setEnabled( false ); program = new KActionMenu( _( "Program" ), actionCollection(), "program" ); program->setEnabled( false ); title = new KActionMenu( _( "Title" ), actionCollection(), "title" ); title->setEnabled( false ); chapter = new KActionMenu( _( "Chapter" ), actionCollection(), "chapter" ); chapter->setEnabled( false ); fileOpen->setStatusText(i18n(_("Opens an existing document"))); fileOpenRecent->setStatusText(i18n(_("Opens a recently used file"))); fileQuit->setStatusText(i18n(_("Quits the application"))); viewToolBar->setStatusText(i18n(_("Enables/disables the toolbar"))); viewStatusBar->setStatusText(i18n(_("Enables/disables the status bar"))); diskOpen->setStatusText( i18n( _("Opens a disk") ) ); streamOpen->setStatusText( i18n( _("Opens a network stream") ) ); backward->setStatusText( i18n( _("Backward") ) ); stop->setStatusText( i18n( _("Stops playback") ) ); play->setStatusText( i18n( _("Starts playback") ) ); pause->setStatusText( i18n( _("Pauses playback") ) ); slow->setStatusText( i18n( _("Slow") ) ); fast->setStatusText( i18n( _("Fast") ) ); prev->setStatusText( i18n( _("Prev") ) ); next->setStatusText( i18n( _("Next") ) ); // use the absolute path to your ktestui.rc file for testing purpose in createGUI(); char *psz_uifile = config_GetPsz( p_intf, "kde-uirc" ); createGUI( psz_uifile );// createGUI( "./modules/gui/kde/ui.rc" );}void KInterface::initStatusBar(){ /////////////////////////////////////////////////////////////////// // STATUSBAR // TODO: add your own items you need for displaying current application status. statusBar()->insertItem(i18n(_("Ready.")), ID_STATUS_MSG, 1, false); statusBar()->setItemAlignment( ID_STATUS_MSG, AlignLeft | AlignVCenter ); statusBar()->insertItem( "0:00:00", ID_DATE, 0, true );}/////////////////////////////////////////////////////////////////////// SLOT IMPLEMENTATION/////////////////////////////////////////////////////////////////////void KInterface::slotShowMessages(){ p_messagesWindow->show();}void KInterface::slotShowInfo(){ if ( p_intf->p_sys->p_input ) { new KInfoWindow(p_intf, p_intf->p_sys->p_input); }}void KInterface::slotFileOpen(){ playlist_t *p_playlist; slotStatusMsg( i18n( _("Opening file...") ) ); KURL url=KFileDialog::getOpenURL( QString::null, i18n( "*|All files" ), this, i18n( _("Open File...") ) ); if( !url.isEmpty() ) { p_playlist = (playlist_t *) vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); if( p_playlist ) { fileOpenRecent->addURL( url ); playlist_Add( p_playlist, url.path(), url.path(), PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END ); vlc_object_release( p_playlist ); } } slotStatusMsg( i18n( _("Ready.") ) );}void KInterface::slotFileOpenRecent(const KURL& url){ slotStatusMsg(i18n(_("Opening file..."))); slotStatusMsg(i18n(_("Ready.")));}void KInterface::slotFileQuit(){ slotStatusMsg(i18n(_("Exiting..."))); p_intf->p_vlc->b_die = VLC_TRUE; slotStatusMsg(i18n(_("Ready.")));}void KInterface::slotViewToolBar(){ slotStatusMsg(i18n(_("Toggling toolbar..."))); /////////////////////////////////////////////////////////////////// // turn Toolbar on or off if(!viewToolBar->isChecked()) { toolBar("mainToolBar")->hide(); } else { toolBar("mainToolBar")->show(); } slotStatusMsg(i18n(_("Ready.")));}void KInterface::slotViewStatusBar(){ slotStatusMsg(i18n(_("Toggle the status bar..."))); /////////////////////////////////////////////////////////////////// //turn Statusbar on or off if(!viewStatusBar->isChecked()) { statusBar()->hide(); } else { statusBar()->show(); } slotStatusMsg(i18n(_("Ready.")));}void KInterface::slotShowPreferences(){ // Do something KPreferences(this->p_intf, "main", this, "preferences");}void KInterface::slotStatusMsg(const QString &text){ /////////////////////////////////////////////////////////////////// // change status message permanently statusBar()->clear(); statusBar()->changeItem(text, ID_STATUS_MSG);}void KInterface::slotManage(){ p_messagesWindow->update();// p_intf->p_sys->p_app->processEvents(); vlc_mutex_lock( &p_intf->change_lock ); /* 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 ); if ( p_intf->p_sys->p_input ) { languages->setEnabled( true ); subtitles->setEnabled( true ); info->setEnabled( true ); } } 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; languages->setEnabled( false ); subtitles->setEnabled( false ); info->setEnabled( false ); } /* If the "display popup" flag has changed */ if( p_intf->b_menu_change ) { fTitleMenu->popup( ( QCursor::pos() ) ); p_intf->b_menu_change = 0; } if( p_intf->p_sys->p_input ) { input_thread_t *p_input = p_intf->p_sys->p_input; vlc_mutex_lock( &p_input->stream.stream_lock ); if( !p_input->b_die ) { /* New input or stream map change */ if( p_input->stream.b_changed ) { // E_(GtkModeManage)( p_intf ); //GtkSetupMenus( p_intf ); slotUpdateLanguages(); p_intf->p_sys->b_playing = 1; p_input->stream.b_changed = 0; } /* Manage the slider. fSlider->setValue triggers * slotSliderChanged which needs to grab the stream lock*/#define p_area p_input->stream.p_selected_area if( p_area->i_size ) { vlc_mutex_unlock( &p_input->stream.stream_lock );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -