Commit 4016a1a0 authored by Clément Stenac's avatar Clément Stenac

Fix flickering of panels in preferences

parent a8b27f21
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QScrollArea> #include <QScrollArea>
#include <QVBoxLayout> #include <QVBoxLayout>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QHeaderView>
#define ITEM_HEIGHT 25 #define ITEM_HEIGHT 25
...@@ -62,6 +63,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) : ...@@ -62,6 +63,7 @@ PrefsTree::PrefsTree( intf_thread_t *_p_intf, QWidget *_parent ) :
setColumnCount( 1 ); setColumnCount( 1 );
setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) ); setIconSize( QSize( ITEM_HEIGHT,ITEM_HEIGHT ) );
setAlternatingRowColors( true ); setAlternatingRowColors( true );
header()->hide();
#ifndef WIN32 #ifndef WIN32
// Fixme - A bit UGLY // Fixme - A bit UGLY
...@@ -320,7 +322,7 @@ PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent ) ...@@ -320,7 +322,7 @@ PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent )
{} {}
PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
PrefsItemData * data ) : PrefsItemData * data, bool currently_advanced ) :
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
module_config_t *p_item; module_config_t *p_item;
...@@ -480,7 +482,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -480,7 +482,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
some_hidden_text->setWordWrap( true ); some_hidden_text->setWordWrap( true );
setLayout( global_layout ); setLayout( global_layout );
setAdvanced( false ); setAdvanced( currently_advanced, true );
} }
void PrefsPanel::Apply() void PrefsPanel::Apply()
...@@ -514,10 +516,10 @@ void PrefsPanel::Apply() ...@@ -514,10 +516,10 @@ void PrefsPanel::Apply()
void PrefsPanel::Clean() void PrefsPanel::Clean()
{} {}
void PrefsPanel::setAdvanced( bool adv ) void PrefsPanel::setAdvanced( bool adv, bool force )
{ {
bool some_hidden = false; bool some_hidden = false;
if( adv == advanced ) return; if( !force && adv == advanced ) return;
advanced = adv; advanced = adv;
QList<ConfigControl *>::Iterator i; QList<ConfigControl *>::Iterator i;
......
...@@ -78,7 +78,7 @@ class PrefsPanel : public QWidget ...@@ -78,7 +78,7 @@ class PrefsPanel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData * ); PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData *, bool );
PrefsPanel( QWidget *); PrefsPanel( QWidget *);
virtual ~PrefsPanel() {}; virtual ~PrefsPanel() {};
void Apply(); void Apply();
...@@ -90,7 +90,8 @@ private: ...@@ -90,7 +90,8 @@ private:
QVBoxLayout *global_layout; QVBoxLayout *global_layout;
bool advanced; bool advanced;
public slots: public slots:
void setAdvanced( bool ); void setAdvanced( bool, bool );
void setAdvanced( bool a ) { return setAdvanced( a, false ); }
}; };
#endif #endif
...@@ -37,20 +37,20 @@ PrefsDialog *PrefsDialog::instance = NULL; ...@@ -37,20 +37,20 @@ PrefsDialog *PrefsDialog::instance = NULL;
PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
{ {
QGridLayout *main_layout = new QGridLayout(); QGridLayout *main_layout = new QGridLayout(this);
setWindowTitle( qtr("Preferences" ) ); setWindowTitle( qtr("Preferences" ) );
resize( 800, 450 ); resize( 800, 450 );
tree_panel = new QWidget; tree_panel = new QWidget(0);
tree_panel_l = new QHBoxLayout; tree_panel_l = new QHBoxLayout;
tree_panel->setLayout( tree_panel_l ); tree_panel->setLayout( tree_panel_l );
main_panel = new QWidget; main_panel = new QWidget(0);
main_panel_l = new QHBoxLayout; main_panel_l = new QHBoxLayout;
main_panel->setLayout( main_panel_l ); 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(0);
tl->setSpacing( 3 ); tl->setMargin( 3 ); tl->setSpacing( 3 ); tl->setMargin( 3 );
small = new QRadioButton( "Basic", types ); tl->addWidget( small ); small = new QRadioButton( "Basic", types ); tl->addWidget( small );
all = new QRadioButton( "All", types ); tl->addWidget( all ); all = new QRadioButton( "All", types ); tl->addWidget( all );
...@@ -64,11 +64,15 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -64,11 +64,15 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
simple_panel = NULL; simple_panel = NULL;
advanced_panel = NULL; advanced_panel = NULL;
main_layout->addLayout( tl, 0,0,1,1 ); main_layout->addWidget( types, 0,0,1,1 );
main_layout->addWidget( tree_panel, 1,0,1,1 ); main_layout->addWidget( tree_panel, 1,0,1,1 );
main_layout->addWidget( adv_chk , 2,0,1,1 ); main_layout->addWidget( adv_chk , 2,0,1,1 );
main_layout->addWidget( main_panel, 0, 1, 3, 1 ); main_layout->addWidget( main_panel, 0, 1, 3, 1 );
main_layout->setColumnMinimumWidth( 0, 200 );
main_layout->setColumnStretch( 0, 1 );
main_layout->setColumnStretch( 1,3 );
setAll(); setAll();
connect( adv_chk, SIGNAL( toggled(bool) ), connect( adv_chk, SIGNAL( toggled(bool) ),
...@@ -95,7 +99,7 @@ void PrefsDialog::setAll() ...@@ -95,7 +99,7 @@ void PrefsDialog::setAll()
if( !advanced_tree ) if( !advanced_tree )
{ {
advanced_tree = new PrefsTree( p_intf, this ); advanced_tree = new PrefsTree( p_intf, tree_panel );
connect( advanced_tree, connect( advanced_tree,
SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ), SIGNAL( currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *) ),
this, SLOT( changePanel( QTreeWidgetItem * ) ) ); this, SLOT( changePanel( QTreeWidgetItem * ) ) );
...@@ -109,10 +113,9 @@ void PrefsDialog::setAll() ...@@ -109,10 +113,9 @@ void PrefsDialog::setAll()
simple_panel->hide(); simple_panel->hide();
} }
if( !advanced_panel ) if( !advanced_panel )
advanced_panel = new PrefsPanel( this ); advanced_panel = new PrefsPanel( main_panel );
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
advanced_panel->show(); advanced_panel->show();
setAdvanced( adv_chk->isChecked() );
} }
void PrefsDialog::setSmall() void PrefsDialog::setSmall()
...@@ -153,7 +156,8 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -153,7 +156,8 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
} }
if( !data->panel ) if( !data->panel )
{ {
data->panel = new PrefsPanel( p_intf, this, data ); data->panel = new PrefsPanel( p_intf, main_panel , data,
adv_chk->isChecked() );
} }
advanced_panel = data->panel; advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
......
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