projects
/
yandex-traffic
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typo
[yandex-traffic]
/
mainwidget.cpp
diff --git
a/mainwidget.cpp
b/mainwidget.cpp
index
f4aa592
..
545292a
100644
(file)
--- a/
mainwidget.cpp
+++ b/
mainwidget.cpp
@@
-1,10
+1,13
@@
#include <QtGui>
#include <QtGui>
+#include "globals.hpp"
#include "mainwidget.hpp"
#include "settingsDialog.hpp"
#include "connection.hpp"
#include "devstate.hpp"
#include "settings.hpp"
#include "mainwidget.hpp"
#include "settingsDialog.hpp"
#include "connection.hpp"
#include "devstate.hpp"
#include "settings.hpp"
+#include "log.hpp"
+#include "menudialog.hpp"
// --------------------------------------------------
// --------------------------------------------------
@@
-64,7
+67,6
@@
void MainWidget::paintEvent(QPaintEvent *event)
}
}
-
void MainWidget::trafficUpdated ()
{
ExtendedTrafficInfo info = _traffic->lookup_ext (_settings->regionID ());
void MainWidget::trafficUpdated ()
{
ExtendedTrafficInfo info = _traffic->lookup_ext (_settings->regionID ());
@@
-72,6
+74,8
@@
void MainWidget::trafficUpdated ()
if (info.valid ()) {
QString data;
bool first = true;
if (info.valid ()) {
QString data;
bool first = true;
+ Log::instance ()->add ("trafficUpdated, info valid");
+ info.dump ();
_light->setColor (info.color ());
if (_settings->check (Settings::C_ShowRank)) {
_light->setColor (info.color ());
if (_settings->check (Settings::C_ShowRank)) {
@@
-95,6
+99,7
@@
void MainWidget::trafficUpdated ()
_label->setText (data);
}
else {
_label->setText (data);
}
else {
+ Log::instance ()->add ("trafficUpdated, but info not valid");
_light->setColor (ExtendedTrafficInfo::Unknown);
_label->setText (tr ("No data"));
}
_light->setColor (ExtendedTrafficInfo::Unknown);
_label->setText (tr ("No data"));
}
@@
-105,15
+110,24
@@
void MainWidget::updateData ()
{
bool update = true;
{
bool update = true;
+ Log::instance ()->add ("updateData called");
+
#if CHECK_FOR_CONNECTION
update = ConnectionChecker::instance ()->checkConnection (_settings->check (Settings::C_UpdateOnGSM),
_settings->check (Settings::C_UpdateOnWiFi));
#if CHECK_FOR_CONNECTION
update = ConnectionChecker::instance ()->checkConnection (_settings->check (Settings::C_UpdateOnGSM),
_settings->check (Settings::C_UpdateOnWiFi));
- if (!_settings->check (Settings::C_UpdateWhenLocked))
+ Log::instance ()->add (QString ("checkConnection returned %1").arg (update ? "true" : "false"));
+ if (!_settings->check (Settings::C_UpdateWhenLocked)) {
+ Log::instance ()->add ("Check for device state");
update &= !DeviceState::instance ()->locked ();
update &= !DeviceState::instance ()->locked ();
+ }
#endif
#endif
- if (update)
+ if (update) {
+ Log::instance ()->add ("Perform update");
_traffic->update ();
_traffic->update ();
+ }
+ else
+ Log::instance ()->add ("Update not performed");
}
}
@@
-154,29
+168,39
@@
void MainWidget::applySettings ()
updateSize ();
updateSize ();
- if (_settings->updateInterval () < 0)
+ Log::instance ()->add (QString ("applySettings: updateInterval is %1").arg (_settings->updateInterval ()));
+
+ if (_settings->updateInterval () < 0) {
_timer->stop ();
_timer->stop ();
- else
+ Log::instance ()->add ("Timer disabled");
+ }
+ else {
_timer->setInterval (1000 * 60 * _settings->updateInterval ());
_timer->setInterval (1000 * 60 * _settings->updateInterval ());
+ _timer->start ();
+ Log::instance ()->add (QString ("Timer interval set to %1 ms").arg (1000 * 60 * _settings->updateInterval ()));
+ }
}
}
-void MainWidget::mousePressEvent (QMouseEvent *event)
+bool MainWidget::event (QEvent *event)
{
{
- QMenu menu;
- QAction *settingsAction, *updateAction, *todo;
+ if (event->type () != QEvent::WindowActivate)
+ return QWidget::event (event);
- settingsAction = menu.addAction (tr ("Settings"));
- updateAction = menu.addAction (tr ("Update"));
+ MenuDialog menu (tr ("Yandex.Traffic"));
- todo = menu.exec (event->pos ());
- if (!todo)
- return;
+ menu.addEntry (tr ("Settings")).addEntry (tr ("Update"));
- if (todo == settingsAction)
- settingsDialog ();
- if (todo == updateAction)
- _traffic->update ();
+ switch (menu.run ()) {
+ case 0:
+ settingsDialog ();
+ break;
+ case 1:
+ _traffic->update ();
+ break;
+ }
+
+ return QWidget::event (event);
}
}