3 #include "mainwidget.hpp"
4 #include "settingsDialog.hpp"
7 // --------------------------------------------------
9 // --------------------------------------------------
10 MainWidget::MainWidget ()
13 setMinimumSize (300, 80);
15 setAttribute(Qt::WA_TranslucentBackground);
17 _light = new TrafficLight (this);
18 _label = new QLabel (this);
20 _traffic = new Traffic;
21 _regions = new RegionsTable;
22 _settings = new Settings;
24 QHBoxLayout *layout = new QHBoxLayout;
25 layout->addWidget (_light);
26 layout->addWidget (_label);
29 connect (_traffic, SIGNAL (updated ()), SLOT (trafficUpdated ()));
31 // every 5 minutes (TODO, make option)
32 startTimer (5*60*1000);
38 MainWidget::~MainWidget ()
49 void MainWidget::paintEvent(QPaintEvent *event)
52 p.setBrush (QColor(0, 0, 0, 128));
54 p.drawRoundedRect (rect(), 10, 10);
57 QWidget::paintEvent (event);
61 void MainWidget::timerEvent (QTimerEvent *)
68 void MainWidget::trafficUpdated ()
70 ExtendedTrafficInfo info = _traffic->lookup_ext ("1");
73 _light->setColor (info.color ());
74 _label->setText (QString ("%1, %2\n%3")
75 .arg (QString::number (info.level ()))
76 .arg (info.localtime ())
80 _light->setColor (ExtendedTrafficInfo::Unknown);
84 void MainWidget::updateData ()
86 // Here we need to check for internet connection
91 void MainWidget::settingsDialog ()
93 SettingsDialog dlg (_settings);