Commit f10eac9f authored by Clément Stenac's avatar Clément Stenac

Skeleton for simple prefs

parent f9ed4872
......@@ -12,7 +12,7 @@
AUTOMAKE_OPTIONS = subdir-objects
TOUI = ui/input_stats ui/main_interface ui/file_open \
ui/logindialog ui/inputdialog ui/progressdialog
ui/logindialog ui/inputdialog ui/progressdialog ui/sprefs_trivial
UIH = $(TOUI:%=%.h)
TOMOC = main_interface \
......@@ -28,6 +28,7 @@ TOMOC = main_interface \
components/infopanels \
components/preferences_widgets \
components/preferences \
components/simple_preferences \
components/open \
components/video_widget \
components/playlist/panels \
......@@ -51,6 +52,7 @@ nodist_SOURCES_qt4 = \
components/infopanels.moc.cpp \
components/preferences_widgets.moc.cpp \
components/preferences.moc.cpp \
components/simple_preferences.moc.cpp \
components/open.moc.cpp \
components/video_widget.moc.cpp \
components/playlist/panels.moc.cpp \
......@@ -94,6 +96,7 @@ SOURCES_qt4 = qt4.cpp \
components/infopanels.cpp \
components/preferences_widgets.cpp \
components/preferences.cpp \
components/simple_preferences.cpp \
components/open.cpp \
components/video_widget.cpp \
components/playlist/standardpanel.cpp \
......@@ -118,6 +121,7 @@ EXTRA_DIST += \
components/infopanels.hpp \
components/preferences_widgets.hpp \
components/preferences.hpp \
components/simple_preferences.hpp \
components/open.hpp \
components/video_widget.hpp \
components/playlist/panels.hpp \
......@@ -133,6 +137,7 @@ EXTRA_DIST += \
ui/logindialog.ui \
ui/inputdialog.ui \
ui/progressdialog.ui \
ui/sprefs_trivial.ui \
pixmaps/advanced.xpm \
pixmaps/audio.xpm \
pixmaps/codec.xpm \
......
/*****************************************************************************
* preferences_tree.cpp : Tree of modules for preferences
* preferences.cpp : "Normal preferences"
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id$
......@@ -25,6 +25,7 @@
#include "components/preferences_widgets.hpp"
#include "qt4.hpp"
#include <vlc_config_cat.h>
#include <vlc_intf_strings.h>
#include <assert.h>
#include "pixmaps/audio.xpm"
......@@ -451,9 +452,9 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
continue;
}
if( !box )
layout->addWidget( control );
layout->addWidget( control->getWidget() );
else
boxlayout->addWidget( control );
boxlayout->addWidget( control->getWidget() );
controls.append( control );
}
......@@ -477,8 +478,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
scroller->setWidgetResizable( true );
global_layout->addWidget( scroller );
some_hidden_text = new QLabel( "Some options are available but hidden. "\
"Check \"Advanced options\" to see them." );
some_hidden_text = new QLabel( qfu( I_HIDDEN_ADV ) );
some_hidden_text->setWordWrap( true );
setLayout( global_layout );
......@@ -528,7 +528,7 @@ void PrefsPanel::setAdvanced( bool adv, bool force )
if( (*i)->isAdvanced() )
{
if( !advanced ) some_hidden = true;
(*i)->setVisible( advanced );
(*i)->getWidget()->setVisible( advanced );
}
}
if( some_hidden_text )
......
......@@ -39,16 +39,9 @@
#include <QVariant>
#include <QComboBox>
ConfigControl::ConfigControl( vlc_object_t *_p_this, module_config_t *p_item,
QWidget *_parent ) : QWidget( _parent ),
p_this( _p_this ), _name( p_item->psz_name )
{
}
ConfigControl::~ConfigControl() {}
ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
module_config_t *p_item, QWidget *parent )
module_config_t *p_item,
QWidget *parent )
{
ConfigControl *p_control = NULL;
if( p_item->psz_current ) return NULL;
......@@ -79,34 +72,60 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
/*********** String **************/
StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *p_item, QWidget *_parent, bool pwd )
: VStringConfigControl( _p_this, p_item, _parent )
module_config_t *_p_item,
QWidget *_parent, bool pwd ) :
VStringConfigControl( _p_this, _p_item, _parent )
{
QLabel *label = new QLabel( qfu(p_item->psz_text) );
text = new QLineEdit( qfu(p_item->psz_value) );
text->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) );
finish(label);
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
setLayout( layout );
widget->setLayout( layout );
}
StringConfigControl::~StringConfigControl() {}
QString StringConfigControl::getValue() { return text->text(); };
StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *label, QLineEdit *_text, bool pwd ):
VStringConfigControl( _p_this, _p_item )
{
text = _text;
finish( label );
}
void StringConfigControl::finish( QLabel *label )
{
text->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) );
}
/********* Module **********/
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
module_config_t *p_item, QWidget *_parent,
bool bycat ) : VStringConfigControl( _p_this, p_item, _parent )
module_config_t *_p_item, QWidget *_parent,
bool bycat ) : VStringConfigControl( _p_this, _p_item, _parent )
{
QLabel *label = new QLabel( qfu(p_item->psz_text) );
combo = new QComboBox();
finish( label, bycat );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo );
widget->setLayout( layout );
}
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *label, QComboBox *_combo,
bool bycat ) : VStringConfigControl( _p_this, _p_item )
{
fprintf( stderr, "%p %p\n", _p_item, p_item );
combo = _combo;
finish( label, bycat );
}
void ModuleConfigControl::finish( QLabel *label, bool bycat )
{
vlc_list_t *p_list;
module_t *p_parser;
QLabel *label = new QLabel( qfu(p_item->psz_text) );
combo = new QComboBox();
combo->setEditable( false );
/* build a list of available modules */
......@@ -145,10 +164,6 @@ ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
vlc_list_release( p_list );
combo->setToolTip( qfu(p_item->psz_longtext) );
label->setToolTip( qfu(p_item->psz_longtext) );
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo );
setLayout( layout );
}
ModuleConfigControl::~ModuleConfigControl() {};
......
......@@ -25,28 +25,42 @@
#define _INFOPANELS_H_
#include <vlc/vlc.h>
#include <QWidget>
#include <QLineEdit>
#include "ui/input_stats.h"
#include "qt4.hpp"
#include <assert.h>
class QSpinBox;
class QLineEdit;
class QString;
class QComboBox;
class QCheckBox;
class ConfigControl : public QWidget
class ConfigControl : public QObject
{
Q_OBJECT;
public:
ConfigControl( vlc_object_t *, module_config_t *, QWidget * );
virtual ~ConfigControl();
QString getName() { return _name; }
bool isAdvanced() { return _advanced; }
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf,
QWidget *p ) : p_this( _p_this ), p_item( _p_conf )
{
widget = new QWidget( p );
}
ConfigControl( vlc_object_t *_p_this, module_config_t *_p_conf ) :
p_this (_p_this ), p_item( _p_conf )
{
widget = NULL;
}
virtual ~ConfigControl() {};
QString getName() { return qfu( p_item->psz_name ); }
QWidget *getWidget() { assert( widget ); return widget; }
bool isAdvanced() { return p_item->b_advanced; }
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget* );
protected:
vlc_object_t *p_this;
module_config_t *p_item;
QString _name;
QWidget *widget;
bool _advanced;
signals:
void Updated();
......@@ -119,6 +133,8 @@ class VStringConfigControl : public ConfigControl
public:
VStringConfigControl( vlc_object_t *a, module_config_t *b, QWidget *c ) :
ConfigControl(a,b,c) {};
VStringConfigControl( vlc_object_t *a, module_config_t *b ) :
ConfigControl(a,b) {};
virtual ~VStringConfigControl() {};
virtual QString getValue() = 0;
};
......@@ -128,9 +144,12 @@ class StringConfigControl : public VStringConfigControl
public:
StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool pwd );
virtual ~StringConfigControl();
virtual QString getValue();
StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit*, bool pwd );
virtual ~StringConfigControl() {};
virtual QString getValue() { return text->text(); };
private:
void finish( QLabel * );
QLineEdit *text;
};
......@@ -139,9 +158,12 @@ class ModuleConfigControl : public VStringConfigControl
public:
ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool
bycat );
ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool );
virtual ~ModuleConfigControl();
virtual QString getValue();
private:
void finish( QLabel *, bool );
QComboBox *combo;
};
#if 0
......
/*****************************************************************************
* simple_preferences.cpp : "Simple preferences"
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: preferences.cpp 16348 2006-08-25 21:10:10Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.org>
* Antoine Cellerier <dionoea@videolan.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "components/simple_preferences.hpp"
#include "components/preferences_widgets.hpp"
#include "qt4.hpp"
#include <vlc_config_cat.h>
#include <assert.h>
#include <QListWidget>
#include <QListWidgetItem>
#include <QString>
#include <QFont>
#include "pixmaps/audio.xpm"
#include "ui/sprefs_trivial.h"
#define ITEM_HEIGHT 25
/*********************************************************************
* The List of categories
*********************************************************************/
SPrefsCatList::SPrefsCatList( intf_thread_t *_p_intf, QWidget *_parent ) :
QListWidget( _parent ), p_intf( _p_intf )
{
setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
setAlternatingRowColors( true );
#ifndef WIN32
// Fixme - A bit UGLY
QFont f = font();
int pSize = f.pointSize();
if( pSize > 0 )
f.setPointSize( pSize + 1 );
else
f.setPixelSize( f.pixelSize() + 1 );
setFont( f );
#endif
addItem( "Very trivial" );
item(0)->setIcon( QIcon( QPixmap( audio_xpm ) ) );
}
void SPrefsCatList::ApplyAll()
{
DoAll( false );
}
void SPrefsCatList::CleanAll()
{
DoAll( true );
}
/// \todo When cleaning, we should remove the panel ?
void SPrefsCatList::DoAll( bool doclean )
{
/* Todo */
}
/*********************************************************************
* The Panels
*********************************************************************/
SPrefsPanel::SPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
int number ) : QWidget( _parent ), p_intf( _p_intf )
{
if( number == 0 )
{
Ui::SPrefsTrivial ui;
ui.setupUi( this );
msg_Err( p_intf, "Intf there" );
module_config_t *p_config = config_FindConfig( VLC_OBJECT(p_intf),
"memcpy" );
msg_Err( p_intf, "%p", p_config );
ConfigControl *control = new ModuleConfigControl( VLC_OBJECT(p_intf),
p_config, ui.memcpyLabel, ui.memcpyCombo, false );
controls.append( control );
}
else
{
int *p = NULL;
fprintf( stderr, "Ha ha ca te fait bien la bite\n" );
*p=42;
}
}
void SPrefsPanel::Apply()
{
/* todo: factorize with PrefsPanel */
QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ )
{
VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
if( !vicc )
{
VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
if( !vfcc)
{
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(*i);
assert( vscc );
config_PutPsz( p_intf, vscc->getName().toAscii().data(),
vscc->getValue().toAscii().data() );
continue;
}
config_PutFloat( p_intf, vfcc->getName().toAscii().data(),
vfcc->getValue() );
continue;
}
config_PutInt( p_intf, vicc->getName().toAscii().data(),
vicc->getValue() );
}
}
void SPrefsPanel::Clean()
{}
/*****************************************************************************
* simple_preferences.hpp : Simple prefs
****************************************************************************
* Copyright (C) 2006 the VideoLAN team
* $Id: preferences.hpp 16348 2006-08-25 21:10:10Z zorglub $
*
* Authors: Clément Stenac <zorglub@videolan.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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _SIMPLEPREFS_H_
#define _SIMPLEPREFS_H_
#include <QListWidget>
#include <vlc/vlc.h>
#include <vlc/intf.h>
class ConfigControl;
class SPrefsCatList : public QListWidget
{
Q_OBJECT;
public:
SPrefsCatList( intf_thread_t *, QWidget *);
virtual ~SPrefsCatList() {};
void ApplyAll();
void CleanAll();
private:
void DoAll( bool );
intf_thread_t *p_intf;
};
class SPrefsPanel : public QWidget
{
Q_OBJECT
public:
SPrefsPanel( intf_thread_t *, QWidget *, int );
virtual ~SPrefsPanel() {};
void Apply();
void Clean();
private:
intf_thread_t *p_intf;
QList<ConfigControl *> controls;
};
#endif
......@@ -39,7 +39,7 @@ PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
QVLCMenu::createPlMenuBar( menuBar(), p_intf );
selector = new PLSelector( centralWidget(), p_intf, THEPL );
selector->setMaximumWidth( 140 );
selector->setMaximumWidth( 130 );
playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
THEPL->p_local_category );
......
......@@ -25,6 +25,7 @@
#include "util/qvlcframe.hpp"
#include "components/preferences.hpp"
#include "components/simple_preferences.hpp"
#include "qt4.hpp"
#include <QHBoxLayout>
......@@ -126,7 +127,13 @@ void PrefsDialog::setSmall()
advanced_tree->hide();
}
if( !simple_tree )
simple_tree = new QTreeWidget();
{
simple_tree = new SPrefsCatList( p_intf, tree_panel );
connect( simple_tree,
SIGNAL( currentItemChanged( QListWidgetItem *, QListWidgetItem *) ),
this, SLOT( changeSimplePanel( QListWidgetItem * ) ) );
}
tree_panel_l->addWidget( simple_tree );
simple_tree->show();
......@@ -136,7 +143,7 @@ void PrefsDialog::setSmall()
advanced_panel->hide();
}
if( !simple_panel )
simple_panel = new QWidget();
simple_panel = new SPrefsPanel( p_intf, main_panel, 0 );
main_panel_l->addWidget( simple_panel );
simple_panel->show();
}
......@@ -145,6 +152,20 @@ PrefsDialog::~PrefsDialog()
{
}
void PrefsDialog::changeSimplePanel( QListWidgetItem *item )
{
if( simple_panel )
{
main_panel_l->removeWidget( simple_panel );
simple_panel->hide();
/* Don't do this once it works, you would loose all changes */
delete simple_panel;
}
simple_panel = new SPrefsPanel( p_intf, main_panel, 0 );
main_panel_l->addWidget( simple_panel );
simple_panel->show();
}
void PrefsDialog::changePanel( QTreeWidgetItem *item )
{
PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
......
......@@ -27,7 +27,9 @@
#include "util/qvlcframe.hpp"
class PrefsTree;
class SPrefsCatList;
class PrefsPanel;
class SPrefsPanel;
class QTreeWidgetItem;
class QTreeWidget;
class QHBoxLayout;
......@@ -36,6 +38,8 @@ class QGroupBox;
class QRadioButton;
class QWidget;
class QCheckBox;
class QListWidget;
class QListWidgetItem;
class PrefsDialog : public QVLCFrame
{
......@@ -54,11 +58,11 @@ private:
QWidget *main_panel;
QHBoxLayout *main_panel_l;
PrefsPanel *advanced_panel;
QWidget *simple_panel;
SPrefsPanel *simple_panel;
QWidget *tree_panel;
QHBoxLayout *tree_panel_l;
QTreeWidget *simple_tree;
SPrefsCatList *simple_tree;
PrefsTree *advanced_tree;
QGroupBox *types;
......@@ -70,6 +74,7 @@ private:
static PrefsDialog *instance;
private slots:
void changePanel( QTreeWidgetItem *);
void changeSimplePanel( QListWidgetItem *);
void setAll();
void setSmall();
void setAdvanced( bool );
......
<ui version="4.0" >
<author></author>
<comment></comment>
<exportmacro></exportmacro>
<class>SPrefsTrivial</class>
<widget class="QWidget" name="SPrefsTrivial" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="4" column="1" >
<widget class="QSpinBox" name="crSpin" />
</item>
<item row="0" column="0" >
<widget class="QComboBox" name="memcpyCombo" />
</item>
<item row="5" column="0" colspan="2" >
<widget class="QDateTimeEdit" name="dateTimeEdit" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="crLabel" >
<property name="text" >
<string>That's the question</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="memcpyLabel" >
<property name="text" >
<string>Should labels be set in Designer or by program ?.</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLCDNumber" name="lcdNumber" >
<property name="numDigits" >
<number>3</number>
</property>
<property name="value" stdset="0" >
<double>42</double>
</property>
</widget>
</item>
</layout>
</widget>
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>
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