From a622a74a1fe9cd481474960ff8435335d56a4067 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sun, 15 Mar 2009 03:41:19 +0100 Subject: [PATCH] Qt: remove Preferences singleton. Simplify and Close #2552 and #2551 --- modules/gui/qt4/dialogs/preferences.cpp | 53 ++----------------------- modules/gui/qt4/dialogs/preferences.hpp | 14 +------ modules/gui/qt4/dialogs_provider.cpp | 3 +- 3 files changed, 7 insertions(+), 63 deletions(-) diff --git a/modules/gui/qt4/dialogs/preferences.cpp b/modules/gui/qt4/dialogs/preferences.cpp index 06b2f5cd82..89864d7a16 100644 --- a/modules/gui/qt4/dialogs/preferences.cpp +++ b/modules/gui/qt4/dialogs/preferences.cpp @@ -39,8 +39,6 @@ #include #include -PrefsDialog *PrefsDialog::instance = NULL; - PrefsDialog::PrefsDialog( QWidget *parent, intf_thread_t *_p_intf ) : QVLCDialog( parent, _p_intf ) { @@ -294,56 +292,13 @@ void PrefsDialog::save() /* Save to file */ config_SaveConfigFile( p_intf, NULL ); - - destroyPanels(); - - hide(); + accept(); } -void PrefsDialog::destroyPanels() -{ - msg_Dbg( p_intf, "Destroying the Panels" ); - /* Delete the other panel in order to force its reload after clicking - on apply. In fact, if we don't do that, the preferences from the other - panels won't be accurate, so we would have to recreate the whole dialog, - and we don't want that.*/ - if( small->isChecked() && advanced_panel ) - { - /* Deleting only the active panel from the advanced config doesn't work - because the data records of PrefsItemData contains still a - reference to it only cleanAll() is sure to remove all Panels! */ - advanced_tree->cleanAll(); - advanced_panel = NULL; - } - if( all->isChecked() && current_simple_panel ) - { - for( int i = 0 ; i< SPrefsMax; i++ ) - { - if( simple_panels[i] ) - { - delete simple_panels[i]; - simple_panels[i] = NULL; - } - } - current_simple_panel = NULL; - } -} - - /* Clean the preferences, dunno if it does something really */ void PrefsDialog::cancel() { - if( small->isChecked() && simple_tree ) - { - for( int i = 0 ; i< SPrefsMax; i++ ) - if( simple_panels[i] ) simple_panels[i]->clean(); - } - else if( all->isChecked() && advanced_tree ) - { - advanced_tree->cleanAll(); - advanced_panel = NULL; - } - hide(); + reject(); } /* Reset all the preferences, when you click the button */ @@ -362,8 +317,6 @@ void PrefsDialog::reset() config_SaveConfigFile( p_intf, NULL ); getSettings()->clear(); - close(); - instance = NULL; - PrefsDialog::getInstance( p_intf )->show(); + accept(); } } diff --git a/modules/gui/qt4/dialogs/preferences.hpp b/modules/gui/qt4/dialogs/preferences.hpp index bcd1f49ef4..ef50b5201b 100644 --- a/modules/gui/qt4/dialogs/preferences.hpp +++ b/modules/gui/qt4/dialogs/preferences.hpp @@ -45,24 +45,16 @@ class PrefsDialog : public QVLCDialog { Q_OBJECT; public: - static PrefsDialog * getInstance( intf_thread_t *p_intf ) - { - if( !instance ) - instance = new PrefsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf ); - return instance; - } - virtual ~PrefsDialog() { instance = NULL; } + PrefsDialog( QWidget *, intf_thread_t * ); + virtual ~PrefsDialog() {} #if 0 /*Called from extended settings, is not used anymore, but could be useful one day*/ void showModulePrefs( char* ); #endif private: - PrefsDialog( QWidget *, intf_thread_t * ); QGridLayout *main_layout; - void destroyPanels(); - QWidget *main_panel; QHBoxLayout *main_panel_l; @@ -79,8 +71,6 @@ private: QGroupBox *types; QRadioButton *small,*all; - static PrefsDialog *instance; - bool b_small; private slots: diff --git a/modules/gui/qt4/dialogs_provider.cpp b/modules/gui/qt4/dialogs_provider.cpp index 79ad6aa95f..2c95d90f39 100644 --- a/modules/gui/qt4/dialogs_provider.cpp +++ b/modules/gui/qt4/dialogs_provider.cpp @@ -172,7 +172,8 @@ void DialogsProvider::playlistDialog() void DialogsProvider::prefsDialog() { - PrefsDialog::getInstance( p_intf )->toggleVisible(); + PrefsDialog *p = new PrefsDialog( (QWidget *)p_intf->p_sys->p_mi, p_intf ); + p->toggleVisible(); } void DialogsProvider::extendedDialog() -- 2.39.2