Commit 92df268e authored by Andres Krapf's avatar Andres Krapf

initial import - still buggy, crashes on exit, etc.

the playlist and the popup are unimplemented.
parent d072e40d
###############################################################################
# vlc (VideoLAN Client) kde module Makefile
# (c)2001 VideoLAN
###############################################################################
#
# Objects
#
PLUGIN_KDE = kde.o \
kdeinterface.o \
kinterfacemain.o \
kvlcslider.o \
kdiskdialog.o \
knetdialog.o \
ktitlemenu.o
PLUGIN_KDE_MOC = kinterfacemain.moc.o \
kvlcslider.moc.o \
kdiskdialog.moc.o \
knetdialog.moc.o \
ktitlemenu.moc.o
#BUILTIN_KDE = $(PLUGIN_KDE:%.o=BUILTIN_%.o)
#BUILTIN_KDE_MOC = $(PLUGIN_KDE_MOC:%.o=BUILTIN_%.o)
ALL_OBJ = $(PLUGIN_KDE) $(PLUGIN_KDE_MOC) $(BUILTIN_KDE) $(BUILTIN_KDE_MOC)
#
# Virtual targets
#
include ../../Makefile.modules
$(PLUGIN_KDE): %.o: .dep/%.dpp
$(PLUGIN_KDE): %.o: %.cpp
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
$(PLUGIN_KDE_MOC): %.o: .dep/%.dpp
$(PLUGIN_KDE_MOC): %.o: %.cpp
$(CC) $(CFLAGS) $(PCFLAGS) -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
$(PLUGIN_KDE_MOC:%.moc.o=%.moc.cpp): %.moc.cpp: %.h
moc $< -o $@
#$(BUILTIN_KDE): BUILTIN_%.o: .dep/%.dpp
#$(BUILTIN_KDE): BUILTIN_%.o: %.cpp
# $(CC) $(CFLAGS) -DBUILTIN -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
#$(BUILTIN_KDE_MOC): BUILTIN_%.o: dep/%.dpp
#$(BUILTIN_KDE_MOC): BUILTIN_%.o: %.cpp
# $(CC) $(CFLAGS) -DBUILTIN -I/usr/include/kde -I/usr/include/qt -c -o $@ $<
#$(BUILTIN_KDE_MOC: %.moc.o=%.cpp): %.moc.cpp: %.h
# $(MOC) $< -o $@
#
# Real targets
#
../../lib/kde.so: $(PLUGIN_KDE) $(PLUGIN_KDE_MOC)
$(CC) $(PCFLAGS) -o $@ $^ $(PLCFLAGS) $(LIB_KDE) -lkfile
#../../lib/kde.a: $(BUILTIN_KDE)
# ar r $@ $^
# $(RANLIB) $@
/***************************************************************************
intf_plugin.h - description
-------------------
begin : Mon Apr 9 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _INTF_PLUGIN_H_
#define _INTF_PLUGIN_H_
extern "C"
{
#include "modules_inner.h"
#include "defs.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "tests.h"
#include "modules.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "intf_msg.h"
#include "intf_playlist.h"
#include "interface.h"
#include "main.h"
}
#endif /* _INTF_PLUGIN_H_ */
\ No newline at end of file
/***************************************************************************
kde.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#define MODULE_NAME kde
#include "intf_plugin.h"
extern "C"
{
/*****************************************************************************
* Build configuration tree.
*****************************************************************************/
MODULE_CONFIG_START
ADD_WINDOW( "Configuration for KDE module" )
ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
MODULE_CONFIG_END
/*****************************************************************************
* Capabilities defined in the other files.
*****************************************************************************/
void _M( intf_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
* InitModule: get the module structure and configuration.
*****************************************************************************
* We have to fill psz_name, psz_longname and psz_version. These variables
* will be strdup()ed later by the main application because the module can
* be unloaded later to save memory, and we want to be able to access this
* data even after the module has been unloaded.
*****************************************************************************/
MODULE_INIT
{
p_module->psz_name = MODULE_STRING;
p_module->psz_longname = "KDE interface module";
p_module->psz_version = VERSION;
p_module->i_capabilities = MODULE_CAPABILITY_NULL
| MODULE_CAPABILITY_INTF;
return( 0 );
}
/*****************************************************************************
* ActivateModule: set the module to an usable state.
*****************************************************************************
* This function fills the capability functions and the configuration
* structure. Once ActivateModule() has been called, the i_usage can
* be set to 0 and calls to NeedModule() be made to increment it. To unload
* the module, one has to wait until i_usage == 0 and call DeactivateModule().
*****************************************************************************/
MODULE_ACTIVATE
{
p_module->p_functions =
( module_functions_t * )malloc( sizeof( module_functions_t ) );
if( p_module->p_functions == NULL )
{
return( -1 );
}
_M( intf_getfunctions )( &p_module->p_functions->intf );
p_module->p_config = p_config;
return( 0 );
}
/*****************************************************************************
* DeactivateModule: make sure the module can be unloaded.
*****************************************************************************
* This function must only be called when i_usage == 0. If it successfully
* returns, i_usage can be set to -1 and the module unloaded. Be careful to
* lock usage_lock during the whole process.
*****************************************************************************/
MODULE_DEACTIVATE
{
free( p_module->p_functions );
return( 0 );
}
} /* extern "C" */
/***************************************************************************
kdeinterface.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#define MODULE_NAME kde
#include "intf_plugin.h"
#include "kdeinterface.h"
#include "kinterfacemain.h"
#include <iostream>
#include <kaction.h>
#include <kapp.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kmainwindow.h>
#include <kstdaction.h>
#include <qwidget.h>
/*****************************************************************************
* Functions exported as capabilities.
*****************************************************************************/
extern "C"
{
void _M( intf_getfunctions )( function_list_t * p_function_list )
{
p_function_list->pf_probe = KDEInterface::probe;
p_function_list->functions.intf.pf_open = KDEInterface::open;
p_function_list->functions.intf.pf_close = KDEInterface::close;
p_function_list->functions.intf.pf_run = KDEInterface::run;
}
}
/*****************************************************************************
* KDEInterface::KDEInterface: KDE interface constructor
*****************************************************************************/
KDEInterface::KDEInterface(intf_thread_t *p_intf)
{
fAboutData = new KAboutData("VideoLAN Client", I18N_NOOP("Kvlc"),
VERSION,
"This is the VideoLAN client, a DVD and MPEG player. It can play MPEG and MPEG 2 files from a file or from a network source.", KAboutData::License_GPL,
"(C) 1996, 1997, 1998, 1999, 2000, 2001 - the VideoLAN Team", 0, 0, "dae@chez.com");
char *authors[][2] = {
{ "Rgis Duchesne", "<regis@via.ecp.fr>" },
{ "Michel Lespinasse", "<walken@zoy.org>" },
{ "Olivier Pomel", "<pomel@via.ecp.fr>" },
{ "Pierre Baillet", "<oct@zoy.org>" },
{ "Jean-Philippe Grimaldi", "<jeanphi@via.ecp.fr>" },
{ "Andres Krapf", "<dae@via.ecp.fr>" },
{ "Christophe Massiot", "<massiot@via.ecp.fr>" },
{ "Vincent Seguin", "<seguin@via.ecp.fr>" },
{ "Benoit Steiner", "<benny@via.ecp.fr>" },
{ "Arnaud de Bossoreille de Ribou", "<bozo@via.ecp.fr>" },
{ "Jean-Marc Dressler", "<polux@via.ecp.fr>" },
{ "Gal Hendryckx", "<jimmy@via.ecp.fr>" },
{ "Samuel Hocevar","<sam@zoy.org>" },
{ "Brieuc Jeunhomme", "<bbp@via.ecp.fr>" },
{ "Michel Kaempf", "<maxx@via.ecp.fr>" },
{ "Stphane Borel", "<stef@via.ecp.fr>" },
{ "Renaud Dartus", "<reno@via.ecp.fr>" },
{ "Henri Fallon", "<henri@via.ecp.fr>" },
{ NULL, NULL },
};
for ( int i = 0; NULL != authors[i][0]; i++ ) {
fAboutData->addAuthor( authors[i][0], 0, authors[i][1] );
}
int argc = 1;
char *argv[] = { "" };
KCmdLineArgs::init( argc, argv, fAboutData );
fApplication = new KApplication();
fWindow = new KInterfaceMain(p_intf);
fWindow->setCaption( VOUT_TITLE " (KDE interface)" );
}
/*****************************************************************************
* KDEInterface::~KDEInterface: KDE interface destructor
*****************************************************************************/
KDEInterface::~KDEInterface()
{
cerr << "entering ~KDEInterface()\n";
// delete ( fApplication );
cerr << "leaving ~KDEInterface()\n";
}
/*****************************************************************************
* KDEInterface::probe: probe the interface and return a score
*****************************************************************************
* This function tries to initialize KDE and returns a score to the
* plugin manager so that it can select the best plugin.
*****************************************************************************/
int KDEInterface::probe(probedata_t *p_data )
{
if ( TestMethod( INTF_METHOD_VAR, "kde" ) )
{
return ( 999 );
}
if ( TestProgram( "kvlc" ) )
{
return ( 180 );
}
return ( 80 );
}
/*****************************************************************************
* KDEInterface::open: initialize and create window
*****************************************************************************/
int KDEInterface::open(intf_thread_t *p_intf)
{
p_intf->p_sys = (intf_sys_s*) new KDEInterface(p_intf); // XXX static_cast ?
return ( 0 );
}
/*****************************************************************************
* KDEInterface::close: destroy interface window
*****************************************************************************/
void KDEInterface::close(intf_thread_t *p_intf)
{
// delete ( ( KDEInterface* ) p_intf->p_sys );
}
/*****************************************************************************
* KDEInterface::run: KDE 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.
*****************************************************************************/
void KDEInterface::run(intf_thread_t *p_intf)
{
// XXX static_cast ?
KDEInterface *kdeInterface = (KDEInterface*) p_intf->p_sys;
kdeInterface->fWindow->show();
kdeInterface->fApplication->exec();
}
/***************************************************************************
kdeinterface.h - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _KDEINTERFACE_H_
#define _KDEINTERFACE_H_
class KApplication;
class KInterfaceMain;
class KAboutData;
class KDEInterface
{
private:
KDEInterface ( KDEInterface &kdeInterface ) {};
KDEInterface &operator= ( KDEInterface &kdeInterface ) { return ( *this ); };
public:
KDEInterface(intf_thread_t *p_intf);
~KDEInterface();
// These methods get exported to the core
static int probe ( probedata_t *p_data );
static int open ( intf_thread_t *p_intf );
static void close ( intf_thread_t *p_intf );
static void run ( intf_thread_t *p_intf );
private:
KApplication *fApplication;
KInterfaceMain *fWindow;
KAboutData *fAboutData;
};
#endif /* _KDEINTERFACE_H_ */
/***************************************************************************
kdiskdialog.cpp - description
-------------------
begin : Sat Apr 7 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "kdiskdialog.h"
#include <qhbox.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qstring.h>
#include <qvbox.h>
#include <qvbuttongroup.h>
#include <qvgroupbox.h>
#include <qwidget.h>
#include <kdialogbase.h>
#include <klineedit.h>
KDiskDialog::KDiskDialog( QWidget *parent, const char *name ) :
KDialogBase( parent, name, true, QString::null, Ok|Cancel, Ok, true )
{
QVBox *pageVBox = makeVBoxMainWidget();
QHBox *deviceSelectHBox = new QHBox( pageVBox );
deviceSelectHBox->setSpacing( 5 );
fButtonGroup = new QVButtonGroup( "Disk type", deviceSelectHBox );
fDVDButton = new QRadioButton( "DVD", fButtonGroup);
fDVDButton->setChecked( true );
fVCDButton = new QRadioButton( "VCD", fButtonGroup);
fVCDButton->setEnabled( false );
QVGroupBox *startVBox = new QVGroupBox( "Starting position", deviceSelectHBox );
QHBox *titleHBox = new QHBox( startVBox );
QLabel *titleLabel = new QLabel( "Title ", titleHBox );
fTitle = new QSpinBox( titleHBox );
QHBox *chapterHBox = new QHBox( startVBox );
QLabel *chapterLabel = new QLabel( "Chapter ", chapterHBox );
fChapter = new QSpinBox( chapterHBox );
QHBox *deviceNameHBox = new QHBox( pageVBox );
QLabel *deviceNameLabel = new QLabel( "Device name ", deviceNameHBox );
fLineEdit = new KLineEdit( "/dev/dvd", deviceNameHBox );
}
KDiskDialog::~KDiskDialog()
{
}
QString KDiskDialog::type() const
{
if ( fDVDButton->isChecked() )
{
return ( QString("dvd") );
}
else
{
return ( QString("vcd") );
}
}
QString KDiskDialog::device() const
{
return ( fLineEdit->text() );
}
int KDiskDialog::title() const
{
return ( fTitle->value() );
}
int KDiskDialog::chapter() const
{
return ( fChapter->value() );
}
\ No newline at end of file
/***************************************************************************
kdiskdialog.h - description
-------------------
begin : Sat Apr 7 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef KDISKDIALOG_H
#define KDISKDIALOG_H
#include <kdialogbase.h>
#include <qstring.h>
class QVButtonGroup;
class QRadioButton;
class QSpinBox;
class KLineEdit;
/**
*@author andres
*/
class KDiskDialog : public KDialogBase {
Q_OBJECT
public:
KDiskDialog( QWidget *parent=0, const char *name=0 );
~KDiskDialog();
QString type() const;
QString device() const;
int title() const;
int chapter() const;
private:
QVButtonGroup *fButtonGroup;
QRadioButton *fDVDButton;
QRadioButton *fVCDButton;
QSpinBox *fTitle;
QSpinBox *fChapter;
KLineEdit *fLineEdit;
};
#endif
/***************************************************************************
kinterfacemain.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "kdiskdialog.h"
#include "kinterfacemain.h"
#include "knetdialog.h"
#include "ktitlemenu.h"
#include "kvlcslider.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>
#define ID_STATUS_MSG 1
#define ID_DATE 2
#define ID_STREAM_SOURCE 3
KInterfaceMain::KInterfaceMain( intf_thread_t *p_intf, QWidget *parent,
const char *name ) : KMainWindow(parent,name)
{
setAcceptDrops(true);
fInterfaceThread = p_intf;
fDiskDialog = new KDiskDialog( this );
fNetDialog = new KNetDialog( this );
fTitleMenu = new KTitleMenu( fInterfaceThread, this );
fSlider = new KVLCSlider( QSlider::Horizontal, this );
connect( fSlider, SIGNAL( userChanged( int ) ), this, SLOT( slotSliderMoved( int ) ) );
connect( fSlider, SIGNAL( valueChanged( int ) ), this, SLOT( slotSliderChanged( int ) ) );
setCentralWidget(fSlider);
fTimer = new QTimer( this );
connect( fTimer, SIGNAL( timeout() ), this, SLOT( slotManage() ) );
fTimer->start( 100 );
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 );
fileClose->plug( fTitleMenu );
fileQuit->plug( fTitleMenu );
}
KInterfaceMain::~KInterfaceMain()
{
}
void KInterfaceMain::initActions()
{
fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection());
fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection());
fileClose = KStdAction::close(this, SLOT(slotFileClose()), 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" );
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" );
stop = new KAction( i18n( "&Stop" ), 0, 0, this, SLOT( slotStop() ), actionCollection(), "stop" );
backward = new KAction( i18n( "&Backward" ), 0, 0, this, SLOT( slotBackward() ), actionCollection(), "backward" );
forward = new KAction( i18n( "&Forward" ), 0, 0, this, SLOT( slotForward() ), actionCollection(), "forward" );
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" );
fileOpen->setStatusText(i18n("Opens an existing document"));
fileOpenRecent->setStatusText(i18n("Opens a recently used file"));
fileClose->setStatusText(i18n("Closes the actual document"));
fileQuit->setStatusText(i18n("Quits the application"));
viewToolBar->setStatusText(i18n("Enables/disables the toolbar"));
viewStatusBar->setStatusText(i18n("Enables/disables the statusbar"));
diskOpen->setStatusText( i18n( "Opens a disk") );
streamOpen->setStatusText( i18n( "Opens a network stream" ) );
play->setStatusText( i18n( "Starts playback" ) );
pause->setStatusText( i18n( "Pauses playback" ) );
stop->setStatusText( i18n( "Stops playback" ) );
backward->setStatusText( i18n( "Backward" ) );
forward->setStatusText( i18n( "Forward" ) );
slow->setStatusText( i18n( "Slow" ) );
fast->setStatusText( i18n( "Fast" ) );
// use the absolute path to your ktestui.rc file for testing purpose in createGUI();
createGUI("plugins/kde/kvlcui.rc");
}
void KInterfaceMain::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 KInterfaceMain::slotFileOpen()
{
slotStatusMsg( i18n( "Opening file..." ) );
KURL url=KFileDialog::getOpenURL( QString::null,
i18n( "*|All files" ), this, i18n( "Open File..." ) );
if( !url.isEmpty() )
{
fileOpenRecent->addURL( url );
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, url.path() );
}
slotStatusMsg( i18n( "Ready." ) );
}
void KInterfaceMain::slotFileOpenRecent(const KURL& url)
{
slotStatusMsg(i18n("Opening file..."));
slotStatusMsg(i18n("Ready."));
}
void KInterfaceMain::slotFileClose()
{
slotStatusMsg(i18n("Closing file..."));
close();
slotStatusMsg(i18n("Ready."));
}
void KInterfaceMain::slotFileQuit()
{
slotStatusMsg(i18n("Exiting..."));
slotStatusMsg(i18n("Ready."));
}
void KInterfaceMain::slotViewToolBar()
{
slotStatusMsg(i18n("Toggling toolbar..."));
///////////////////////////////////////////////////////////////////
// turn Toolbar on or off
if(!viewToolBar->isChecked())
{
toolBar("mainToolBar")->hide();
}
else
{
toolBar("mainToolBar")->show();
}
slotStatusMsg(i18n("Ready."));
}
void KInterfaceMain::slotViewStatusBar()
{
slotStatusMsg(i18n("Toggle the statusbar..."));
///////////////////////////////////////////////////////////////////
//turn Statusbar on or off
if(!viewStatusBar->isChecked())
{
statusBar()->hide();
}
else
{
statusBar()->show();
}
slotStatusMsg(i18n("Ready."));
}
void KInterfaceMain::slotStatusMsg(const QString &text)
{
///////////////////////////////////////////////////////////////////
// change status message permanently
statusBar()->clear();
statusBar()->changeItem(text, ID_STATUS_MSG);
}
void KInterfaceMain::slotManage()
{
vlc_mutex_lock( &fInterfaceThread->change_lock );
/* If the "display popup" flag has changed */
if( fInterfaceThread->b_menu_change )
{
fTitleMenu->popup( ( QCursor::pos() ) );
fInterfaceThread->b_menu_change = 0;
}
/* Update language/chapter menus after user request */
// if( fInterface->p_input != NULL && p_intf->p_sys->p_window != NULL &&
// p_intf->p_sys->b_menus_update )
// {
//// GnomeSetupMenu( p_intf );
// }
/* Manage the slider */
if( fInterfaceThread->p_input != NULL )
{
#define p_area fInterfaceThread->p_input->stream.p_selected_area
fSlider->setValue( ( 100 * p_area->i_tell ) / p_area->i_size );
#undef p_area
}
/* Manage core vlc functions through the callback */
fInterfaceThread->pf_manage(fInterfaceThread);
if( fInterfaceThread->b_die )
{
cerr << "we shoud die\n";
}
vlc_mutex_unlock( &fInterfaceThread->change_lock );
}
void KInterfaceMain::slotSliderMoved( int position )
{
// XXX is this locking really useful ?
vlc_mutex_lock( &fInterfaceThread->change_lock );
off_t i_seek = ( position * fInterfaceThread->p_input->stream.p_selected_area->i_size ) / 100;
input_Seek( fInterfaceThread->p_input, i_seek );
vlc_mutex_unlock( &fInterfaceThread->change_lock );
}
void KInterfaceMain::slotSliderChanged( int position )
{
if( fInterfaceThread->p_input != NULL )
{
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
vlc_mutex_lock( &fInterfaceThread->p_input->stream.stream_lock );
#define p_area fInterfaceThread->p_input->stream.p_selected_area
statusBar()->changeItem( input_OffsetToTime( fInterfaceThread->p_input, psz_time, ( p_area->i_size * position ) / 100 ), ID_DATE );
#undef p_area
vlc_mutex_unlock( &fInterfaceThread->p_input->stream.stream_lock );
}
}
void KInterfaceMain::slotOpenDisk()
{
int r = fDiskDialog->exec();
if ( r )
{
// Build source name
QString source;
source += fDiskDialog->type();
source += ':';
source += fDiskDialog->device();
// Select title and chapter
main_PutIntVariable( INPUT_TITLE_VAR, fDiskDialog->title() );
main_PutIntVariable( INPUT_CHAPTER_VAR, fDiskDialog->chapter() );
// add it to playlist
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, source.latin1() );
// Select added item and switch to disk interface
intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
if( fInterfaceThread->p_input != NULL )
{
fInterfaceThread->p_input->b_eof = 1;
}
}
}
void KInterfaceMain::slotOpenStream()
{
int r = fNetDialog->exec();
if ( r )
{
// Build source name
QString source;
source += fNetDialog->protocol();
source += "://";
source += fNetDialog->server();
source += ":";
source += QString().setNum( fNetDialog->port() );
// add it to playlist
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, source.latin1() );
intf_PlaylistJumpto( p_main->p_playlist, p_main->p_playlist->i_size-2 );
if( fInterfaceThread->p_input != NULL )
{
fInterfaceThread->p_input->b_eof = 1;
}
}
}
void KInterfaceMain::slotPlay()
{
if( fInterfaceThread->p_input != NULL )
{
input_SetStatus( fInterfaceThread->p_input, INPUT_STATUS_PLAY );
}
}
void KInterfaceMain::slotPause()
{
if ( fInterfaceThread->p_input != NULL )
{
input_SetStatus( fInterfaceThread->p_input, INPUT_STATUS_PAUSE );
}
}
void KInterfaceMain::slotStop()
{
cerr << "KInterfaceMain::slotStop() - Unimplemented\n";
}
void KInterfaceMain::slotBackward()
{
if( fInterfaceThread->p_input != NULL )
{
/* FIXME: temporary hack */
intf_PlaylistPrev( p_main->p_playlist );
intf_PlaylistPrev( p_main->p_playlist );
fInterfaceThread->p_input->b_eof = 1;
}
}
void KInterfaceMain::slotForward()
{
if( fInterfaceThread->p_input != NULL )
{
/* FIXME: temporary hack */
fInterfaceThread->p_input->b_eof = 1;
}
}
void KInterfaceMain::slotSlow()
{
if( fInterfaceThread->p_input != NULL )
{
input_SetStatus( fInterfaceThread->p_input, INPUT_STATUS_SLOWER );
}
}
void KInterfaceMain::slotFast()
{
if( fInterfaceThread->p_input != NULL )
{
input_SetStatus( fInterfaceThread->p_input, INPUT_STATUS_FASTER );
}
}
void KInterfaceMain::dragEnterEvent( QDragEnterEvent *event )
{
event->accept( QUriDrag::canDecode( event ) );
}
void KInterfaceMain::dropEvent( QDropEvent *event )
{
KURL::List urlList;
if ( KURLDrag::decode( event, urlList ) ) {
for ( KURL::List::ConstIterator i = urlList.begin(); i != urlList.end(); i++ )
{
// XXX add a private function to add a KURL with checking
// actually a whole class for core abstraction would be neat
if( !(*i).isEmpty() )
{
fileOpenRecent->addURL( *i );
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, (*i).path() );
}
}
}
}
/***************************************************************************
kinterfacemain.h - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _KINTERFACEMAIN_H_
#define _KINTERFACEMAIN_H_
#define MODULE_NAME kde
#include "intf_plugin.h"
#include <kmainwindow.h>
#include <kurl.h>
#include <qdragobject.h>
#include <qstring.h>
#include <qwidget.h>
class KDiskDialog;
class KNetDialog;
class KRecentFilesAction;
class KTitleMenu;
class KToggleAction;
class KVLCSlider;
/**Main Window for the KDE vlc interface
*@author andres
*/
class KInterfaceMain : public KMainWindow {
Q_OBJECT
public:
KInterfaceMain(intf_thread_t *p_intf, QWidget *parent=0,
const char *name=0);
~KInterfaceMain();
public slots:
/** open a file and load it into the document*/
void slotFileOpen();
/** opens a file from the recent files menu */
void slotFileOpenRecent(const KURL& url);
/** asks for saving if the file is modified, then closes the actual file and window*/
void slotFileClose();
/** closes all open windows by calling close() on each memberList item until the list is empty, then quits the application.
* If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
*/
void slotFileQuit();
/** toggles the toolbar
*/
void slotViewToolBar();
/** toggles the statusbar
*/
void slotViewStatusBar();
/** changes the statusbar contents for the standard label permanently, used to indicate current actions.
* @param text the text that is displayed in the statusbar
*/
void slotStatusMsg( const QString &text );
protected:
/** initializes the KActions of the application */
void initActions();
/** sets up the statusbar for the main window by initialzing a statuslabel.
*/
void initStatusBar();
virtual void dragEnterEvent( QDragEnterEvent *event );
virtual void dropEvent( QDropEvent *event );
private slots:
/** we use this to manage the communication with the vlc core */
void slotManage();
/** this slot is called when we drag the position seek bar */
void slotSliderMoved( int position );
/** called every time the slider changes values */
void slotSliderChanged( int position );
void slotOpenDisk();
void slotOpenStream();
void slotPlay();
void slotPause();
void slotStop();
void slotBackward();
void slotForward();
void slotSlow();
void slotFast();
private:
intf_thread_t *fInterfaceThread;
/** to call p_intf->pf_manage every now and then */
QTimer *fTimer;
/** slider which works well with user movement */
KVLCSlider *fSlider;
/** open dvd/vcd */
KDiskDialog *fDiskDialog;
/** open net stream */
KNetDialog *fNetDialog;
KTitleMenu *fTitleMenu;
// KAction pointers to enable/disable actions
KAction *fileOpen;
KAction *diskOpen;
KAction *streamOpen;
KRecentFilesAction *fileOpenRecent;
KAction *fileClose;
KAction *fileQuit;
KToggleAction *viewToolBar;
KToggleAction *viewStatusBar;
KAction *play;
KAction *pause;
KAction *stop;
KAction *backward;
KAction *forward;
KAction *slow;
KAction *fast;
};
#endif /* _KINTERFACEMAIN_H_ */
/***************************************************************************
knetdialog.cpp - description
-------------------
begin : Mon Apr 9 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "knetdialog.h"
#include <kdialogbase.h>
#include <klineedit.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qradiobutton.h>
#include <qspinbox.h>
#include <qstring.h>
#include <qvbox.h>
#include <qvbuttongroup.h>
#include <qvgroupbox.h>
#include <qwidget.h>
KNetDialog::KNetDialog( QWidget *parent, const char *name ) :
KDialogBase( parent, name, true, QString::null, Ok|Cancel, Ok, true )
{
QVBox *pageVBox = makeVBoxMainWidget();
QHBox *layout = new QHBox( pageVBox );
layout->setSpacing( 5 );
fButtonGroup = new QVButtonGroup( "Protocol", layout );
fTSButton = new QRadioButton( "TS", fButtonGroup);
fTSButton->setChecked( true );
fRTPButton = new QRadioButton( "RTP", fButtonGroup);
fRTPButton->setEnabled( false );
fHTTPButton = new QRadioButton( "HTTP", fButtonGroup);
fHTTPButton->setEnabled( false );
QVGroupBox *serverVBox = new QVGroupBox( "Starting position", layout );
QHBox *titleHBox = new QHBox( serverVBox );
QLabel *titleLabel = new QLabel( "Address ", titleHBox );
fAddress = new KLineEdit( "vls", titleHBox );
QHBox *portHBox = new QHBox( serverVBox );
QLabel *portLabel = new QLabel( "Port ", portHBox );
fPort = new QSpinBox( 0, 65535, 1, portHBox );
}
KNetDialog::~KNetDialog()
{
}
QString KNetDialog::protocol() const
{
if ( fTSButton->isChecked() )
{
return ( QString( "ts" ) );
}
else if ( fRTPButton->isChecked() )
{
return ( QString( "rtp" ) );
}
else
{
return ( QString( "http" ) );
}
}
QString KNetDialog::server() const
{
return ( fAddress->text() );
}
int KNetDialog::port() const
{
return ( fPort->value() );
}
/***************************************************************************
knetdialog.h - description
-------------------
begin : Mon Apr 9 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _KNETDIALOG_H_
#define _KNETDIALOG_H_
#include <qwidget.h>
#include <kdialogbase.h>
class QVButtonGroup;
class QRadioButton;
class QSpinBox;
class KLineEdit;
/**
*@author andres
*/
class KNetDialog : public KDialogBase {
Q_OBJECT
public:
KNetDialog(QWidget *parent=0, const char *name=0);
~KNetDialog();
QString protocol() const;
QString server() const;
int port() const;
private:
QVButtonGroup *fButtonGroup;
QRadioButton *fTSButton;
QRadioButton *fRTPButton;
QRadioButton *fHTTPButton;
KLineEdit *fAddress;
QSpinBox *fPort;
};
#endif /* _KNETDIALOG_H_ */
/***************************************************************************
ktitlemenu.cpp - description
-------------------
begin : Thu Apr 12 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#include "ktitlemenu.h"
#include <kaction.h>
#include <klocale.h>
KTitleMenu::KTitleMenu( intf_thread_t *p_intf, QWidget *parent, const char *name ) : KPopupMenu( parent, name )
{
fInterfaceThread = p_intf;
connect( this, SIGNAL( aboutToShow() ), this, SLOT( regenerateSlot() ) );
fLanguageList = new KActionMenu( "Language", 0, this );
}
KTitleMenu::~KTitleMenu()
{
}
void KTitleMenu::regenerateSlot()
{
// removal of elements and disconnection of signal/slots happen transparently on delete
delete fLanguageList;
fLanguageList = new KActionMenu( "Language", 0, this );
int i_item = 0;
vlc_mutex_lock( &fInterfaceThread->p_input->stream.stream_lock );
for( int i = 0 ; i < fInterfaceThread->p_input->stream.i_es_number ; i++ )
{
if( fInterfaceThread->p_input->stream.pp_es[i]->i_cat /* == i_cat */ )
{
i_item++;
QString language( fInterfaceThread->p_input->stream.pp_es[i]->psz_desc );
if ( QString::null == language )
{
language += i18n( "Language" );
language += " " + i_item;
}
KRadioAction *action = new KRadioAction( language, 0, this, "language_action" );
fLanguageList->insert( action );
if( /* p_es == */ fInterfaceThread->p_input->stream.pp_es[i] )
{
/* don't lose p_item when we append into menu */
//p_item_active = p_item;
}
}
}
vlc_mutex_unlock( &fInterfaceThread->p_input->stream.stream_lock );
// /* link the new menu to the menubar item */
// gtk_menu_item_set_submenu( GTK_MENU_ITEM( p_root ), p_menu );
//
// /* acitvation will call signals so we can only do it
// * when submenu is attached to menu - to get intf_window */
// if( p_item_active != NULL )
// {
// gtk_check_menu_item_set_active( GTK_CHECK_MENU_ITEM( p_item_active ),
// TRUE );
// }
/* be sure that menu is sensitive if non empty */
if ( i_item > 0 )
{
fLanguageList->setEnabled( true );
}
}
/** this method is called when the user selects a language */
void KTitleMenu::languageSelectedSlot()
{
}
/***************************************************************************
ktitlemenu.h - description
-------------------
begin : Thu Apr 12 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
#ifndef _KTITLEMENU_H_
#define _KTITLEMENU_H_
#define MODULE_NAME kde
#include "intf_plugin.h"
#include <qwidget.h>
#include <kpopupmenu.h>
class KActionMenu;
/**
*@author andres
*/
class KTitleMenu : public KPopupMenu {
Q_OBJECT
public:
KTitleMenu( intf_thread_t *p_intf, QWidget *parent=0, const char *name=0 );
~KTitleMenu();
private:
intf_thread_t *fInterfaceThread;
KActionMenu *fLanguageList;
private slots: // Private slots
/** this method regenerates the popup menu */
void regenerateSlot();
/** this method is called when the user selects a language */
void languageSelectedSlot();
};
#endif /* _KTITLEMENU_H_ */
/***************************************************************************
kinterfacemain.cpp - description
-------------------
begin : Sun Mar 25 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
/***************************************************************************
shamelessly copied from noatun's excellent interface
****************************************************************************/
#include "kvlcslider.h"
KVLCSlider::KVLCSlider(QWidget * parent, const char * name) :
QSlider(parent,name), pressed(false)
{
}
KVLCSlider::KVLCSlider(Orientation o, QWidget * parent, const char * name) :
QSlider(o,parent,name), pressed(false)
{
}
KVLCSlider::KVLCSlider(int minValue, int maxValue, int pageStep, int value,
Orientation o, QWidget * parent, const char * name) :
QSlider(minValue, maxValue, pageStep, value, o, parent,name), pressed(false)
{
}
void KVLCSlider::setValue(int i)
{
if ( !pressed )
{
QSlider::setValue( i );
}
}
void KVLCSlider::mousePressEvent( QMouseEvent *e )
{
if ( e->button() != RightButton )
{
pressed=true;
QSlider::mousePressEvent( e );
}
}
void KVLCSlider::mouseReleaseEvent( QMouseEvent *e )
{
pressed=false;
QSlider::mouseReleaseEvent( e );
emit userChanged( value() );
}
/***************************************************************************
kvlcslider.h - description
-------------------
begin : Sun Apr 03 2001
copyright : (C) 2001 by andres
email : dae@chez.com
***************************************************************************/
/***************************************************************************
shamelessly copied from noatun's excellent interface
****************************************************************************/
#ifndef _KVLCSLIDER_H_
#define _KVLCSLIDER_H_
#include <qslider.h>
/**
* This slider can be changed by the vlc while not dragged by the user
*/
class KVLCSlider : public QSlider
{
Q_OBJECT
public:
KVLCSlider(QWidget * parent, const char * name=0);
KVLCSlider(Orientation, QWidget * parent, const char * name=0);
KVLCSlider(int minValue, int maxValue, int pageStep, int value,
Orientation, QWidget * parent, const char * name=0);
signals:
/**
* emmited only when the user changes the value by hand
*/
void userChanged( int value );
public slots:
virtual void setValue( int );
protected:
virtual void mousePressEvent( QMouseEvent * e );
virtual void mouseReleaseEvent( QMouseEvent * e );
private:
bool pressed; // set this to true when the user drags the slider
};
#endif /* _KVLCSLIDER_H_ */
<!DOCTYPE kpartgui>
<kpartgui name="kvlc" version="0.1">
<ActionProperties>
<Action name="open_disk" icon="dvd_unmount"/>
<Action name="open_stream" icon="connect_no"/>
<Action name="play" icon="1rightarrow"/>
<Action name="pause" icon = "player_pause"/>
<Action name="stop" icon="player_stop"/>
<Action name="backward" icon="player_start"/>
<Action name="forward" icon="player_end"/>
<Action name="fast" icon="2rightarrow"/>
<Action name="slow" icon="2leftarrow"/>
</ActionProperties>
<MenuBar>
<Menu name="file" noMerge="1"><text>&amp;File</text>
<Action name="file_open"/>
<Action name="file_open_recent"/>
<Action name="open_disk"/>
<Action name="open_stream"/>
<Separator lineSeparator="true"/>
<Action name="file_close"/>
<Separator lineSeparator="true"/>
<Action name="file_quit"/>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar" noMerge="1">
</ToolBar>
<ToolBar name="main" iconText="icononly" iconSize="32">
<Action name="file_open"/>
<Action name="open_disk"/>
<Action name="open_stream"/>
<Separator lineSeparator="true"/>
<Action name="backward"/>
<Action name="play"/>
<Action name="pause"/>
<Action name="stop"/>
<Action name="forward"/>
<Action name="slow"/>
<Action name="fast"/>
</ToolBar>
</kpartgui>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment