Commit a4989d74 authored by Antoine Cellerier's avatar Antoine Cellerier

Float, Float with range and Integer with range widgets.

parent 7cf4df92
...@@ -79,7 +79,8 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -79,7 +79,8 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
p_control = new IntegerListConfigControl( p_this, p_item, p_control = new IntegerListConfigControl( p_this, p_item,
parent, false, l, line ); parent, false, l, line );
else if( p_item->i_min || p_item->i_max ) else if( p_item->i_min || p_item->i_max )
fprintf( stderr, "Todo\n" ); p_control = new IntegerRangeConfigControl( p_this, p_item, parent,
l, line );
else else
p_control = new IntegerConfigControl( p_this, p_item, parent, p_control = new IntegerConfigControl( p_this, p_item, parent,
l, line ); l, line );
...@@ -92,9 +93,11 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -92,9 +93,11 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
break; break;
case CONFIG_ITEM_FLOAT: case CONFIG_ITEM_FLOAT:
if( p_item->f_min || p_item->f_max ) if( p_item->f_min || p_item->f_max )
fprintf( stderr, "Todo\n" ); p_control = new FloatRangeConfigControl( p_this, p_item, parent,
l, line );
else else
fprintf( stderr, "Todo\n" ); p_control = new FloatConfigControl( p_this, p_item, parent,
l, line );
break; break;
default: default:
break; break;
...@@ -323,6 +326,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this, ...@@ -323,6 +326,7 @@ IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
void IntegerConfigControl::finish() void IntegerConfigControl::finish()
{ {
spin->setMaximum( 2000000000 ); spin->setMaximum( 2000000000 );
spin->setMinimum( -2000000000 );
spin->setValue( p_item->i_value ); spin->setValue( p_item->i_value );
spin->setToolTip( qfu(p_item->psz_longtext) ); spin->setToolTip( qfu(p_item->psz_longtext) );
if( label ) if( label )
...@@ -334,6 +338,30 @@ int IntegerConfigControl::getValue() ...@@ -334,6 +338,30 @@ int IntegerConfigControl::getValue()
return spin->value(); return spin->value();
} }
/********* Integer range **********/
IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
IntegerConfigControl( _p_this, _p_item, _parent, l, line )
{
finish();
}
IntegerRangeConfigControl::IntegerRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label, QSpinBox *_spin ) :
IntegerConfigControl( _p_this, _p_item, _label, _spin )
{
finish();
}
void IntegerRangeConfigControl::finish()
{
spin->setMaximum( p_item->i_max );
spin->setMinimum( p_item->i_min );
}
/********* Integer / choice list **********/ /********* Integer / choice list **********/
IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this, IntegerListConfigControl::IntegerListConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, bool bycat, module_config_t *_p_item, QWidget *_parent, bool bycat,
...@@ -428,3 +456,84 @@ int BoolConfigControl::getValue() ...@@ -428,3 +456,84 @@ int BoolConfigControl::getValue()
{ {
return checkbox->checkState() == Qt::Checked ? VLC_TRUE : VLC_FALSE; return checkbox->checkState() == Qt::Checked ? VLC_TRUE : VLC_FALSE;
} }
/**************************************************************************
* Float-based controls
*************************************************************************/
/*********** Float **************/
FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
VFloatConfigControl( _p_this, _p_item, _parent )
{
label = new QLabel( qfu(p_item->psz_text) );
spin = new QDoubleSpinBox; spin->setMinimumWidth( 80 );
spin->setMaximumWidth( 90 );
finish();
if( !l )
{
QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( spin, 1 );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( spin, line, 1, Qt::AlignRight );
}
}
FloatConfigControl::FloatConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label,
QDoubleSpinBox *_spin ) :
VFloatConfigControl( _p_this, _p_item )
{
spin = _spin;
label = _label;
finish();
}
void FloatConfigControl::finish()
{
spin->setMaximum( 2000000000. );
spin->setMinimum( -2000000000. );
spin->setSingleStep( 0.1 );
spin->setValue( (double)p_item->f_value );
spin->setToolTip( qfu(p_item->psz_longtext) );
if( label )
label->setToolTip( qfu(p_item->psz_longtext) );
}
float FloatConfigControl::getValue()
{
return (float)spin->value();
}
/*********** Float with range **************/
FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QWidget *_parent, QGridLayout *l,
int line ) :
FloatConfigControl( _p_this, _p_item, _parent, l, line )
{
finish();
}
FloatRangeConfigControl::FloatRangeConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item,
QLabel *_label,
QDoubleSpinBox *_spin ) :
FloatConfigControl( _p_this, _p_item, _label, _spin )
{
finish();
}
void FloatRangeConfigControl::finish()
{
spin->setMaximum( (double)p_item->f_max );
spin->setMinimum( (double)p_item->f_min );
}
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <QWidget> #include <QWidget>
#include <QLineEdit> #include <QLineEdit>
#include <QSpinBox> #include <QSpinBox>
#include <QDoubleSpinBox>
#include <QComboBox> #include <QComboBox>
#include <QCheckBox> #include <QCheckBox>
#include "ui/input_stats.h" #include "ui/input_stats.h"
...@@ -95,12 +96,26 @@ public: ...@@ -95,12 +96,26 @@ public:
virtual int getValue(); virtual int getValue();
virtual void show() { spin->show(); label->show(); } virtual void show() { spin->show(); label->show(); }
virtual void hide() { spin->hide(); label->hide(); } virtual void hide() { spin->hide(); label->hide(); }
private:
protected:
QSpinBox *spin; QSpinBox *spin;
private:
QLabel *label; QLabel *label;
void finish(); void finish();
}; };
class IntegerRangeConfigControl : public IntegerConfigControl
{
public:
IntegerRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
IntegerRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* );
private:
void finish();
};
class IntegerListConfigControl : public VIntConfigControl class IntegerListConfigControl : public VIntConfigControl
{ {
public: public:
...@@ -148,6 +163,36 @@ public: ...@@ -148,6 +163,36 @@ public:
virtual float getValue() = 0; virtual float getValue() = 0;
}; };
class FloatConfigControl : public VFloatConfigControl
{
public:
FloatConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
FloatConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
virtual ~FloatConfigControl() {};
virtual float getValue();
virtual void show() { spin->show(); label->show(); }
virtual void hide() { spin->hide(); label->hide(); }
protected:
QDoubleSpinBox *spin;
private:
QLabel *label;
void finish();
};
class FloatRangeConfigControl : public FloatConfigControl
{
public:
FloatRangeConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
FloatRangeConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QDoubleSpinBox* );
private:
void finish();
};
#if 0 #if 0
class FloatConfigControl : public VFloatConfigControl class FloatConfigControl : public VFloatConfigControl
{ {
......
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