* Enable Save/Cancel. Please test heavily with already implemented stuff. There is a layout bug with simple prefs because they don't implement save yet. Also, we still have some parenting issues to fix
* Remove "advanced" stuff
PrefsTree::~PrefsTree() {}
-void PrefsTree::ApplyAll()
+void PrefsTree::applyAll()
{
- DoAll( false );
+ doAll( false );
}
-void PrefsTree::CleanAll()
+void PrefsTree::cleanAll()
{
- DoAll( true );
+ doAll( true );
}
/// \todo When cleaning, we should remove the panel ?
-void PrefsTree::DoAll( bool doclean )
+void PrefsTree::doAll( bool doclean )
{
for( int i_cat_index = 0 ; i_cat_index < topLevelItemCount();
i_cat_index++ )
{
QTreeWidgetItem *cat_item = topLevelItem( i_cat_index );
- for( int i_sc_index = 0; i_sc_index <= cat_item->childCount();
+ for( int i_sc_index = 0; i_sc_index < cat_item->childCount();
i_sc_index++ )
{
QTreeWidgetItem *sc_item = cat_item->child( i_sc_index );
- for( int i_module = 0 ; i_module <= sc_item->childCount();
+ for( int i_module = 0 ; i_module < sc_item->childCount();
i_module++ )
{
- PrefsItemData *data = sc_item->child( i_sc_index )->
- data( 0, Qt::UserRole ).
- value<PrefsItemData *>();
+ PrefsItemData *data = sc_item->child( i_module )->
+ data( 0, Qt::UserRole).value<PrefsItemData *>();
if( data->panel && doclean )
- data->panel->Clean();
+ {
+ delete data->panel;
+ data->panel = NULL;
+ }
else if( data->panel )
- data->panel->Apply();
+ data->panel->apply();
}
+ PrefsItemData *data = sc_item->data( 0, Qt::UserRole).
+ value<PrefsItemData *>();
+ if( data->panel && doclean )
+ {
+ delete data->panel;
+ data->panel = NULL;
+ }
+ else if( data->panel )
+ data->panel->apply();
+ }
+ PrefsItemData *data = cat_item->data( 0, Qt::UserRole).
+ value<PrefsItemData *>();
+ if( data->panel && doclean )
+ {
+ delete data->panel;
+ data->panel = NULL;
}
+ else if( data->panel )
+ data->panel->apply();
}
}
-
/*********************************************************************
* The Panel
*********************************************************************/
scroller->setWidget( scrolled_area );
scroller->setWidgetResizable( true );
global_layout->addWidget( scroller );
-
+ setLayout( global_layout );
+#if 0
some_hidden_text = new QLabel( qfu( I_HIDDEN_ADV ) );
some_hidden_text->setWordWrap( true );
-
- setLayout( global_layout );
setAdvanced( currently_advanced, true );
+#endif
}
-void PrefsPanel::Apply()
+void PrefsPanel::apply()
{
/* todo */
QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ )
{
- VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
- if( !vicc )
+ ConfigControl *c = qobject_cast<ConfigControl *>(*i);
+ fprintf( stderr, "Get a control %s\n", c->getName() );
+ switch( c->getType() )
{
+ case 1:
+ {
+ VIntConfigControl *vicc = qobject_cast<VIntConfigControl *>(*i);
+ fprintf( stderr, "Put %s = %i\n", vicc->getName(),vicc->getValue() );
+ config_PutInt( p_intf, vicc->getName(), vicc->getValue() );
+ break;
+ }
+ case 2:
+ {
VFloatConfigControl *vfcc = qobject_cast<VFloatConfigControl *>(*i);
- if( !vfcc)
+ fprintf( stderr, "Put %s = %f\n", vfcc->getName(),vfcc->getValue() );
+ config_PutFloat( p_intf, vfcc->getName(), vfcc->getValue() );
+ break;
+ }
+ case 3:
{
- VStringConfigControl *vscc =
- qobject_cast<VStringConfigControl *>(*i);
- assert( vscc );
- config_PutPsz( p_intf, vscc->getName().toAscii().data(),
+ VStringConfigControl *vscc =
+ qobject_cast<VStringConfigControl *>(*i);
+ fprintf( stderr, "Put %s = %s\n", vscc->getName(),vscc->getValue().toAscii().data() );
+ config_PutPsz( p_intf, vscc->getName(),
vscc->getValue().toAscii().data() );
- continue;
}
- config_PutFloat( p_intf, vfcc->getName().toAscii().data(),
- vfcc->getValue() );
- continue;
}
- config_PutInt( p_intf, vicc->getName().toAscii().data(),
- vicc->getValue() );
}
}
-void PrefsPanel::Clean()
+void PrefsPanel::clean()
{}
-
+#if 0
void PrefsPanel::setAdvanced( bool adv, bool force )
{
bool some_hidden = false;
some_hidden_text->show();
}
}
+#endif
PrefsTree( intf_thread_t *, QWidget * );
virtual ~PrefsTree();
- void ApplyAll();
- void CleanAll();
+ void applyAll();
+ void cleanAll();
private:
- void DoAll( bool );
+ void doAll( bool );
intf_thread_t *p_intf;
};
PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData *, bool );
PrefsPanel( QWidget *);
virtual ~PrefsPanel() {};
- void Apply();
- void Clean();
+ void apply();
+ void clean();
private:
intf_thread_t *p_intf;
QList<ConfigControl *> controls;
- QLabel *some_hidden_text;
QVBoxLayout *global_layout;
+#if 0
+ QLabel *some_hidden_text;
bool advanced;
+#endif
public slots:
+#if 0
void setAdvanced( bool, bool );
void setAdvanced( bool a ) { return setAdvanced( a, false ); }
+#endif
};
#endif
widget = NULL;
}
virtual ~ConfigControl() {};
- QString getName() { return qfu( p_item->psz_name ); }
+ virtual int getType() = 0;
+ char * getName() { return p_item->psz_name; }
QWidget *getWidget() { assert( widget ); return widget; }
bool isAdvanced() { return p_item->b_advanced; }
virtual void hide() { getWidget()->hide(); };
ConfigControl(a,b) {};
virtual ~VIntConfigControl() {};
virtual int getValue() = 0;
+ virtual int getType() { return 1; }
};
class IntegerConfigControl : public VIntConfigControl
ConfigControl(a,b) {};
virtual ~VFloatConfigControl() {};
virtual float getValue() = 0;
+ virtual int getType() { return 2; }
};
class FloatConfigControl : public VFloatConfigControl
ConfigControl(a,b) {};
virtual ~VStringConfigControl() {};
virtual QString getValue() = 0;
+ virtual int getType() { return 3; }
};
class StringConfigControl : public VStringConfigControl
setCurrentRow( SPrefsInterface );
}
-void SPrefsCatList::ApplyAll()
+void SPrefsCatList::applyAll()
{
- DoAll( false );
+ doAll( false );
}
-void SPrefsCatList::CleanAll()
+void SPrefsCatList::cleanAll()
{
- DoAll( true );
+ doAll( true );
}
/// \todo When cleaning, we should remove the panel ?
-void SPrefsCatList::DoAll( bool doclean )
+void SPrefsCatList::doAll( bool doclean )
{
/* Todo */
}
VStringConfigControl *vscc =
qobject_cast<VStringConfigControl *>(*i);
assert( vscc );
- config_PutPsz( p_intf, vscc->getName().toAscii().data(),
+ config_PutPsz( p_intf, vscc->getName(),
vscc->getValue().toAscii().data() );
continue;
}
- config_PutFloat( p_intf, vfcc->getName().toAscii().data(),
+ config_PutFloat( p_intf, vfcc->getName(),
vfcc->getValue() );
continue;
}
- config_PutInt( p_intf, vicc->getName().toAscii().data(),
+ config_PutInt( p_intf, vicc->getName(),
vicc->getValue() );
}
}
SPrefsCatList( intf_thread_t *, QWidget *);
virtual ~SPrefsCatList() {};
- void ApplyAll();
- void CleanAll();
+ void applyAll();
+ void cleanAll();
private:
- void DoAll( bool );
+ void doAll( bool );
intf_thread_t *p_intf;
};
all = new QRadioButton( "All", types ); tl->addWidget( all );
types->setLayout(tl);
small->setChecked( true );
-
+#if 0
adv_chk = new QCheckBox("Advanced options");
-
+#endif
advanced_tree = NULL;
simple_tree = NULL;
simple_panel = NULL;
main_layout->addWidget( types, 0,0,1,1 );
main_layout->addWidget( tree_panel, 1,0,1,1 );
+#if 0
main_layout->addWidget( adv_chk , 2,0,1,1 );
- main_layout->addWidget( main_panel, 0, 1, 3, 1 );
+#endif
+ main_layout->addWidget( main_panel, 0, 1, 2, 1 );
main_layout->setColumnMinimumWidth( 0, 200 );
main_layout->setColumnStretch( 0, 1 );
main_layout->setColumnStretch( 1,3 );
setSmall();
-
+#if 0
connect( adv_chk, SIGNAL( toggled(bool) ),
this, SLOT( setAdvanced( bool ) ) );
+#endif
+
+ QPushButton *save, *cancel;
+ QHBoxLayout *buttonsLayout =
+ QVLCFrame::doButtons( this, NULL, &save, _("Save"),
+ &cancel, _("Cancel"),
+ NULL, NULL );
+ connect( save, SIGNAL( clicked() ), this, SLOT( save() ) );
+ connect( cancel, SIGNAL( clicked() ), this, SLOT( cancel() ) );
+ main_layout->addLayout( buttonsLayout, 2,0, 1 ,3 );
+
setLayout( main_layout );
connect( small, SIGNAL( clicked() ), this, SLOT( setSmall()) );
connect( all, SIGNAL( clicked() ), this, SLOT( setAll()) );
}
-
+#if 0
void PrefsDialog::setAdvanced( bool advanced )
{
if( advanced_panel )
advanced_panel->setAdvanced( advanced );
}
-
+#endif
void PrefsDialog::setAll()
{
if( simple_tree )
advanced_panel = new PrefsPanel( main_panel );
main_panel_l->addWidget( advanced_panel );
advanced_panel->show();
+#if 0
adv_chk->show();
+#endif
}
void PrefsDialog::setSmall()
simple_panel = new SPrefsPanel( p_intf, main_panel, SPrefsDefaultCat );
main_panel_l->addWidget( simple_panel );
simple_panel->show();
+#if 0
adv_chk->hide();
+#endif
}
PrefsDialog::~PrefsDialog()
}
if( !data->panel )
{
- data->panel = new PrefsPanel( p_intf, main_panel , data,
- adv_chk->isChecked() );
+ data->panel = new PrefsPanel( p_intf, main_panel , data, true );
+#if 0
+ adv_chk->isChecked() );
+#endif
}
advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel );
advanced_panel->show();
+#if 0
setAdvanced( adv_chk->isChecked() );
+#endif
+}
+
+void PrefsDialog::save()
+{
+ if( small->isChecked() && simple_tree )
+ simple_tree->applyAll();
+ else if( all->isChecked() && advanced_tree )
+ advanced_tree->applyAll();
+ config_SaveConfigFile( p_intf, NULL );
+ hide();
+}
+
+void PrefsDialog::cancel()
+{
+ if( small->isChecked() && simple_tree )
+ {
+ simple_tree->cleanAll();
+ simple_panel = NULL;
+ }
+ else if( all->isChecked() && advanced_tree )
+ {
+ advanced_tree->cleanAll();
+ advanced_panel = NULL;
+ }
+ hide();
}
QGroupBox *types;
QRadioButton *small,*all;
+#if 0
QCheckBox *adv_chk;
+#endif
QGridLayout *main_layout;
void changeSimplePanel( QListWidgetItem *);
void setAll();
void setSmall();
+ void save();
+ void cancel();
+#if 0
void setAdvanced( bool );
+#endif
};
#endif
}
#endif
}
- static void doButtons( QWidget *w, QBoxLayout *l,
- QPushButton **defaul, char *psz_default,
- QPushButton **alt, char *psz_alt,
- QPushButton **other, char *psz_other )
+ static QHBoxLayout* doButtons( QWidget *w, QBoxLayout *l,
+ QPushButton **defaul, char *psz_default,
+ QPushButton **alt, char *psz_alt,
+ QPushButton **other, char *psz_other )
{
#ifdef QT42
#else
if( psz_default )
{
+ fprintf( stderr, "Creating default button %s\n", psz_default );
*defaul = new QPushButton(0);
buttons_layout->addWidget( *defaul );
(*defaul)->setText( qfu( psz_default ) );
buttons_layout->addWidget( *other );
(*other)->setText( qfu( psz_other ) );
}
- l->addLayout( buttons_layout );
+ if( l )
+ l->addLayout( buttons_layout );
#endif
+ return buttons_layout;
};
QVLCFrame( intf_thread_t *_p_intf ) : QWidget( NULL ), p_intf( _p_intf )