comparison 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
comparison
equal deleted inserted replaced
19631:4e85ca0b4887 19632:101ce4eaa56c
83 history_window (new history_dock_widget (this)), 83 history_window (new history_dock_widget (this)),
84 file_browser_window (new files_dock_widget (this)), 84 file_browser_window (new files_dock_widget (this)),
85 doc_browser_window (new documentation_dock_widget (this)), 85 doc_browser_window (new documentation_dock_widget (this)),
86 editor_window (create_default_editor (this)), 86 editor_window (create_default_editor (this)),
87 workspace_window (new workspace_view (this)), 87 workspace_window (new workspace_view (this)),
88 _settings_dlg (0),
88 find_files_dlg (0), 89 find_files_dlg (0),
89 release_notes_window (0), 90 release_notes_window (0),
90 community_news_window (0), 91 community_news_window (0),
91 _octave_qt_link (0), 92 _octave_qt_link (0),
92 _clipboard (QApplication::clipboard ()), 93 _clipboard (QApplication::clipboard ()),
147 } 148 }
148 if (release_notes_window) 149 if (release_notes_window)
149 { 150 {
150 delete release_notes_window; 151 delete release_notes_window;
151 release_notes_window = 0; 152 release_notes_window = 0;
153 }
154 if (_settings_dlg)
155 {
156 delete _settings_dlg;
157 _settings_dlg = 0;
152 } 158 }
153 if (community_news_window) 159 if (community_news_window)
154 { 160 {
155 delete community_news_window; 161 delete community_news_window;
156 community_news_window = 0; 162 community_news_window = 0;
666 } 672 }
667 673
668 void 674 void
669 main_window::process_settings_dialog_request (const QString& desired_tab) 675 main_window::process_settings_dialog_request (const QString& desired_tab)
670 { 676 {
671 settings_dialog *settingsDialog = new settings_dialog (this, desired_tab); 677 if (_settings_dlg) // _settings_dlg is a guarded pointer!
672 678 { // here the dialog is still open and called once again
673 connect (settingsDialog, SIGNAL (apply_new_settings ()), 679 if (! desired_tab.isEmpty ())
680 _settings_dlg->show_tab (desired_tab);
681 return;
682 }
683
684 _settings_dlg = new settings_dialog (this, desired_tab);
685
686 connect (_settings_dlg, SIGNAL (apply_new_settings ()),
674 this, SLOT (request_reload_settings ())); 687 this, SLOT (request_reload_settings ()));
675 688
676 settingsDialog->setModal (false); 689 _settings_dlg->setModal (false);
677 settingsDialog->setAttribute (Qt::WA_DeleteOnClose); 690 _settings_dlg->setAttribute (Qt::WA_DeleteOnClose);
678 settingsDialog->show (); 691 _settings_dlg->show ();
679 } 692 }
680 693
681 void 694 void
682 main_window::request_reload_settings () 695 main_window::request_reload_settings ()
683 { 696 {