Commit 036838fa authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Prefs; cleaning, disabling unused code, general comments, class...

Qt4 - Prefs; cleaning, disabling unused code, general comments, class renaming, in order to actually use those preferences. :D

parent 00e3654a
...@@ -324,10 +324,10 @@ void PrefsTree::doAll( bool doclean ) ...@@ -324,10 +324,10 @@ void PrefsTree::doAll( bool doclean )
/********************************************************************* /*********************************************************************
* The Panel * The Panel
*********************************************************************/ *********************************************************************/
PrefsPanel::PrefsPanel( QWidget *_parent ) : QWidget( _parent ) AdvPrefsPanel::AdvPrefsPanel( QWidget *_parent ) : QWidget( _parent )
{} {}
PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, AdvPrefsPanel::AdvPrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
PrefsItemData * data ) : PrefsItemData * data ) :
QWidget( _parent ), p_intf( _p_intf ) QWidget( _parent ), p_intf( _p_intf )
{ {
...@@ -490,7 +490,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent, ...@@ -490,7 +490,7 @@ PrefsPanel::PrefsPanel( intf_thread_t *_p_intf, QWidget *_parent,
setLayout( global_layout ); setLayout( global_layout );
} }
void PrefsPanel::apply() void AdvPrefsPanel::apply()
{ {
QList<ConfigControl *>::Iterator i; QList<ConfigControl *>::Iterator i;
for( i = controls.begin() ; i != controls.end() ; i++ ) for( i = controls.begin() ; i != controls.end() ; i++ )
...@@ -499,5 +499,5 @@ void PrefsPanel::apply() ...@@ -499,5 +499,5 @@ void PrefsPanel::apply()
c->doApply( p_intf ); c->doApply( p_intf );
} }
} }
void PrefsPanel::clean() void AdvPrefsPanel::clean()
{} {}
...@@ -37,7 +37,7 @@ enum ...@@ -37,7 +37,7 @@ enum
TYPE_MODULE TYPE_MODULE
}; };
class PrefsPanel; class AdvPrefsPanel;
class QLabel; class QLabel;
class QVBoxLayout; class QVBoxLayout;
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
PrefsItemData() PrefsItemData()
{ panel = NULL; i_object_id = 0; i_subcat_id = -1; psz_name = NULL; }; { panel = NULL; i_object_id = 0; i_subcat_id = -1; psz_name = NULL; };
virtual ~PrefsItemData() { free( psz_name ); }; virtual ~PrefsItemData() { free( psz_name ); };
PrefsPanel *panel; AdvPrefsPanel *panel;
int i_object_id; int i_object_id;
int i_subcat_id; int i_subcat_id;
int i_type; int i_type;
...@@ -76,13 +76,13 @@ private: ...@@ -76,13 +76,13 @@ private:
class ConfigControl; class ConfigControl;
class PrefsPanel : public QWidget class AdvPrefsPanel : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
PrefsPanel( intf_thread_t *, QWidget *, PrefsItemData * ); AdvPrefsPanel( intf_thread_t *, QWidget *, PrefsItemData * );
PrefsPanel( QWidget *); AdvPrefsPanel( QWidget *);
virtual ~PrefsPanel() {}; virtual ~AdvPrefsPanel() {};
void apply(); void apply();
void clean(); void clean();
private: private:
......
...@@ -103,23 +103,19 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -103,23 +103,19 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL; for( int i = 0; i < SPrefsMax ; i++ ) simple_panels[i] = NULL;
if( config_GetInt( p_intf, "qt-advanced-pref") == 1 ) if( config_GetInt( p_intf, "qt-advanced-pref") == 1 )
{ SetAdvanced();
setAll();
}
else else
{
setSmall(); setSmall();
}
BUTTONACT( save, save() ); BUTTONACT( save, save() );
BUTTONACT( cancel, cancel() ); BUTTONACT( cancel, cancel() );
BUTTONACT( reset, reset() ); BUTTONACT( reset, reset() );
BUTTONACT( small, setSmall() );
BUTTONACT( all, setAll() );
BUTTONACT( small, setSmall() );
BUTTONACT( all, SetAdvanced() );
} }
void PrefsDialog::setAll() void PrefsDialog::SetAdvanced()
{ {
/* We already have a simple TREE, and we just want to hide it */ /* We already have a simple TREE, and we just want to hide it */
if( simple_tree ) if( simple_tree )
...@@ -136,7 +132,7 @@ void PrefsDialog::setAll() ...@@ -136,7 +132,7 @@ void PrefsDialog::setAll()
/* and connections */ /* and connections */
CONNECT( advanced_tree, CONNECT( advanced_tree,
currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *), currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem *),
this, changePanel( QTreeWidgetItem * ) ); this, changeAdvPanel( QTreeWidgetItem * ) );
} }
/* Add the Advanced tree to the tree_panel, even if it is already inside, /* Add the Advanced tree to the tree_panel, even if it is already inside,
since it can't hurt. And show it. */ since it can't hurt. And show it. */
...@@ -151,7 +147,7 @@ void PrefsDialog::setAll() ...@@ -151,7 +147,7 @@ void PrefsDialog::setAll()
} }
/* 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 PrefsPanel( main_panel ); advanced_panel = new AdvPrefsPanel( main_panel );
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
all->setChecked( true ); all->setChecked( true );
advanced_panel->show(); advanced_panel->show();
...@@ -193,6 +189,7 @@ void PrefsDialog::setSmall() ...@@ -193,6 +189,7 @@ void PrefsDialog::setSmall()
current_simple_panel->show(); current_simple_panel->show();
} }
/* Switching from on simple panel to another */
void PrefsDialog::changeSimplePanel( int number ) void PrefsDialog::changeSimplePanel( int number )
{ {
if( current_simple_panel ) if( current_simple_panel )
...@@ -210,7 +207,8 @@ void PrefsDialog::changeSimplePanel( int number ) ...@@ -210,7 +207,8 @@ void PrefsDialog::changeSimplePanel( int number )
current_simple_panel->show(); current_simple_panel->show();
} }
void PrefsDialog::changePanel( QTreeWidgetItem *item ) /* Changing from one Advanced Panel to another */
void PrefsDialog::changeAdvPanel( QTreeWidgetItem *item )
{ {
PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>(); PrefsItemData *data = item->data( 0, Qt::UserRole ).value<PrefsItemData*>();
...@@ -220,16 +218,18 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item ) ...@@ -220,16 +218,18 @@ void PrefsDialog::changePanel( QTreeWidgetItem *item )
advanced_panel->hide(); advanced_panel->hide();
} }
if( !data->panel ) if( !data->panel )
data->panel = new PrefsPanel( p_intf, main_panel , data ); data->panel = new AdvPrefsPanel( p_intf, main_panel , data );
advanced_panel = data->panel; advanced_panel = data->panel;
main_panel_l->addWidget( advanced_panel ); main_panel_l->addWidget( advanced_panel );
advanced_panel->show(); advanced_panel->show();
} }
#if 0
/*Called from extended settings, is not used anymore, but could be useful one day*/
void PrefsDialog::showModulePrefs( char *psz_module ) void PrefsDialog::showModulePrefs( char *psz_module )
{ {
setAll(); SetAdvanced();
all->setChecked( true ); all->setChecked( true );
for( int i_cat_index = 0 ; i_cat_index < advanced_tree->topLevelItemCount(); for( int i_cat_index = 0 ; i_cat_index < advanced_tree->topLevelItemCount();
i_cat_index++ ) i_cat_index++ )
...@@ -257,14 +257,10 @@ void PrefsDialog::showModulePrefs( char *psz_module ) ...@@ -257,14 +257,10 @@ void PrefsDialog::showModulePrefs( char *psz_module )
} }
show(); show();
} }
#endif
/* Actual apply and save for the preferences */
void PrefsDialog::save() void PrefsDialog::save()
{
apply();
hide();
}
void PrefsDialog::apply()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
{ {
...@@ -289,8 +285,11 @@ void PrefsDialog::apply() ...@@ -289,8 +285,11 @@ void PrefsDialog::apply()
delete current_simple_panel; delete current_simple_panel;
current_simple_panel = NULL; current_simple_panel = NULL;
} }
hide();
} }
/* Clean the preferences, dunno if it does something really */
void PrefsDialog::cancel() void PrefsDialog::cancel()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
...@@ -306,6 +305,7 @@ void PrefsDialog::cancel() ...@@ -306,6 +305,7 @@ void PrefsDialog::cancel()
hide(); hide();
} }
/* Reset all the preferences, when you click the button */
void PrefsDialog::reset() void PrefsDialog::reset()
{ {
int ret = QMessageBox::question(this, qtr("Reset Preferences"), int ret = QMessageBox::question(this, qtr("Reset Preferences"),
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
class PrefsTree; class PrefsTree;
class SPrefsCatList; class SPrefsCatList;
class PrefsPanel; class AdvPrefsPanel;
class SPrefsPanel; class SPrefsPanel;
class QTreeWidgetItem; class QTreeWidgetItem;
class QTreeWidget; class QTreeWidget;
...@@ -54,14 +54,17 @@ public: ...@@ -54,14 +54,17 @@ public:
return instance; return instance;
} }
virtual ~PrefsDialog() {}; virtual ~PrefsDialog() {};
#if 0
/*Called from extended settings, is not used anymore, but could be useful one day*/
void showModulePrefs( char* ); void showModulePrefs( char* );
#endif
private: private:
PrefsDialog( intf_thread_t * ); PrefsDialog( intf_thread_t * );
QWidget *main_panel; QWidget *main_panel;
QHBoxLayout *main_panel_l; QHBoxLayout *main_panel_l;
PrefsPanel *advanced_panel;
AdvPrefsPanel *advanced_panel;
SPrefsPanel *current_simple_panel; SPrefsPanel *current_simple_panel;
SPrefsPanel *simple_panels[SPrefsMax]; SPrefsPanel *simple_panels[SPrefsMax];
...@@ -76,16 +79,18 @@ private: ...@@ -76,16 +79,18 @@ private:
QGridLayout *main_layout; QGridLayout *main_layout;
static PrefsDialog *instance; static PrefsDialog *instance;
private slots: private slots:
void changePanel( QTreeWidgetItem * ); void SetAdvanced();
void changeSimplePanel( int ); void setSmall();
void setAll();
void setSmall(); void changeAdvPanel( QTreeWidgetItem * );
void save(); void changeSimplePanel( int );
void apply();
void cancel(); void save();
void reset(); void cancel();
void close(){ save(); }; void reset();
void close(){ save(); }; /* Needed for any generic CloseEvent*/
}; };
#endif #endif
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