changeset 15275:c5d09a57ceb2

provide buttons for the settings dialog (bug #36981) * settings-dialog.ui: Add Ok and Cancel buttons. * settings-dialog.h, settings-dialog.cc (settings_dialog::write_changed_settings): New method. * main-window.cc: Call it.
author Torsten <ttl@justmail.de>
date Sun, 02 Sep 2012 22:39:56 +0200
parents 535bb601e7db
children ecdb1463bff4
files libgui/src/main-window.cc libgui/src/settings-dialog.cc libgui/src/settings-dialog.h libgui/src/settings-dialog.ui
diffstat 4 files changed, 52 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc
+++ b/libgui/src/main-window.cc
@@ -164,9 +164,13 @@
 main_window::process_settings_dialog_request ()
 {
   settings_dialog *settingsDialog = new settings_dialog (this);
-  settingsDialog->exec ();
+  int change_settings = settingsDialog->exec ();
+  if (change_settings == QDialog::Accepted)
+    {
+      settingsDialog->write_changed_settings ();
+      emit settings_changed ();
+    }
   delete settingsDialog;
-  emit settings_changed ();
 }
 
 void
--- a/libgui/src/settings-dialog.cc
+++ b/libgui/src/settings-dialog.cc
@@ -85,6 +85,12 @@
 
 settings_dialog::~settings_dialog ()
 {
+  delete ui;
+}
+
+void
+settings_dialog::write_changed_settings ()
+{
   QSettings *settings = resource_manager::get_settings ();
 
   // FIXME -- what should happen if settings is 0?
@@ -122,5 +128,4 @@
     }
   settings->setValue ("terminal/cursorType", cursorType);
   settings->sync ();
-  delete ui;
 }
--- a/libgui/src/settings-dialog.h
+++ b/libgui/src/settings-dialog.h
@@ -35,6 +35,7 @@
 Q_OBJECT public:
   explicit settings_dialog (QWidget * parent);
   ~settings_dialog ();
+  void write_changed_settings ();
 
 private:
   Ui::settings_dialog * ui;
--- a/libgui/src/settings-dialog.ui
+++ b/libgui/src/settings-dialog.ui
@@ -487,6 +487,13 @@
      </widget>
     </widget>
    </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>
@@ -715,5 +722,37 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>settings_dialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>299</x>
+     <y>366</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>299</x>
+     <y>199</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>settings_dialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>299</x>
+     <y>366</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>299</x>
+     <y>199</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
 </ui>