Make display according to settings.
authorMax Lapan <max.lapan@gmail.com>
Sun, 14 Mar 2010 14:34:38 +0000 (17:34 +0300)
committerMax Lapan <max.lapan@gmail.com>
Sun, 14 Mar 2010 14:34:38 +0000 (17:34 +0300)
mainwidget.cpp
settings.cpp

index 6b7f6be..76fc3ed 100644 (file)
@@ -26,6 +26,8 @@ MainWidget::MainWidget ()
     layout->addWidget (_label);
     setLayout (layout);
 
+    _light->setVisible (_settings->check (Settings::C_Light));
+
     connect (_traffic, SIGNAL (updated ()), SLOT (trafficUpdated ()));
 
     // every 5 minutes (TODO, make option)
@@ -70,11 +72,29 @@ void MainWidget::trafficUpdated ()
     ExtendedTrafficInfo info = _traffic->lookup_ext ("1");
 
     if (info.valid ()) {
+        QString data;
+        bool first = true;
         _light->setColor (info.color ());
-        _label->setText (QString ("%1, %2\n%3")
-                         .arg (QString::number (info.level ()))
-                         .arg (info.localtime ())
-                         .arg (info.hint ()));
+
+        if (_settings->check (Settings::C_Rank)) {
+            data.append (QString::number (info.level ()));
+            data.append (info.level () > 1 ? tr (" points") : tr (" point"));
+            first = false;
+        }
+
+        if (_settings->check (Settings::C_Time)) {
+            if (!first)
+                data.append (", ");
+            data.append (info.localtime ());
+            first = false;
+        }
+
+        if (_settings->check (Settings::C_Hint)) {
+            data.append ("\n");
+            data.append (info.hint ());
+        }
+
+        _label->setText (data);
     }
     else
         _light->setColor (ExtendedTrafficInfo::Unknown);
@@ -93,4 +113,9 @@ void MainWidget::settingsDialog ()
     SettingsDialog dlg (_settings);
 
     dlg.exec ();
+
+    // Handle settings
+    _light->setVisible (_settings->check (Settings::C_Light));
+
+    trafficUpdated ();
 }
index a02e90c..ad9311e 100644 (file)
@@ -29,4 +29,8 @@ void Settings::makeDefault ()
     _cities["10174"] = tr ("Kiev");
     _cities["11162"] = tr ("Ekaterinburg");
     _cities["11079"] = tr ("N.Novgorod");
+
+    setCheck (C_Light, true);
+    setCheck (C_Rank, true);
+    setCheck (C_Hint, true);
 }