of Sigmund Augdal <sigmunau@stud.ntnu.no>.
-MOC_SOURCES = kde_interface.moc.cpp kde_slider.moc.cpp kde_disc.moc.cpp kde_net.moc.cpp kde_menu.moc.cpp
+MOC_SOURCES = kde_interface.moc.cpp kde_slider.moc.cpp kde_disc.moc.cpp kde_net.moc.cpp kde_menu.moc.cpp kde_preferences.moc.cpp kde_pluginsbox.moc.cpp QConfigItem.moc.cpp
-kde_SOURCES = kde.cpp kde_interface.cpp kde_slider.cpp kde_disc.cpp kde_net.cpp kde_menu.cpp $(MOC_SOURCES)
+kde_SOURCES = kde.cpp kde_interface.cpp kde_slider.cpp kde_disc.cpp kde_net.cpp kde_menu.cpp kde_preferences.cpp kde_pluginsbox.cpp QConfigItem.cpp $(MOC_SOURCES)
$(MOC_SOURCES): %.moc.cpp: %.h
$(MOC) $< -o $@
--- /dev/null
+#include "QConfigItem.h"
+#include <videolan/vlc.h>
+QConfigItem::QConfigItem(QObject *parent, QString name, int iType, int i_val) :
+ QObject(parent, name)
+{
+ type = iType;
+ iVal = i_val;
+}
+
+QConfigItem::QConfigItem(QObject *parent, QString name, int iType, float f_val) :
+ QObject(parent, name)
+{
+ type = iType;
+ fVal = f_val;
+}
+
+QConfigItem::QConfigItem(QObject *parent, QString name, int iType, QString s_val) :
+ QObject(parent, name)
+{
+ type = iType;
+ sVal = s_val;
+}
+
+QConfigItem::~QConfigItem()
+{
+ ;
+}
+
+int QConfigItem::getType()
+{
+ return type;
+}
+
+int QConfigItem::iValue()
+{
+ return iVal;
+}
+
+float QConfigItem::fValue()
+{
+ return fVal;
+}
+
+QString QConfigItem::sValue()
+{
+ return sVal;
+}
+
+void QConfigItem::setValue(int val)
+{
+ iVal = val;
+}
+
+void QConfigItem::setValue(float val)
+{
+ fVal = val;
+}
+
+void QConfigItem::setValue(double val)
+{
+ fVal = (float)val;
+}
+
+void QConfigItem::setValue(const QString &val)
+{
+ sVal = val;
+}
--- /dev/null
+#ifndef _KCONFIGITEM_H_
+#define _KCONFIGITEM_H_
+#include <qobject.h>
+#include <qstring.h>
+/*
+ A class to handle the information for one configuration item.
+*/
+
+class QConfigItem : public QObject
+{
+ Q_OBJECT
+ public:
+ QConfigItem(QObject *parent, QString name, int iType, int i_val);
+ QConfigItem(QObject *parent, QString name, int iType, float f_val);
+ QConfigItem(QObject *parent, QString name, int iType, QString s_val);
+ ~QConfigItem();
+
+ int getType();
+ float fValue();
+ int iValue();
+ QString sValue();
+
+ public slots:
+ void setValue(int val);
+ void setValue(float val);
+ void setValue(double val);
+ void setValue(const QString &val);
+
+ private:
+ int iVal, type;
+ float fVal;
+ QString sVal;
+};
+#endif
#include "kde_net.h"
#include "kde_menu.h"
#include "kde_slider.h"
+#include "kde_preferences.h"
#include <iostream.h>
#include <qcursor.h>
#include <qdragobject.h>
#include <qtimer.h>
+#include <kdialog.h>
#define ID_STATUS_MSG 1
#define ID_DATE 2
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 ) ) );
setCentralWidget(fSlider);
fileOpen = KStdAction::open(this, SLOT(slotFileOpen()), actionCollection());
fileOpenRecent = KStdAction::openRecent(this, SLOT(slotFileOpenRecent(const KURL&)), actionCollection());
fileClose = KStdAction::close(this, SLOT(slotFileClose()), 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());
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" );
-
+
fileOpen->setStatusText(i18n("Opens an existing document"));
fileOpenRecent->setStatusText(i18n("Opens a recently used file"));
fileClose->setStatusText(i18n("Closes the actual document"));
slotStatusMsg(i18n("Ready."));
}
+void KInterface::slotShowPreferences()
+{
+ // Do something
+ KPreferences("main", this, "preferences");
+}
+
void KInterface::slotStatusMsg(const QString &text)
{
///////////////////////////////////////////////////////////////////
#endif
/* Manage the slider */
- if( p_input_bank->pp_input[0] != NULL )
- {
#define p_area p_input_bank->pp_input[0]->stream.p_selected_area
- fSlider->setValue( ( 100 * p_area->i_tell ) / p_area->i_size );
-#undef p_area
+ if( (p_input_bank->pp_input[0] != NULL) && (p_area->i_size != 0 ))
+ {
+ fSlider->setValue( ( 10000. * p_area->i_tell ) / p_area->i_size );
}
+#undef p_area
/* Manage core vlc functions through the callback */
p_intf->pf_manage(p_intf);
// XXX is this locking really useful ?
vlc_mutex_lock( &p_intf->change_lock );
- off_t i_seek = ( position * p_input_bank->pp_input[0]->stream.p_selected_area->i_size ) / 100;
+ off_t i_seek = ( position * p_input_bank->pp_input[0]->stream.p_selected_area->i_size ) / 10000;
input_Seek( p_input_bank->pp_input[0], i_seek );
vlc_mutex_unlock( &p_intf->change_lock );
vlc_mutex_lock( &p_input_bank->pp_input[0]->stream.stream_lock );
#define p_area p_input_bank->pp_input[0]->stream.p_selected_area
- statusBar()->changeItem( input_OffsetToTime( p_input_bank->pp_input[0], psz_time, ( p_area->i_size * position ) / 100 ), ID_DATE );
+ statusBar()->changeItem( input_OffsetToTime( p_input_bank->pp_input[0], psz_time, ( p_area->i_size * position ) / 10000 ), ID_DATE );
#undef p_area
vlc_mutex_unlock( &p_input_bank->pp_input[0]->stream.stream_lock );
* If queryClose() returns false because the user canceled the saveModified() dialog, the closing breaks.
*/
void slotFileQuit();
+ void slotShowPreferences();
+
/** toggles the toolbar
*/
void slotViewToolBar();
KAction *fast;
KAction *prev;
KAction *next;
+ KAction *preferences;
};
/*****************************************************************************
--- /dev/null
+#include "kde_pluginsbox.h"
+#include "kde_preferences.h"
+
+#include <videolan/vlc.h>
+#include <qgroupbox.h>
+#include <qhbox.h>
+#include <qlabel.h>
+#include <qvbox.h>
+#include <klistview.h>
+#include <kbuttonbox.h>
+
+KPluginsBox::KPluginsBox(QString text, QString value, QWidget *parent,
+ int spacing, KPreferences *pref) :
+ QGroupBox( 1, Vertical, text, parent )
+{
+ owner = pref;
+ QVBox *item_vbox = new QVBox( this );
+ item_vbox->setSpacing(spacing);
+
+ listView = new KListView(item_vbox);
+ listView->setAllColumnsShowFocus(true);
+ listView->addColumn(_("Name"));
+ listView->addColumn(_("Description"));
+ KButtonBox *item_bbox = new KButtonBox(item_vbox);
+ configure = item_bbox->addButton( _("Configure") );
+ configure->setEnabled(false);
+ selectButton = item_bbox->addButton( _("Select") );
+ QHBox *item_hbox = new QHBox(item_vbox);
+ item_hbox->setSpacing(spacing);
+ new QLabel( _("Selected:"), item_hbox );
+ line = new KLineEdit( value, item_hbox );
+ connect(selectButton, SIGNAL(clicked()), this, SLOT(selectClicked()));
+ connect(configure, SIGNAL(clicked()), this, SLOT(configureClicked()));
+ connect(listView, SIGNAL(selectionChanged( QListViewItem *)),
+ this, SLOT( selectionChanged( QListViewItem *)));
+}
+
+KPluginsBox::~KPluginsBox()
+{
+ ;
+}
+
+QListView* KPluginsBox::getListView()
+{
+ return listView;
+}
+
+void KPluginsBox::selectClicked()
+{
+ if (listView->selectedItem()) {
+ line->setText(listView->selectedItem()->text(0));
+ emit selectionChanged(listView->selectedItem()->text(0));
+ }
+}
+
+void KPluginsBox::configureClicked()
+{
+ if (listView->selectedItem()) {
+ new KPreferences(listView->selectedItem()->text(0), this);
+ }
+}
+void KPluginsBox::selectionChanged( QListViewItem *item )
+{
+ selectButton->setEnabled(true);
+ /* look for module 'psz_name' */
+ configure->setEnabled(owner->isConfigureable(item->text(0)));
+}
--- /dev/null
+#ifndef _KDE_PLUGINBOX_H_
+#define _KDE_PLUGINBOX_H_
+#include <qgroupbox.h>
+#include <klistview.h>
+#include <qpushbutton.h>
+#include <klineedit.h>
+#include "kde_preferences.h"
+class KPluginsBox : public QGroupBox
+{
+ Q_OBJECT
+ public:
+ KPluginsBox(QString title, QString value, QWidget *parent, int spacing,
+ KPreferences *pref);
+ ~KPluginsBox();
+
+ QListView *getListView(void);
+
+ private slots:
+ void selectClicked(void);
+ void configureClicked(void);
+ void selectionChanged( QListViewItem * );
+
+ signals:
+ void selectionChanged(const QString &text);
+
+ private:
+ KListView *listView;
+ QPushButton *configure;
+ QPushButton *selectButton;
+ KLineEdit *line;
+ KPreferences *owner;
+};
+#endif
--- /dev/null
+#include <kdialogbase.h>
+#include <qmap.h>
+#include <qcheckbox.h>
+#include <qframe.h>
+#include <qgroupbox.h>
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlistview.h>
+#include <qnamespace.h>
+#include <qobjectlist.h>
+#include <qspinbox.h>
+#include <qtooltip.h>
+#include <qvbox.h>
+
+#include <kbuttonbox.h>
+#include <klineedit.h>
+#include <klocale.h>
+#include <knuminput.h>
+#include <videolan/vlc.h>
+
+#include "QConfigItem.h"
+#include "kde_pluginsbox.h"
+#include "kde_preferences.h"
+#include "interface.h"
+
+/*
+ construkt a new configuration window for the given module
+*/
+KPreferences::KPreferences(const char *psz_module_name, QWidget *parent,
+ const QString &caption) :
+ KDialogBase ( Tabbed, caption, Ok| Apply|Cancel|User1, Ok, parent,
+ "vlc preferences", true, false, "Save")
+{
+ module_t *p_module, *p_module_bis;
+ module_config_t *p_item;
+ QVBox *category_table = NULL;
+ QString *category_label;
+
+ /* Look for the selected module */
+ for( p_module = p_module_bank->first ; p_module != NULL ;
+ p_module = p_module->next )
+ {
+
+ if( psz_module_name && !strcmp( psz_module_name, p_module->psz_name ) )
+ break;
+ }
+ if( !p_module ) return;
+ p_item = p_module->p_config;
+ do
+ {
+ switch( p_item->i_type )
+ {
+
+ case MODULE_CONFIG_HINT_CATEGORY:
+ case MODULE_CONFIG_HINT_END:
+
+ /*
+ * Now we can start taking care of the new category
+ */
+ if( p_item->i_type == MODULE_CONFIG_HINT_CATEGORY )
+ {
+ category_label = new QString( p_item->psz_text );
+ QFrame *page = addPage( *category_label );
+ QVBoxLayout *toplayout = new QVBoxLayout( page);
+ QScrollView *sv = new QScrollView(page);
+ sv->setResizePolicy(QScrollView::AutoOneFit);
+ sv->setFrameStyle(QScrollView::NoFrame);
+ toplayout->addWidget(sv);
+ category_table = new QVBox(sv->viewport());
+ sv->addChild(category_table);
+ toplayout->addStretch(10);
+ category_table->setSpacing(spacingHint());
+ }
+
+ break;
+
+ case MODULE_CONFIG_ITEM_MODULE:
+
+ {
+
+ vlc_mutex_lock( p_item->p_lock );
+ KPluginsBox *item_frame =
+ new KPluginsBox( p_item->psz_text,
+ p_item->psz_value ? p_item->psz_value :"",
+ category_table,
+ spacingHint(),
+ this );
+ QConfigItem *ci = new QConfigItem(this,
+ p_item->psz_name,
+ p_item->i_type,
+ p_item->psz_value);
+ connect(item_frame, SIGNAL(selectionChanged(const QString &)),
+ ci, SLOT(setValue(const QString &)));
+
+
+ /* build a list of available plugins */
+
+ for( p_module_bis = p_module_bank->first ;
+ p_module_bis != NULL ;
+ p_module_bis = p_module_bis->next ) {
+ if( p_module_bis->i_capabilities & (1 << p_item->i_value)){
+ new QListViewItem(item_frame->getListView(),
+ p_module_bis->psz_name,
+ p_module_bis->psz_longname);
+ }
+ }
+ vlc_mutex_unlock( p_item->p_lock );
+ }
+ break;
+
+ case MODULE_CONFIG_ITEM_STRING:
+ case MODULE_CONFIG_ITEM_FILE:
+
+ {
+ QHBox *hb = new QHBox(category_table);
+ hb->setSpacing(spacingHint());
+ new QLabel(p_item->psz_text, hb);
+ /* add input box with default value */
+ vlc_mutex_lock( p_item->p_lock );
+
+ KLineEdit *kl = new KLineEdit( p_item->psz_value ?
+ p_item->psz_value : "", hb);
+ QConfigItem *ci = new QConfigItem(this, p_item->psz_name,
+ p_item->i_type,
+ p_item->psz_value ?
+ p_item->psz_value : "");
+ connect(kl, SIGNAL(textChanged ( const QString & )),
+ ci, SLOT(setValue( const QString &)));
+ QToolTip::add(kl, p_item->psz_longtext);
+ kl->setMaxLength(10);
+
+ vlc_mutex_unlock( p_item->p_lock );
+
+ }
+ break;
+
+ case MODULE_CONFIG_ITEM_INTEGER:
+ /* add input box with default value */
+ {
+ QHBox *hb = new QHBox(category_table);
+ hb->setSpacing(spacingHint());
+ new QLabel(p_item->psz_text, hb);
+ QSpinBox *item_adj = new QSpinBox(-1, 99999, 1, hb);
+ QConfigItem *ci = new QConfigItem(this, p_item->psz_name,
+ p_item->i_type,
+ p_item->i_value);
+ connect(item_adj, SIGNAL(valueChanged( int)),
+ ci, SLOT(setValue(int)));
+ QToolTip::add(item_adj, p_item->psz_longtext);
+ item_adj->setValue( p_item->i_value );
+ }
+ break;
+
+ case MODULE_CONFIG_ITEM_FLOAT:
+ {
+ QHBox *hb = new QHBox(category_table);
+ hb->setSpacing(spacingHint());
+ new QLabel(p_item->psz_text, hb);
+ KDoubleNumInput *kdi= new KDoubleNumInput(p_item->f_value, hb);
+ kdi->setRange(-1, 99999, 0.01, false);
+ QConfigItem *ci = new QConfigItem(this, p_item->psz_name,
+ p_item->i_type,
+ p_item->f_value);
+ connect(kdi, SIGNAL(valueChanged(double)),
+ ci, SLOT(setValue(double)));
+ QToolTip::add(kdi, p_item->psz_longtext);
+
+ }
+ break;
+
+
+ case MODULE_CONFIG_ITEM_BOOL:
+
+ /* add check button */
+ {
+ QCheckBox *bool_checkbutton =
+ new QCheckBox(QString(p_item->psz_text), category_table);
+ QConfigItem *ci = new QConfigItem(this, p_item->psz_name,
+ p_item->i_type,
+ p_item->i_value);
+ bool_checkbutton->setChecked(p_item->i_value);
+ connect(bool_checkbutton, SIGNAL(stateChanged( int)),
+ ci, SLOT(setValue(int)));
+ QToolTip::add(bool_checkbutton, p_item->psz_longtext);
+
+ }
+ break;
+
+ }
+
+ p_item++;
+ }
+ while( p_item->i_type != MODULE_CONFIG_HINT_END );
+ exec();
+
+}
+
+/*
+ empty destructor, qt takes care of this (I think)
+*/
+KPreferences::~KPreferences()
+{
+}
+
+/*
+ return true if the give module is configureable
+*/
+bool KPreferences::isConfigureable(QString module)
+{
+ module_t *p_module;
+ for( p_module = p_module_bank->first ;
+ p_module != NULL ;
+ p_module = p_module->next ) {
+ if( !module.compare( p_module->psz_name ) ) {
+ return p_module->i_config_items != 0;
+ }
+ }
+ return false;
+
+}
+
+/*
+ run when the Apply button is pressed, and by the methods for the ok
+ and save buttons
+*/
+void KPreferences::slotApply()
+{
+ QObjectList * l = queryList( "QConfigItem" );
+ QObjectListIt it( *l ); // iterate over the config items
+ QObject * obj;
+ while ( (obj=it.current()) != 0 ) {
+ ++it;
+ QConfigItem *p_config = (QConfigItem *)obj;
+ intf_WarnMsg(1, const_cast<char *>(p_config->name()));
+ intf_WarnMsg(1, "%d", p_config->getType());
+
+ switch( p_config->getType() ) {
+
+ case MODULE_CONFIG_ITEM_STRING:
+ case MODULE_CONFIG_ITEM_FILE:
+ case MODULE_CONFIG_ITEM_MODULE:
+ if (p_config->sValue()) {
+ config_PutPszVariable( p_config->name(),
+ strdup(p_config->sValue().latin1()));
+ }
+ else {
+ config_PutPszVariable( p_config->name(), NULL );
+ }
+ break;
+ case MODULE_CONFIG_ITEM_INTEGER:
+ case MODULE_CONFIG_ITEM_BOOL:
+ config_PutIntVariable( p_config->name(), p_config->iValue() );
+ break;
+ case MODULE_CONFIG_ITEM_FLOAT:
+ if (config_PutFloatVariable) {
+ config_PutFloatVariable( p_config->name(), p_config->fValue());
+ }
+ else {
+ intf_WarnMsg(1, "config_PutFloatVariable not defined");
+ }
+ break;
+ }
+ }
+ delete l;
+}
+
+/*
+ run when the Ok button is pressed
+*/
+void KPreferences::slotOk()
+{
+ slotApply();
+ accept();
+}
+
+/*
+ run when the save button is pressed
+*/
+void KPreferences::slotUser1()
+{
+ slotApply();
+ config_SaveConfigFile( NULL );
+}
--- /dev/null
+#ifndef _KDE_PREFERENCES_H_
+#define _KDE_PREFERENCES_H_
+#include <kdialogbase.h>
+
+#include "QConfigItem.h"
+class KPreferences : KDialogBase
+{
+ Q_OBJECT
+ public:
+ KPreferences( const char *psz_module_name, QWidget *parent,
+ const QString &caption=QString::null);
+ ~KPreferences();
+ bool isConfigureable(QString module);
+
+ public slots:
+ void slotApply();
+ void slotOk();
+ void slotUser1();
+};
+#endif