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

Improve Qt preferences layout handling

parent 122fbea6
...@@ -37,35 +37,37 @@ PrefsDialog *PrefsDialog::instance = NULL; ...@@ -37,35 +37,37 @@ PrefsDialog *PrefsDialog::instance = NULL;
PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
layout = new QHBoxLayout(); QGridLayout *main_layout = new QGridLayout();
QVBoxLayout * main_layout = new QVBoxLayout();
setWindowTitle( qtr("Preferences" ) ); setWindowTitle( qtr("Preferences" ) );
resize( 800, 450 ); resize( 800, 450 );
advanced_tree = NULL; tree_panel = new QWidget;
simple_tree = NULL; tree_panel_l = new QHBoxLayout;
simple_panel = NULL; tree_panel->setLayout( tree_panel_l );
advanced_panel = NULL; main_panel = new QWidget;
main_panel_l = new QHBoxLayout;
vertical = new QVBoxLayout(); main_panel->setLayout( main_panel_l );
// Choice for types // Choice for types
types = new QGroupBox( "Show settings" ); types = new QGroupBox( "Show settings" );
QHBoxLayout *tl = new QHBoxLayout(); QHBoxLayout *tl = new QHBoxLayout();
tl->setSpacing( 3 ); tl->setMargin( 3 ); tl->setSpacing( 3 ); tl->setMargin( 3 );
small = new QRadioButton( "Basic", types ); small = new QRadioButton( "Basic", types ); tl->addWidget( small );
all = new QRadioButton( "All", types ); all = new QRadioButton( "All", types ); tl->addWidget( all );
tl->addWidget( small ); types->setLayout(tl);
tl->addWidget( all );
types->setLayout(tl );
layout->addLayout( vertical, 1 );
all->setChecked( true ); all->setChecked( true );
main_layout->addLayout( layout );
adv_chk = new QCheckBox("Advanced options"); adv_chk = new QCheckBox("Advanced options");
main_layout->addWidget( adv_chk );
advanced_tree = NULL;
simple_tree = NULL;
simple_panel = NULL;
advanced_panel = NULL;
main_layout->addLayout( tl, 0,0,1,1 );
main_layout->addWidget( tree_panel, 1,0,1,1 );
main_layout->addWidget( adv_chk , 2,0,1,1 );
main_layout->addWidget( main_panel, 0, 1, 3, 1 );
setAll(); setAll();
...@@ -85,9 +87,11 @@ void PrefsDialog::setAdvanced( bool advanced ) ...@@ -85,9 +87,11 @@ void PrefsDialog::setAdvanced( bool advanced )
void PrefsDialog::setAll() void PrefsDialog::setAll()
{ {
while( (vertical->takeAt(0)) != 0 ) {}
if( simple_tree ) if( simple_tree )
{
tree_panel_l->removeWidget( simple_tree );
simple_tree->hide(); simple_tree->hide();
}
if( !advanced_tree ) if( !advanced_tree )
{ {
...@@ -96,42 +100,42 @@ void PrefsDialog::setAll() ...@@ -96,42 +100,42 @@ void PrefsDialog::setAll()
SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ), SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ),
this, SLOT( changePanel( QTreeWidgetItem * ) ) ); this, SLOT( changePanel( QTreeWidgetItem * ) ) );
} }
tree_panel_l->addWidget( advanced_tree );
advanced_tree->show(); advanced_tree->show();
setAdvanced( adv_chk->isChecked() );
vertical->addWidget( types );
vertical->addWidget( advanced_tree );
if( layout->count() == 2 ) if( simple_panel )
layout->takeAt(1); {
main_panel_l->removeWidget( simple_panel );
if( !advanced_panel ) simple_panel->hide();
}
if( !advanced_panel )
advanced_panel = new PrefsPanel( this ); advanced_panel = new PrefsPanel( this );
layout->addWidget( advanced_panel, 3 ) ; main_panel_l->addWidget( advanced_panel );
advanced_panel->show();
setAdvanced( adv_chk->isChecked() );
} }
void PrefsDialog::setSmall() void PrefsDialog::setSmall()
{ {
while( (vertical->takeAt(0)) != 0 ) {}
if( advanced_tree ) if( advanced_tree )
{
tree_panel_l->removeWidget( advanced_tree );
advanced_tree->hide(); advanced_tree->hide();
}
if( !simple_tree ) if( !simple_tree )
simple_tree = new QTreeWidget(); simple_tree = new QTreeWidget();
tree_panel_l->addWidget( simple_tree );
simple_tree->show(); simple_tree->show();
vertical->addWidget( types );
vertical->addWidget( simple_tree );
if( layout->count() == 2 )
layout->takeAt(1);
if( advanced_panel )
{
main_panel_l->removeWidget( advanced_panel );
advanced_panel->hide();
}
if( !simple_panel ) if( !simple_panel )
simple_panel = new QWidget(); simple_panel = new QWidget();
layout->addWidget( simple_panel, 3 ) ; main_panel_l->addWidget( simple_panel );
} simple_panel->show();
void PrefsDialog::init()
{
} }
PrefsDialog::~PrefsDialog() PrefsDialog::~PrefsDialog()
...@@ -144,7 +148,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -144,7 +148,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
if( advanced_panel ) if( advanced_panel )
{ {
layout->removeWidget( advanced_panel ); main_panel_l->removeWidget( advanced_panel );
advanced_panel->hide(); advanced_panel->hide();
} }
if( !data->panel ) if( !data->panel )
...@@ -152,8 +156,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -152,8 +156,7 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
data->panel = new PrefsPanel( p_intf, this, data ); data->panel = new PrefsPanel( p_intf, this, data );
} }
advanced_panel = data->panel; advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel );
advanced_panel->show(); advanced_panel->show();
setAdvanced( adv_chk->isChecked() ); setAdvanced( adv_chk->isChecked() );
layout->addWidget( advanced_panel, 3 );
} }
...@@ -44,28 +44,28 @@ public: ...@@ -44,28 +44,28 @@ public:
static PrefsDialog * getInstance( intf_thread_t *_p_intf ) static PrefsDialog * getInstance( intf_thread_t *_p_intf )
{ {
if( !instance ) if( !instance )
{
instance = new PrefsDialog( _p_intf ); instance = new PrefsDialog( _p_intf );
instance->init();
}
return instance; return instance;
} }
virtual ~PrefsDialog(); virtual ~PrefsDialog();
private: private:
PrefsDialog( intf_thread_t * ); PrefsDialog( intf_thread_t * );
void init();
QWidget *main_panel;
QHBoxLayout *main_panel_l;
PrefsPanel *advanced_panel; PrefsPanel *advanced_panel;
PrefsTree *advanced_tree;
QWidget *simple_panel; QWidget *simple_panel;
QWidget *tree_panel;
QHBoxLayout *tree_panel_l;
QTreeWidget *simple_tree; QTreeWidget *simple_tree;
PrefsTree *advanced_tree;
QGroupBox *types; QGroupBox *types;
// The layout for the main part
QHBoxLayout *layout;
// Layout for the left pane
QVBoxLayout *vertical;
QRadioButton *small,*all; QRadioButton *small,*all;
QCheckBox *adv_chk; QCheckBox *adv_chk;
QGridLayout *main_layout;
static PrefsDialog *instance; static PrefsDialog *instance;
private slots: private slots:
......
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