Commit cfaa0cb3 authored by zorglub's avatar zorglub
Browse files

Improved layout for preferences

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