Commit e66c5af1 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: preferences: use StackedWidget for advanced layout

parent 46d15dba
...@@ -62,9 +62,6 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -62,9 +62,6 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
advanced_tree_panel = new QWidget; advanced_tree_panel = new QWidget;
advanced_tree_panel->setLayout( new QVBoxLayout ); advanced_tree_panel->setLayout( new QVBoxLayout );
advanced_main_panel = new QWidget;
advanced_main_panel->setLayout( new QHBoxLayout );
/* Choice for types */ /* Choice for types */
types = new QGroupBox( qtr("Show settings") ); types = new QGroupBox( qtr("Show settings") );
types->setAlignment( Qt::AlignHCenter ); types->setAlignment( Qt::AlignHCenter );
...@@ -83,7 +80,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -83,7 +80,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
tree_filter = NULL; tree_filter = NULL;
simple_tree = NULL; simple_tree = NULL;
simple_panels_stack = new QStackedWidget; simple_panels_stack = new QStackedWidget;
advanced_panel = NULL; advanced_panels_stack = new QStackedWidget;
/* Buttons */ /* Buttons */
QDialogButtonBox *buttonsBox = new QDialogButtonBox(); QDialogButtonBox *buttonsBox = new QDialogButtonBox();
...@@ -112,7 +109,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -112,7 +109,7 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
simple_split_widget->layout()->setMargin( 0 ); simple_split_widget->layout()->setMargin( 0 );
advanced_split_widget->layout()->addWidget( advanced_tree_panel ); advanced_split_widget->layout()->addWidget( advanced_tree_panel );
advanced_split_widget->layout()->addWidget( advanced_main_panel ); advanced_split_widget->layout()->addWidget( advanced_panels_stack );
advanced_split_widget->layout()->setMargin( 0 ); advanced_split_widget->layout()->setMargin( 0 );
/* Layout */ /* Layout */
...@@ -175,10 +172,10 @@ void PrefsDialog::setAdvanced() ...@@ -175,10 +172,10 @@ void PrefsDialog::setAdvanced()
} }
/* If no advanced Panel exist, create one, attach it and show it*/ /* If no advanced Panel exist, create one, attach it and show it*/
if( !advanced_panel ) if( advanced_panels_stack->count() < 1 )
{ {
advanced_panel = new AdvPrefsPanel( advanced_main_panel ); AdvPrefsPanel *insert = new AdvPrefsPanel( advanced_panels_stack );
advanced_main_panel->layout()->addWidget( advanced_panel ); advanced_panels_stack->insertWidget( 0, insert );
} }
/* Select the first Item of the preferences. Maybe you want to select a specified /* Select the first Item of the preferences. Maybe you want to select a specified
...@@ -229,17 +226,13 @@ void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item ) ...@@ -229,17 +226,13 @@ void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item )
if( item == NULL ) return; if( item == NULL ) return;
PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>(); PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
if( advanced_panel )
if( advanced_panel->isVisible() ) advanced_panel->hide();
if( !data->panel ) if( !data->panel )
{ {
data->panel = new AdvPrefsPanel( p_intf, advanced_main_panel, data ); data->panel = new AdvPrefsPanel( p_intf, advanced_panels_stack, data );
advanced_main_panel->layout()->addWidget( data->panel ); advanced_panels_stack->insertWidget( advanced_panels_stack->count(),
data->panel );
} }
advanced_panels_stack->setCurrentWidget( data->panel );
advanced_panel = data->panel;
advanced_panel->show();
} }
#if 0 #if 0
......
...@@ -56,10 +56,9 @@ private: ...@@ -56,10 +56,9 @@ private:
enum { SIMPLE, ADVANCED }; enum { SIMPLE, ADVANCED };
QStackedWidget *stack; QStackedWidget *stack;
QWidget *advanced_main_panel;
QWidget *simple_split_widget, *advanced_split_widget; QWidget *simple_split_widget, *advanced_split_widget;
AdvPrefsPanel *advanced_panel; QStackedWidget *advanced_panels_stack;
QStackedWidget *simple_panels_stack; QStackedWidget *simple_panels_stack;
SPrefsPanel *simple_panels[SPrefsMax]; SPrefsPanel *simple_panels[SPrefsMax];
......
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