diff libgui/src/main-window.cc @ 19632:101ce4eaa56c gui-release

prevent opening the settings dialog multiple times * main-window.h: settings dialog is now a guarded pointer and class member * main-window.cc (constructor): initialize settings dialog pointer to 0; (destructor): delete pointer if necessary; (process_settings_dialog_request): only switch to desired tab if settings dialog already exists; * settings-dialog.h: new function show_tab, write_changed_setting provate now * settings-dialog.cc (constructor) do not set desired tab here; (show_tab): but here so it can be called independently (button_clicked): close the dialog when ok or cancel was clicked * settings-dialog.ui: removed accepted/rejected signals from the button box since closing the dialog is now done in settings_dialog::button_clicked
author Torsten <ttl@justmail.de>
date Sun, 25 Jan 2015 20:03:17 +0100
parents 4e85ca0b4887
children 5d0663bff506
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Sun Jan 25 12:22:48 2015 +0100
+++ b/libgui/src/main-window.cc	Sun Jan 25 20:03:17 2015 +0100
@@ -85,6 +85,7 @@
     doc_browser_window (new documentation_dock_widget (this)),
     editor_window (create_default_editor (this)),
     workspace_window (new workspace_view (this)),
+    _settings_dlg (0),
     find_files_dlg (0),
     release_notes_window (0),
     community_news_window (0),
@@ -150,6 +151,11 @@
       delete release_notes_window;
       release_notes_window = 0;
     }
+  if (_settings_dlg)
+    {
+      delete _settings_dlg;
+      _settings_dlg = 0;
+    }
   if (community_news_window)
     {
       delete community_news_window;
@@ -668,14 +674,21 @@
 void
 main_window::process_settings_dialog_request (const QString& desired_tab)
 {
-  settings_dialog *settingsDialog = new settings_dialog (this, desired_tab);
-
-  connect (settingsDialog, SIGNAL (apply_new_settings ()),
+  if (_settings_dlg)  // _settings_dlg is a guarded pointer!
+    {                 // here the dialog is still open and called once again
+      if (! desired_tab.isEmpty ())
+        _settings_dlg->show_tab (desired_tab);
+      return;
+    }
+
+  _settings_dlg = new settings_dialog (this, desired_tab);
+
+  connect (_settings_dlg, SIGNAL (apply_new_settings ()),
            this, SLOT (request_reload_settings ()));
 
-  settingsDialog->setModal (false);
-  settingsDialog->setAttribute (Qt::WA_DeleteOnClose);
-  settingsDialog->show ();
+  _settings_dlg->setModal (false);
+  _settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
+  _settings_dlg->show ();
 }
 
 void