Commit 1f180231 authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 - Preferences. Add an apply button and warnings to force saving

and rebuilding when switching details depth.
parent 137e021b
...@@ -59,6 +59,9 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -59,6 +59,9 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
/* Choice for types */ /* Choice for types */
types = new QGroupBox( "Show settings" ); types = new QGroupBox( "Show settings" );
types->setAlignment( Qt::AlignHCenter ); types->setAlignment( Qt::AlignHCenter );
types->setToolTip( qtr("You have to apply the preferences before\n"
"switching settings details if you want\n"
"to keep them") );
QHBoxLayout *types_l = new QHBoxLayout(0); QHBoxLayout *types_l = new QHBoxLayout(0);
types_l->setSpacing( 3 ); types_l->setMargin( 3 ); types_l->setSpacing( 3 ); types_l->setMargin( 3 );
small = new QRadioButton( "Basic", types ); types_l->addWidget( small ); small = new QRadioButton( "Basic", types ); types_l->addWidget( small );
...@@ -75,10 +78,12 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -75,10 +78,12 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
/* Buttons */ /* Buttons */
QDialogButtonBox *buttonsBox = new QDialogButtonBox(); QDialogButtonBox *buttonsBox = new QDialogButtonBox();
QPushButton *save = new QPushButton( qtr( "&Save" ) ); QPushButton *save = new QPushButton( qtr( "&Save" ) );
QPushButton *apply = new QPushButton( qtr( "&Apply" ) );
QPushButton *cancel = new QPushButton( qtr( "&Cancel" ) ); QPushButton *cancel = new QPushButton( qtr( "&Cancel" ) );
QPushButton *reset = new QPushButton( qtr( "&Reset Preferences" ) ); QPushButton *reset = new QPushButton( qtr( "&Reset Preferences" ) );
buttonsBox->addButton( save, QDialogButtonBox::AcceptRole ); buttonsBox->addButton( save, QDialogButtonBox::AcceptRole );
buttonsBox->addButton( apply, QDialogButtonBox::AcceptRole );
buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole ); buttonsBox->addButton( cancel, QDialogButtonBox::RejectRole );
buttonsBox->addButton( reset, QDialogButtonBox::ActionRole ); buttonsBox->addButton( reset, QDialogButtonBox::ActionRole );
...@@ -110,6 +115,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf ) ...@@ -110,6 +115,7 @@ PrefsDialog::PrefsDialog( intf_thread_t *_p_intf ) : QVLCFrame( _p_intf )
} }
BUTTONACT( save, save() ); BUTTONACT( save, save() );
BUTTONACT( apply, apply() );
BUTTONACT( cancel, cancel() ); BUTTONACT( cancel, cancel() );
BUTTONACT( reset, reset() ); BUTTONACT( reset, reset() );
BUTTONACT( small, setSmall() ); BUTTONACT( small, setSmall() );
...@@ -243,6 +249,12 @@ void PrefsDialog::showModulePrefs( char *psz_module ) ...@@ -243,6 +249,12 @@ void PrefsDialog::showModulePrefs( char *psz_module )
} }
void PrefsDialog::save() void PrefsDialog::save()
{
apply();
hide();
}
void PrefsDialog::apply()
{ {
if( small->isChecked() && simple_tree ) if( small->isChecked() && simple_tree )
{ {
...@@ -252,7 +264,14 @@ void PrefsDialog::save() ...@@ -252,7 +264,14 @@ void PrefsDialog::save()
else if( all->isChecked() && advanced_tree ) else if( all->isChecked() && advanced_tree )
advanced_tree->applyAll(); advanced_tree->applyAll();
config_SaveConfigFile( p_intf, NULL ); config_SaveConfigFile( p_intf, NULL );
hide();
/* Delete the other panel in order to force its reload after clicking
on apply - UGLY but will work for now. */
if( simple_panel->isVisible() )
delete advanced_panel;
if( advanced_panel->isVisible() )
delete simple_panel;
} }
void PrefsDialog::cancel() void PrefsDialog::cancel()
......
...@@ -82,6 +82,7 @@ private slots: ...@@ -82,6 +82,7 @@ private slots:
void setAll(); void setAll();
void setSmall(); void setSmall();
void save(); void save();
void apply();
void cancel(); void cancel();
void reset(); void reset();
void close(){ save(); }; void close(){ save(); };
......
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