From 9c472d47e0c491fb45d00c3761689bd40eb627c4 Mon Sep 17 00:00:00 2001 From: Max Lapan Date: Sun, 14 Mar 2010 17:34:38 +0300 Subject: [PATCH] Make display according to settings. --- mainwidget.cpp | 33 +++++++++++++++++++++++++++++---- settings.cpp | 4 ++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/mainwidget.cpp b/mainwidget.cpp index 6b7f6be..76fc3ed 100644 --- a/mainwidget.cpp +++ b/mainwidget.cpp @@ -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 (); } diff --git a/settings.cpp b/settings.cpp index a02e90c..ad9311e 100644 --- a/settings.cpp +++ b/settings.cpp @@ -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); } -- 1.7.9.5