Update data when device unlocked.
[yandex-traffic] / settingsDialog.cpp
index 77ff7eb..ca73077 100644 (file)
@@ -29,11 +29,38 @@ SettingsDialog::SettingsDialog (Settings *settings)
     updateUpdateButtonValue ();
     layout->addWidget (_updateButton);
 
+    createLanguageButton (layout);
+
     connect (_displayButton, SIGNAL (clicked ()), SLOT (displayClicked ()));
     connect (_updateButton, SIGNAL (clicked ()), SLOT (updateClicked ()));
 }
 
 
+void SettingsDialog::createLanguageButton (QBoxLayout *layout)
+{
+    _languageButton = new QMaemo5ValueButton (tr ("Language"), this);
+    layout->addWidget (_languageButton);
+
+#ifdef Q_WS_MAEMO_5
+    QMaemo5ListPickSelector *selector = new QMaemo5ListPickSelector;
+    QStandardItemModel *model = new QStandardItemModel (0, 1);
+    QList<Language>::const_iterator it = _settings->languages ().begin ();
+
+    while (it != _settings->languages ().end ()) {
+        QStandardItem *item = new QStandardItem (it->title ());
+        item->setData (it->alias ());
+        model->appendRow (item);
+        it++;
+    }
+
+    selector->setModel (model);
+    selector->setCurrentIndex (_settings->languages ().indexOf (_settings->language ()));
+
+    _languageButton->setPickSelector (selector);
+#endif
+}
+
+
 void SettingsDialog::displayClicked ()
 {
     DisplaySettingsDialog dlg (_settings);
@@ -50,12 +77,27 @@ void SettingsDialog::updateClicked ()
 }
 
 
+void SettingsDialog::languageChanged (const QString&)
+{
+#ifdef Q_WS_MAEMO_5
+    QMaemo5ListPickSelector *model = static_cast<QMaemo5ListPickSelector*> (_languageButton->pickSelector ());
+
+    if (!model)
+        return;
+
+    const Language &lang = _settings->languages ()[model->currentIndex ()];
+    if (lang != _settings->language ())
+        _settings->setLanguage (lang);
+#endif
+}
+
+
 void SettingsDialog::updateDisplayButtonValue ()
 {
     QString val;
     QStringList list;
 
-    val = tr ("City: ") + _settings->cities ()[_settings->regionID ()] + ", " + tr ("Data: ");
+    val = tr ("City:") + " " + _settings->cities ()[_settings->regionID ()] + ", " + tr ("Display:") + " ";
 
     if (_settings->check (Settings::C_ShowLight))
         list.append (tr ("lights"));
@@ -75,14 +117,21 @@ void SettingsDialog::updateUpdateButtonValue ()
     QStringList list, intervals = _settings->updateIntervals ();
     QString val;
 
-    val = tr ("Interval: ") + intervals[_settings->getUpdateIntervalIndex ()] + ", " + tr ("Update via: ");
+    val = tr ("Interval:") + " " + intervals[_settings->getUpdateIntervalIndex ()] + ", " + tr ("Update via:") + " ";
 
     if (_settings->check (Settings::C_UpdateOnWiFi))
         list.append (tr ("WiFi"));
     if (_settings->check (Settings::C_UpdateOnGSM))
         list.append (tr ("GSM"));
 
-    _updateButton->setValueText (val + list.join (", "));
+    val += list.join (", ");
+
+    if (_settings->check (Settings::C_UpdateWhenLocked))
+        val += ", " + tr ("Update when locked");
+    else
+        val += ", " + tr ("Not update when locked");
+
+    _updateButton->setValueText (val);
 }