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

Improved layout for preferences

parent 21ab0e41
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <QScrollArea> #include <QScrollArea>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QGridLayout>
#include <QHeaderView> #include <QHeaderView>
#define ITEM_HEIGHT 25 #define ITEM_HEIGHT 25
...@@ -414,13 +415,14 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -414,13 +415,14 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
global_layout->addWidget( help ); global_layout->addWidget( help );
QGroupBox *box = NULL; QGroupBox *box = NULL;
QVBoxLayout *boxlayout = NULL; QGridLayout *boxlayout = NULL;
QScrollArea *scroller= new QScrollArea; QScrollArea *scroller= new QScrollArea;
scroller->setFrameStyle( QFrame::NoFrame ); scroller->setFrameStyle( QFrame::NoFrame );
QWidget *scrolled_area = new QWidget; QWidget *scrolled_area = new QWidget;
QVBoxLayout *layout = new QVBoxLayout(); QGridLayout *layout = new QGridLayout();
int i_line = 0, i_boxline = 0;
if( p_item ) do if( p_item ) do
{ {
...@@ -438,24 +440,29 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -438,24 +440,29 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
if( box ) if( box )
{ {
box->setLayout( boxlayout ); box->setLayout( boxlayout );
layout->addWidget( box, 1 ); layout->addWidget( box, i_line, 0, 1, 2 );
i_line++;
} }
box = new QGroupBox( qfu(p_item->psz_text) ); box = new QGroupBox( qfu(p_item->psz_text) );
boxlayout = new QVBoxLayout(); boxlayout = new QGridLayout();
}
ConfigControl *control;
if( ! box )
{
control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
p_item, NULL, layout, i_line );
}
else
{
control = ConfigControl::createControl( VLC_OBJECT( p_intf ),
p_item, NULL, boxlayout, i_boxline );
} }
ConfigControl *control = ConfigControl::createControl(
VLC_OBJECT( p_intf ), p_item,
NULL );
if( !control ) if( !control )
{ {
continue; continue;
} }
if( !box ) if( box ) i_boxline++;
layout->addWidget( control->getWidget() ); else i_line++;
else
boxlayout->addWidget( control->getWidget() );
controls.append( control ); controls.append( control );
} }
while( !(p_item->i_type == CONFIG_HINT_END || while( !(p_item->i_type == CONFIG_HINT_END ||
...@@ -467,7 +474,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -467,7 +474,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
if( box ) if( box )
{ {
box->setLayout( boxlayout ); box->setLayout( boxlayout );
layout->addWidget( box, 1 ); layout->addWidget( box, i_line, 0, 1, 2 );
} }
vlc_object_release( p_module ); vlc_object_release( p_module );
...@@ -527,8 +534,13 @@ void PrefsPanel::setAdvanced( bool adv, bool force ) ...@@ -527,8 +534,13 @@ void PrefsPanel::setAdvanced( bool adv, bool force )
{ {
if( (*i)->isAdvanced() ) if( (*i)->isAdvanced() )
{ {
if( !advanced ) some_hidden = true; if( !advanced )
(*i)->getWidget()->setVisible( advanced ); {
some_hidden = true;
(*i)->hide();
}
else
(*i)->show();
} }
} }
if( some_hidden_text ) if( some_hidden_text )
......
...@@ -38,10 +38,19 @@ ...@@ -38,10 +38,19 @@
#include <QDoubleSpinBox> #include <QDoubleSpinBox>
#include <QVariant> #include <QVariant>
#include <QComboBox> #include <QComboBox>
#include <QGridLayout>
ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
module_config_t *p_item, module_config_t *p_item,
QWidget *parent ) QWidget *parent )
{
return createControl( p_this, p_item, parent, NULL, 0 );
}
ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
module_config_t *p_item,
QWidget *parent,
QGridLayout *l, int line )
{ {
ConfigControl *p_control = NULL; ConfigControl *p_control = NULL;
if( p_item->psz_current ) return NULL; if( p_item->psz_current ) return NULL;
...@@ -49,14 +58,17 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -49,14 +58,17 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
switch( p_item->i_type ) switch( p_item->i_type )
{ {
case CONFIG_ITEM_MODULE: case CONFIG_ITEM_MODULE:
p_control = new ModuleConfigControl( p_this, p_item, parent, false ); p_control = new ModuleConfigControl( p_this, p_item, parent, false,
l, line );
break; break;
case CONFIG_ITEM_MODULE_CAT: case CONFIG_ITEM_MODULE_CAT:
p_control = new ModuleConfigControl( p_this, p_item, parent, true ); p_control = new ModuleConfigControl( p_this, p_item, parent, true,
l, line );
break; break;
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
if( !p_item->i_list ) if( !p_item->i_list )
p_control = new StringConfigControl( p_this, p_item, parent,false ); p_control = new StringConfigControl( p_this, p_item, parent,
l, line, false );
else else
fprintf(stderr, "TODO\n" ); fprintf(stderr, "TODO\n" );
break; break;
...@@ -66,7 +78,8 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -66,7 +78,8 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
else if( p_item->i_min || p_item->i_max ) else if( p_item->i_min || p_item->i_max )
fprintf( stderr, "Todo\n" ); fprintf( stderr, "Todo\n" );
else else
p_control = new IntegerConfigControl( p_this, p_item, parent ); p_control = new IntegerConfigControl( p_this, p_item, parent,
l, line );
break; break;
default: default:
break; break;
...@@ -81,28 +94,37 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this, ...@@ -81,28 +94,37 @@ ConfigControl *ConfigControl::createControl( vlc_object_t *p_this,
/*********** String **************/ /*********** String **************/
StringConfigControl::StringConfigControl( vlc_object_t *_p_this, StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
QWidget *_parent, bool pwd ) : QWidget *_parent, QGridLayout *l,
int line, bool pwd ) :
VStringConfigControl( _p_this, _p_item, _parent ) VStringConfigControl( _p_this, _p_item, _parent )
{ {
QLabel *label = new QLabel( qfu(p_item->psz_text) ); label = new QLabel( qfu(p_item->psz_text) );
text = new QLineEdit( qfu(p_item->psz_value) ); text = new QLineEdit( qfu(p_item->psz_value) );
finish(label); finish();
QHBoxLayout *layout = new QHBoxLayout(); if( !l )
layout->addWidget( label, 0 ); layout->addWidget( text, 1 ); {
widget->setLayout( layout ); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label, 0 ); layout->addWidget( text, 1 );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 ); l->addWidget( text, line, 1 );
}
} }
StringConfigControl::StringConfigControl( vlc_object_t *_p_this, StringConfigControl::StringConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
QLabel *label, QLineEdit *_text, bool pwd ): QLabel *_label, QLineEdit *_text, bool pwd ):
VStringConfigControl( _p_this, _p_item ) VStringConfigControl( _p_this, _p_item )
{ {
text = _text; text = _text;
finish( label ); label = _label;
finish( );
} }
void StringConfigControl::finish( QLabel *label ) void StringConfigControl::finish()
{ {
text->setText( qfu(p_item->psz_value) ); text->setText( qfu(p_item->psz_value) );
text->setToolTip( qfu(p_item->psz_longtext) ); text->setToolTip( qfu(p_item->psz_longtext) );
...@@ -111,25 +133,35 @@ void StringConfigControl::finish( QLabel *label ) ...@@ -111,25 +133,35 @@ void StringConfigControl::finish( QLabel *label )
/********* Module **********/ /********* Module **********/
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QWidget *_parent, module_config_t *_p_item, QWidget *_parent, bool bycat,
bool bycat ) : VStringConfigControl( _p_this, _p_item, _parent ) QGridLayout *l, int line) :
VStringConfigControl( _p_this, _p_item, _parent )
{ {
QLabel *label = new QLabel( qfu(p_item->psz_text) ); label = new QLabel( qfu(p_item->psz_text) );
combo = new QComboBox(); combo = new QComboBox();
finish( label, bycat ); finish( bycat );
QHBoxLayout *layout = new QHBoxLayout(); if( !l )
layout->addWidget( label ); layout->addWidget( combo ); {
widget->setLayout( layout ); QHBoxLayout *layout = new QHBoxLayout();
layout->addWidget( label ); layout->addWidget( combo );
widget->setLayout( layout );
}
else
{
l->addWidget( label, line, 0 );
l->addWidget( combo, line, 1, Qt::AlignRight );
}
} }
ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this, ModuleConfigControl::ModuleConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, QLabel *label, QComboBox *_combo, module_config_t *_p_item, QLabel *_label, QComboBox *_combo,
bool bycat ) : VStringConfigControl( _p_this, _p_item ) bool bycat ) : VStringConfigControl( _p_this, _p_item )
{ {
combo = _combo; combo = _combo;
finish( label, bycat ); label = _label;
finish( bycat );
} }
void ModuleConfigControl::finish( QLabel *label, bool bycat ) void ModuleConfigControl::finish( bool bycat )
{ {
vlc_list_t *p_list; vlc_list_t *p_list;
module_t *p_parser; module_t *p_parser;
...@@ -186,28 +218,40 @@ QString ModuleConfigControl::getValue() ...@@ -186,28 +218,40 @@ QString ModuleConfigControl::getValue()
/*********** Integer **************/ /*********** Integer **************/
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this, IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
QWidget *_parent ) : QWidget *_parent, QGridLayout *l,
int line ) :
VIntConfigControl( _p_this, _p_item, _parent ) VIntConfigControl( _p_this, _p_item, _parent )
{ {
QLabel *label = new QLabel( qfu(p_item->psz_text) ); label = new QLabel( qfu(p_item->psz_text) );
spin = new QSpinBox; spin = new QSpinBox; spin->setMinimumWidth( 80 );
finish( label ); spin->setMaximumWidth( 90 );
finish();
QHBoxLayout *layout = new QHBoxLayout(); if( !l )
layout->addWidget( label, 0 ); layout->addWidget( spin, 1 ); {
widget->setLayout( layout ); 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 );
}
} }
IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this, IntegerConfigControl::IntegerConfigControl( vlc_object_t *_p_this,
module_config_t *_p_item, module_config_t *_p_item,
QLabel *label, QSpinBox *_spin ) : QLabel *_label, QSpinBox *_spin ) :
VIntConfigControl( _p_this, _p_item ) VIntConfigControl( _p_this, _p_item )
{ {
spin = _spin; spin = _spin;
finish(label); label = _label;
finish();
} }
void IntegerConfigControl::finish( QLabel *label ) void IntegerConfigControl::finish()
{ {
spin->setMaximum( 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) );
label->setToolTip( qfu(p_item->psz_longtext) ); label->setToolTip( qfu(p_item->psz_longtext) );
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <QWidget> #include <QWidget>
#include <QLineEdit> #include <QLineEdit>
#include <QSpinBox>
#include <QComboBox>
#include "ui/input_stats.h" #include "ui/input_stats.h"
#include "qt4.hpp" #include "qt4.hpp"
#include <assert.h> #include <assert.h>
...@@ -53,9 +55,14 @@ public: ...@@ -53,9 +55,14 @@ public:
QString getName() { return qfu( p_item->psz_name ); } QString getName() { return qfu( p_item->psz_name ); }
QWidget *getWidget() { assert( widget ); return widget; } QWidget *getWidget() { assert( widget ); return widget; }
bool isAdvanced() { return p_item->b_advanced; } bool isAdvanced() { return p_item->b_advanced; }
virtual void hide() { getWidget()->hide(); };
virtual void show() { getWidget()->show(); };
static ConfigControl * createControl( vlc_object_t*, static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget* ); module_config_t*,QWidget* );
static ConfigControl * createControl( vlc_object_t*,
module_config_t*,QWidget*,
QGridLayout *, int);
protected: protected:
vlc_object_t *p_this; vlc_object_t *p_this;
module_config_t *p_item; module_config_t *p_item;
...@@ -83,14 +90,18 @@ public: ...@@ -83,14 +90,18 @@ public:
class IntegerConfigControl : public VIntConfigControl class IntegerConfigControl : public VIntConfigControl
{ {
public: public:
IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget * ); IntegerConfigControl( vlc_object_t *, module_config_t *, QWidget *,
QGridLayout *, int );
IntegerConfigControl( vlc_object_t *, module_config_t *, IntegerConfigControl( vlc_object_t *, module_config_t *,
QLabel*, QSpinBox* ); QLabel*, QSpinBox* );
virtual ~IntegerConfigControl() {}; virtual ~IntegerConfigControl() {};
virtual int getValue(); virtual int getValue();
virtual void show() { spin->show(); label->show(); }
virtual void hide() { spin->hide(); label->hide(); }
private: private:
QSpinBox *spin; QSpinBox *spin;
void finish( QLabel * ); QLabel *label;
void finish();
}; };
#if 0 #if 0
...@@ -150,27 +161,33 @@ class StringConfigControl : public VStringConfigControl ...@@ -150,27 +161,33 @@ class StringConfigControl : public VStringConfigControl
{ {
public: public:
StringConfigControl( vlc_object_t *, module_config_t *, QWidget *, StringConfigControl( vlc_object_t *, module_config_t *, QWidget *,
bool pwd ); QGridLayout *, int, bool pwd );
StringConfigControl( vlc_object_t *, module_config_t *, QLabel *, StringConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QLineEdit*, bool pwd ); QLineEdit*, bool pwd );
virtual ~StringConfigControl() {}; virtual ~StringConfigControl() {};
virtual QString getValue() { return text->text(); }; virtual QString getValue() { return text->text(); };
virtual void show() { text->show(); label->show(); }
virtual void hide() { text->hide(); label->hide(); }
private: private:
void finish( QLabel * ); void finish();
QLineEdit *text; QLineEdit *text;
QLabel *label;
}; };
class ModuleConfigControl : public VStringConfigControl class ModuleConfigControl : public VStringConfigControl
{ {
public: public:
ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool ModuleConfigControl( vlc_object_t *, module_config_t *, QWidget *, bool,
bycat ); QGridLayout*, int );
ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *, ModuleConfigControl( vlc_object_t *, module_config_t *, QLabel *,
QComboBox*, bool ); QComboBox*, bool );
virtual ~ModuleConfigControl() {}; virtual ~ModuleConfigControl() {};
virtual QString getValue(); virtual QString getValue();
virtual void hide() { combo->hide(); label->hide(); }
virtual void show() { combo->show(); label->show(); }
private: private:
void finish( QLabel *, bool ); void finish( bool );
QLabel *label;
QComboBox *combo; QComboBox *combo;
}; };
#if 0 #if 0
......
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