Make sure settings are only saved when the "Save" button is pressed and the daily...
authorChristophe Dumez <dchris@gmail.com>
Wed, 7 Jul 2010 08:03:13 +0000 (10:03 +0200)
committerChristophe Dumez <dchris@gmail.com>
Wed, 7 Jul 2010 08:03:13 +0000 (10:03 +0200)
Changelog
TimedSilencer.pro.user
mainwindow.cpp
mainwindow.h

index 08aebcd..5a4ed5a 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -1,3 +1,7 @@
+* Mon Jul 7 2010 - Christophe Dumez <dchris@gmail.com> - v0.5
+    - Make sure settings are only saved when the "Save" button is pressed
+    - Daily profile switching is now deactivated as a default
+
 * Mon Jul 7 2010 - Christophe Dumez <dchris@gmail.com> - v0.4
     - UI changes to improve usability
 
index 7eea5c4..8f553ad 100644 (file)
     <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">16</value>
     <valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
      <value key="192.168.1.4" type="QDateTime">2010-06-29T00:09:20</value>
-     <value key="localhost" type="QDateTime">2010-07-07T00:05:11</value>
+     <value key="localhost" type="QDateTime">2010-07-07T09:57:55</value>
     </valuemap>
    </valuemap>
    <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
index dc2acd0..e4ed214 100644 (file)
@@ -57,12 +57,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
   verticalLayoutR->addItem(new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding));
   done_btn = new QPushButton(tr("Save"));
   done_btn->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-  connect(done_btn, SIGNAL(clicked()), this, SLOT(close()));
+  connect(done_btn, SIGNAL(clicked()), this, SLOT(saveAndClose()));
   verticalLayoutR->addWidget(done_btn);
   hori_layout->addLayout(verticalLayoutR);
   // Load settings
   loadSettings();
-  connect(cb_enable, SIGNAL(toggled(bool)), this, SLOT(enableSilencing(bool)));
   // Auto rotation
   setAttribute(Qt::WA_Maemo5AutoOrientation, true);
 }
@@ -74,15 +73,18 @@ MainWindow::~MainWindow() {
   delete done_btn;
 }
 
-void MainWindow::closeEvent(QCloseEvent *event) {
+void MainWindow::saveAndClose() {
+  // Save the settings and set the events
   if(cb_enable->isChecked()) {
-    QMaemo5InformationBox::information(this, tr("The daily profile switching is activated"), 0);
     setProfileEvents();
+    QMaemo5InformationBox::information(this, tr("The daily profile switching is activated"), 0);
   } else {
+    AlarmdBackend::deleteEvents();
     QMaemo5InformationBox::information(this, tr("The daily profile switching is deactivated"), 0);
   }
   saveSettings();
-  event->accept();
+  // Close the window
+  close();
 }
 
 void MainWindow::saveSettings() {
@@ -98,15 +100,7 @@ void MainWindow::loadSettings() {
   static_cast<QMaemo5TimePickSelector*>(from_button->pickSelector())->setCurrentTime(from_time);
   QTime to_time = settings.value("to_time", QTime(8, 0)).toTime();
   static_cast<QMaemo5TimePickSelector*>(to_button->pickSelector())->setCurrentTime(to_time);
-  cb_enable->setChecked(settings.value("enabled", true).toBool());
-}
-
-void MainWindow::enableSilencing(bool enabled) {
-  if(enabled) {
-    setProfileEvents();
-  } else {
-    AlarmdBackend::deleteEvents();
-  }
+  cb_enable->setChecked(settings.value("enabled", false).toBool());
 }
 
 void MainWindow::setProfileEvents() {
index 375ab19..1242af8 100644 (file)
@@ -32,14 +32,11 @@ public:
   explicit MainWindow(QWidget *parent = 0);
   ~MainWindow();
 
-protected:
-  void closeEvent(QCloseEvent *event);
-
 protected slots:
   void saveSettings();
   void loadSettings();
-  void enableSilencing(bool enabled);
   void setProfileEvents();
+  void saveAndClose();
 
 private:
   QMaemo5ValueButton *from_button, *to_button;