Check for device state on update.
authorMax Lapan <max.lapan@gmail.com>
Tue, 16 Mar 2010 14:38:42 +0000 (17:38 +0300)
committerMax Lapan <max.lapan@gmail.com>
Tue, 16 Mar 2010 14:39:49 +0000 (17:39 +0300)
mainwidget.cpp
settings.cpp
settings.hpp
settingsDialog.cpp
settingsDialog.hpp

index 8149f1f..187602f 100644 (file)
@@ -106,6 +106,8 @@ void MainWidget::updateData ()
 #if CHECK_FOR_CONNECTION
     update = ConnectionChecker::instance ()->checkConnection (_settings->check (Settings::C_UpdateOnGSM),
                                                               _settings->check (Settings::C_UpdateOnWiFi));
+    if (!_settings->check (Settings::C_UpdateWhenLocked))
+        update &= !DeviceState::instance ()->locked ();
 #endif
 
     if (update)
index 973e6d6..6831ecb 100644 (file)
@@ -22,6 +22,7 @@ void Settings::load ()
     _checks[C_ShowHint] = settings.value ("checks/hint", _checks[C_ShowHint]).toBool ();
     _checks[C_UpdateOnWiFi] = settings.value ("checks/updateOnWifi", _checks[C_UpdateOnWiFi]).toBool ();
     _checks[C_UpdateOnGSM] = settings.value ("checks/updateOnGSM", _checks[C_UpdateOnGSM]).toBool ();
+    _checks[C_UpdateWhenLocked] = settings.value ("checks/updateWhenLocked", _checks[C_UpdateWhenLocked]).toBool ();
 
     loadCities (&settings);
 
@@ -41,6 +42,7 @@ void Settings::save ()
     settings.setValue ("checks/hint", _checks[C_ShowHint]);
     settings.setValue ("checks/updateOnWifi", _checks[C_UpdateOnWiFi]);
     settings.setValue ("checks/updateOnGSM", _checks[C_UpdateOnGSM]);
+    settings.setValue ("checks/updateWhenLocked", _checks[C_UpdateWhenLocked]);
 
     settings.setValue ("updateInterval", intervalIndex2Minutes (_updateIntervalIndex));
 
@@ -99,6 +101,8 @@ void Settings::makeDefault ()
 
     setCheck (C_UpdateOnWiFi, true);
 
+    setCheck (C_UpdateWhenLocked, true);
+
     _updateIntervalIndex = 3;
 }
 
index 28fb78f..cc896e6 100644 (file)
@@ -15,6 +15,7 @@ public:
         C_ShowHint,
         C_UpdateOnWiFi,
         C_UpdateOnGSM,
+        C_UpdateWhenLocked,
     };
 
 private:
index 693c3ad..77ff7eb 100644 (file)
@@ -206,11 +206,14 @@ UpdateSettingsDialog::UpdateSettingsDialog (Settings *_settings)
     _wifiUpdate->setChecked (settings ()->check (Settings::C_UpdateOnWiFi));
     _gsmUpdate  = new QCheckBox (tr ("Update via GSM"), this);
     _gsmUpdate->setChecked (settings ()->check (Settings::C_UpdateOnGSM));
+    _lockedUpdate  = new QCheckBox (tr ("Update when device locked"), this);
+    _lockedUpdate->setChecked (settings ()->check (Settings::C_UpdateWhenLocked));
 
     initUpdateInterval (layout ());
 
     layout ()->addWidget (_wifiUpdate);
     layout ()->addWidget (_gsmUpdate);
+    layout ()->addWidget (_lockedUpdate);
 }
 
 
@@ -224,6 +227,7 @@ void UpdateSettingsDialog::saveSettings ()
 #endif
     settings ()->setCheck (Settings::C_UpdateOnWiFi, _wifiUpdate->isChecked ());
     settings ()->setCheck (Settings::C_UpdateOnGSM,  _gsmUpdate->isChecked ());
+    settings ()->setCheck (Settings::C_UpdateWhenLocked,  _lockedUpdate->isChecked ());
 }
 
 
index 28a7892..9d041ec 100644 (file)
@@ -84,7 +84,7 @@ class UpdateSettingsDialog : public BaseSettingsDialog
 
 private:
     QMaemo5ValueButton *_intervalButton;
-    QCheckBox *_wifiUpdate, *_gsmUpdate;
+    QCheckBox *_wifiUpdate, *_gsmUpdate, *_lockedUpdate;
 
     void initUpdateInterval (QBoxLayout *layout);