Commit d4af177c authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: preferences: use StackedWidget for main layout

parent 2859c5db
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <QPushButton> #include <QPushButton>
#include <QMessageBox> #include <QMessageBox>
#include <QDialogButtonBox> #include <QDialogButtonBox>
#include <QStackedWidget>
PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
: QVLCDialog( parent, _p_intf ) : QVLCDialog( parent, _p_intf )
...@@ -55,12 +56,17 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -55,12 +56,17 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
setAttribute( Qt::WA_DeleteOnClose ); setAttribute( Qt::WA_DeleteOnClose );
/* Create Panels */ /* Create Panels */
tree_panel = new QWidget; simple_tree_panel = new QWidget;
tree_panel_l = new QVBoxLayout; simple_tree_panel->setLayout( new QVBoxLayout );
tree_panel->setLayout( tree_panel_l );
main_panel = new QWidget; advanced_tree_panel = new QWidget;
main_panel_l = new QHBoxLayout; advanced_tree_panel->setLayout( new QVBoxLayout );
main_panel->setLayout( main_panel_l );
simple_main_panel = new QWidget;
simple_main_panel->setLayout( new QHBoxLayout );
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") );
...@@ -93,26 +99,36 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -93,26 +99,36 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole ); buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole );
buttonsBox->addButton( reset, QDialogButtonBox::ResetRole ); buttonsBox->addButton( reset, QDialogButtonBox::ResetRole );
simple_split_widget = new QWidget();
simple_split_widget->setLayout( new QHBoxLayout );
advanced_split_widget = new QWidget();
advanced_split_widget->setLayout( new QHBoxLayout );
stack = new QStackedWidget();
stack->insertWidget( SIMPLE, simple_split_widget );
stack->insertWidget( ADVANCED, advanced_split_widget );
simple_split_widget->layout()->addWidget( simple_tree_panel );
simple_split_widget->layout()->addWidget( simple_main_panel );
simple_split_widget->layout()->setMargin( 0 );
advanced_split_widget->layout()->addWidget( advanced_tree_panel );
advanced_split_widget->layout()->addWidget( advanced_main_panel );
advanced_split_widget->layout()->setMargin( 0 );
/* Layout */ /* Layout */
main_layout->addWidget( tree_panel, 0, 0, 3, 1 ); main_layout->addWidget( stack, 0, 0, 3, 3 );
main_layout->addWidget( types, 3, 0, 2, 1 ); main_layout->addWidget( types, 3, 0, 2, 1 );
main_layout->addWidget( main_panel, 0, 1, 4, 2 );
main_layout->addWidget( buttonsBox, 4, 2, 1 ,1 ); main_layout->addWidget( buttonsBox, 4, 2, 1 ,1 );
main_layout->setColumnMinimumWidth( 0, 150 );
main_layout->setColumnMinimumWidth( 1, 10 );
main_layout->setColumnStretch( 0, 1 );
main_layout->setColumnStretch( 1, 0 );
main_layout->setColumnStretch( 2, 10 );
main_layout->setRowStretch( 2, 4 ); main_layout->setRowStretch( 2, 4 );
main_layout->setMargin( 9 ); main_layout->setMargin( 9 );
setLayout( main_layout ); setLayout( main_layout );
/* Margins */ /* Margins */
tree_panel_l->setMargin( 1 ); simple_tree_panel->layout()->setMargin( 1 );
main_panel_l->setContentsMargins( 6, 0, 0, 3 ); simple_main_panel->layout()->setContentsMargins( 6, 0, 0, 3 );
b_small = (p_intf->p_sys->i_screenHeight < 750); b_small = (p_intf->p_sys->i_screenHeight < 750);
if( b_small ) msg_Dbg( p_intf, "Small Resolution"); if( b_small ) msg_Dbg( p_intf, "Small Resolution");
...@@ -137,49 +153,36 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) ...@@ -137,49 +153,36 @@ PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf )
void PrefsDialog::setAdvanced() void PrefsDialog::setAdvanced()
{ {
/* We already have a simple TREE, and we just want to hide it */
if( simple_tree )
if( simple_tree->isVisible() ) simple_tree->hide();
if ( !tree_filter ) if ( !tree_filter )
{ {
tree_filter = new SearchLineEdit( tree_panel ); tree_filter = new SearchLineEdit( simple_tree_panel );
tree_filter->setMinimumHeight( 26 ); tree_filter->setMinimumHeight( 26 );
CONNECT( tree_filter, textChanged( const QString & ), CONNECT( tree_filter, textChanged( const QString & ),
this, advancedTreeFilterChanged( const QString & ) ); this, advancedTreeFilterChanged( const QString & ) );
tree_panel_l->addWidget( tree_filter ); advanced_tree_panel->layout()->addWidget( tree_filter );
} }
tree_filter->show();
/* If don't have already and advanced TREE, then create it */ /* If don't have already and advanced TREE, then create it */
if( !advanced_tree ) if( !advanced_tree )
{ {
/* Creation */ /* Creation */
advanced_tree = new PrefsTree( p_intf, tree_panel ); advanced_tree = new PrefsTree( p_intf, simple_tree_panel );
/* and connections */ /* and connections */
CONNECT( advanced_tree, CONNECT( advanced_tree,
currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * ), currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * ),
this, changeAdvPanel( QTreeWidgetItem * ) ); this, changeAdvPanel( QTreeWidgetItem * ) );
tree_panel_l->addWidget( advanced_tree ); advanced_tree_panel->layout()->addWidget( advanced_tree );
advanced_tree_panel->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
} }
/* Show it */
advanced_tree->show();
/* Remove the simple current panel from the main panels*/
if( current_simple_panel )
if( current_simple_panel->isVisible() ) current_simple_panel->hide();
/* 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_panel )
{ {
advanced_panel = new AdvPrefsPanel( main_panel ); advanced_panel = new AdvPrefsPanel( simple_main_panel );
main_panel_l->addWidget( advanced_panel ); advanced_main_panel->layout()->addWidget( advanced_panel );
} }
advanced_panel->show();
/* 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
category... */ category... */
...@@ -187,44 +190,33 @@ void PrefsDialog::setAdvanced() ...@@ -187,44 +190,33 @@ void PrefsDialog::setAdvanced()
advanced_tree->model()->index( 0, 0, QModelIndex() ) ); advanced_tree->model()->index( 0, 0, QModelIndex() ) );
all->setChecked( true ); all->setChecked( true );
stack->setCurrentIndex( ADVANCED );
} }
void PrefsDialog::setSmall() void PrefsDialog::setSmall()
{ {
/* If an advanced TREE exists, remove and hide it */
if( advanced_tree )
if( advanced_tree->isVisible() ) advanced_tree->hide();
if( tree_filter )
if( tree_filter->isVisible() ) tree_filter->hide();
/* If no simple_tree, create one, connect it */ /* If no simple_tree, create one, connect it */
if( !simple_tree ) if( !simple_tree )
{ {
simple_tree = new SPrefsCatList( p_intf, tree_panel, b_small ); simple_tree = new SPrefsCatList( p_intf, simple_tree_panel, b_small );
CONNECT( simple_tree, CONNECT( simple_tree,
currentItemChanged( int ), currentItemChanged( int ),
this, changeSimplePanel( int ) ); this, changeSimplePanel( int ) );
tree_panel_l->addWidget( simple_tree ); simple_tree_panel->layout()->addWidget( simple_tree );
simple_tree_panel->setMinimumSize( QSize( 150, 0 ) );
simple_tree_panel->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
} }
/*show it */
simple_tree->show();
/* If an Advanced PANEL exists, remove it */
if( advanced_panel )
if( advanced_panel->isVisible() ) advanced_panel->hide();
if( !current_simple_panel ) if( !current_simple_panel )
{ {
current_simple_panel = current_simple_panel =
new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat, b_small ); new SPrefsPanel( p_intf, simple_main_panel, SPrefsDefaultCat, b_small );
simple_panels[SPrefsDefaultCat] = current_simple_panel; simple_panels[SPrefsDefaultCat] = current_simple_panel;
main_panel_l->addWidget( current_simple_panel ); simple_main_panel->layout()->addWidget( current_simple_panel );
} }
current_simple_panel->show();
small->setChecked( true ); small->setChecked( true );
stack->setCurrentIndex( SIMPLE );
} }
/* Switching from on simple panel to another */ /* Switching from on simple panel to another */
...@@ -236,9 +228,9 @@ void PrefsDialog::changeSimplePanel( int number ) ...@@ -236,9 +228,9 @@ void PrefsDialog::changeSimplePanel( int number )
current_simple_panel = simple_panels[number]; current_simple_panel = simple_panels[number];
if( !current_simple_panel ) if( !current_simple_panel )
{ {
current_simple_panel = new SPrefsPanel( p_intf, main_panel, number, b_small ); current_simple_panel = new SPrefsPanel( p_intf, simple_main_panel, number, b_small );
simple_panels[number] = current_simple_panel; simple_panels[number] = current_simple_panel;
main_panel_l->addWidget( current_simple_panel ); simple_main_panel->layout()->addWidget( current_simple_panel );
} }
current_simple_panel->show(); current_simple_panel->show();
...@@ -255,8 +247,8 @@ void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item ) ...@@ -255,8 +247,8 @@ void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item )
if( !data->panel ) if( !data->panel )
{ {
data->panel = new AdvPrefsPanel( p_intf, main_panel , data ); data->panel = new AdvPrefsPanel( p_intf, simple_main_panel , data );
main_panel_l->addWidget( data->panel ); advanced_main_panel->layout()->addWidget( data->panel );
} }
advanced_panel = data->panel; advanced_panel = data->panel;
......
...@@ -33,14 +33,13 @@ class AdvPrefsPanel; ...@@ -33,14 +33,13 @@ class AdvPrefsPanel;
class SPrefsPanel; class SPrefsPanel;
class QTreeWidgetItem; class QTreeWidgetItem;
class QTreeWidget; class QTreeWidget;
class QHBoxLayout;
class QVBoxLayout;
class QGroupBox; class QGroupBox;
class QRadioButton; class QRadioButton;
class QWidget; class QWidget;
class QCheckBox; class QCheckBox;
class QLabel; class QLabel;
class SearchLineEdit; class SearchLineEdit;
class QStackedWidget;
class PrefsDialog : public QVLCDialog class PrefsDialog : public QVLCDialog
{ {
...@@ -54,15 +53,18 @@ public: ...@@ -54,15 +53,18 @@ public:
#endif #endif
private: private:
QWidget *main_panel; enum { SIMPLE, ADVANCED };
QHBoxLayout *main_panel_l; QStackedWidget *stack;
QWidget *simple_main_panel, *advanced_main_panel;
QWidget *simple_split_widget, *advanced_split_widget;
AdvPrefsPanel *advanced_panel; AdvPrefsPanel *advanced_panel;
SPrefsPanel *current_simple_panel; SPrefsPanel *current_simple_panel;
SPrefsPanel *simple_panels[SPrefsMax]; SPrefsPanel *simple_panels[SPrefsMax];
QWidget *tree_panel; QWidget *simple_tree_panel;
QVBoxLayout *tree_panel_l; QWidget *advanced_tree_panel;
SPrefsCatList *simple_tree; SPrefsCatList *simple_tree;
PrefsTree *advanced_tree; PrefsTree *advanced_tree;
......
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