From 0bb38d4e1b84a11e8fdfaae2e46b66c101fda40e Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Sun, 19 Aug 2012 17:49:36 +0200 Subject: preparing new compass watchlet --- qmapwatchlet/arrow.png | Bin 2809 -> 0 bytes qmapwatchlet/compass-metawatch-digital.qml | 47 +++++ qmapwatchlet/compasswatchlet.cpp | 11 ++ qmapwatchlet/compasswatchlet.h | 20 +++ qmapwatchlet/icon.png | Bin 207 -> 0 bytes qmapwatchlet/map-arrow.png | Bin 0 -> 2809 bytes qmapwatchlet/map-icon.png | Bin 0 -> 207 bytes qmapwatchlet/map-metawatch-digital.qml | 27 +++ qmapwatchlet/mapview.cc | 273 ----------------------------- qmapwatchlet/mapview.cpp | 273 +++++++++++++++++++++++++++++ qmapwatchlet/metawatch-digital.qml | 27 --- qmapwatchlet/qmapwatchlet.cpp | 2 +- qmapwatchlet/qmapwatchlet.pro | 9 +- qmapwatchlet/qmapwatchletplugin.cpp | 13 +- 14 files changed, 395 insertions(+), 307 deletions(-) delete mode 100644 qmapwatchlet/arrow.png create mode 100644 qmapwatchlet/compass-metawatch-digital.qml create mode 100644 qmapwatchlet/compasswatchlet.cpp create mode 100644 qmapwatchlet/compasswatchlet.h delete mode 100644 qmapwatchlet/icon.png create mode 100644 qmapwatchlet/map-arrow.png create mode 100644 qmapwatchlet/map-icon.png create mode 100644 qmapwatchlet/map-metawatch-digital.qml delete mode 100644 qmapwatchlet/mapview.cc create mode 100644 qmapwatchlet/mapview.cpp delete mode 100644 qmapwatchlet/metawatch-digital.qml diff --git a/qmapwatchlet/arrow.png b/qmapwatchlet/arrow.png deleted file mode 100644 index b0e4d0c..0000000 Binary files a/qmapwatchlet/arrow.png and /dev/null differ diff --git a/qmapwatchlet/compass-metawatch-digital.qml b/qmapwatchlet/compass-metawatch-digital.qml new file mode 100644 index 0000000..9268435 --- /dev/null +++ b/qmapwatchlet/compass-metawatch-digital.qml @@ -0,0 +1,47 @@ +import QtQuick 1.0 +import QtMobility.location 1.2 +import com.javispedro.sowatch.metawatch 1.0 +import com.javispedro.sowatch.qmap 1.0 + +MWPage { + MWTitle { + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + text: qsTr("Trip computer") + icon.source: "trip-icon.png" + } + + PositionSource { + id: gps + active: watch.active + updateInterval: 2000 + } + + function formatSpeed(speed) { + if (speed < 10) { + return speed.toFixed(1); + } else { + return speed.toFixed(0); + } + } + + Column { + anchors.verticalCenter: parent.verticalCenter + MWLabel { + text: qsTr("Speed") + } + MWLabel { + id: speedLabel + text: gps.position.speedValid ? formatSpeed(gps.position.speed) : "" + } + + MWLabel { + text: qsTr("Altitude") + } + } + + Column { + + } +} diff --git a/qmapwatchlet/compasswatchlet.cpp b/qmapwatchlet/compasswatchlet.cpp new file mode 100644 index 0000000..3101955 --- /dev/null +++ b/qmapwatchlet/compasswatchlet.cpp @@ -0,0 +1,11 @@ +#include "tripwatchlet.h" + +using namespace sowatch; + +const QLatin1String TripWatchlet::myId("com.javispedro.sowatch.trip"); + +TripWatchlet::TripWatchlet(WatchServer* server) : + DeclarativeWatchlet(server, myId) +{ + setSource(QUrl(SOWATCH_QML_DIR "/qmapwatchlet/trip-" + server->watch()->model() + ".qml")); +} diff --git a/qmapwatchlet/compasswatchlet.h b/qmapwatchlet/compasswatchlet.h new file mode 100644 index 0000000..185205b --- /dev/null +++ b/qmapwatchlet/compasswatchlet.h @@ -0,0 +1,20 @@ +#ifndef TRIPWATCHLET_H +#define TRIPWATCHLET_H + +#include + +namespace sowatch +{ + +class TripWatchlet : public DeclarativeWatchlet +{ + Q_OBJECT +public: + explicit TripWatchlet(WatchServer* server); + + static const QLatin1String myId; +}; + +} + +#endif // TRIPWATCHLET_H diff --git a/qmapwatchlet/icon.png b/qmapwatchlet/icon.png deleted file mode 100644 index 4e9cd9e..0000000 Binary files a/qmapwatchlet/icon.png and /dev/null differ diff --git a/qmapwatchlet/map-arrow.png b/qmapwatchlet/map-arrow.png new file mode 100644 index 0000000..b0e4d0c Binary files /dev/null and b/qmapwatchlet/map-arrow.png differ diff --git a/qmapwatchlet/map-icon.png b/qmapwatchlet/map-icon.png new file mode 100644 index 0000000..4e9cd9e Binary files /dev/null and b/qmapwatchlet/map-icon.png differ diff --git a/qmapwatchlet/map-metawatch-digital.qml b/qmapwatchlet/map-metawatch-digital.qml new file mode 100644 index 0000000..9c054a4 --- /dev/null +++ b/qmapwatchlet/map-metawatch-digital.qml @@ -0,0 +1,27 @@ +import QtQuick 1.0 +import QtMobility.location 1.2 +import com.javispedro.sowatch.metawatch 1.0 +import com.javispedro.sowatch.qmap 1.0 + +MWPage { + MapView { + id: map + anchors.fill: parent; + updateEnabled: watch.active + updateInterval: 5000; + } + + Connections { + target: watch + onButtonPressed : { + switch(button) { + case 1: + map.zoomLevel -= 1; + break; + case 2: + map.zoomLevel += 1; + break; + } + } + } +} diff --git a/qmapwatchlet/mapview.cc b/qmapwatchlet/mapview.cc deleted file mode 100644 index 5972e07..0000000 --- a/qmapwatchlet/mapview.cc +++ /dev/null @@ -1,273 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "qmapwatchletplugin.h" -#include "mapview.h" - -QTM_USE_NAMESPACE -using namespace sowatch; - -MapView::MapView(QDeclarativeItem *parent) : - QDeclarativeItem(parent), - _enabled(false), - _arrow(SOWATCH_QML_DIR "/qmapwatchlet/arrow.png"), - _mapData(0), - _posSource(QGeoPositionInfoSource::createDefaultSource(this)), - _searchArea(0), _searchReply(0) -{ - QGeoServiceProvider *provider = QMapWatchletPlugin::geoServiceProvider(); - if (!provider) { - qWarning() << "No geo service provider for map watchlet!"; - } - - QGeoMappingManager *manager = provider->mappingManager(); - _mapData = manager->createMapData(); - - if (_mapData) { - _mapData->init(); - _mapData->setMapType(QGraphicsGeoMap::StreetMap); - - _mapData->setZoomLevel(12); - - connect(_mapData, SIGNAL(zoomLevelChanged(qreal)), SIGNAL(zoomLevelChanged())); - connect(_mapData, SIGNAL(updateMapDisplay(QRectF)), SLOT(handleMapChanged(QRectF))); - } else { - qWarning() << "No mapdata!"; - } - - if (_posSource) { - connect(_posSource, SIGNAL(positionUpdated(QGeoPositionInfo)), - SLOT(handlePositionUpdate(QGeoPositionInfo))); - _posSource->lastKnownPosition(); - } else { - qWarning() << "No position source for moving map!"; - } - - setFlag(QGraphicsItem::ItemHasNoContents, false); -} - -MapView::~MapView() -{ - delete _mapData; - delete _searchReply; - delete _searchArea; -} - -bool MapView::updateEnabled() const -{ - return _enabled; -} - -void MapView::setUpdateEnabled(bool enabled) -{ - if (_posSource && _enabled != enabled) { - if (enabled) { - qDebug() << "Start position updates"; - _posSource->startUpdates(); - } else { - qDebug() << "Stop position updates"; - _posSource->stopUpdates(); - } - _enabled = enabled; - - emit updateEnabledChanged(); - } - -} - -int MapView::updateInterval() const -{ - if (_posSource) { - return _posSource->updateInterval(); - } else { - return 0; - } -} - -void MapView::setUpdateInterval(int msec) -{ - if (_posSource) { - _posSource->setUpdateInterval(msec); - emit updateIntervalChanged(); - } -} - -qreal MapView::zoomLevel() const -{ - if (_mapData) { - return _mapData->zoomLevel(); - } else { - return -1.0; - } -} - -void MapView::setZoomLevel(qreal level) -{ - if (_mapData) { - _mapData->setZoomLevel(level); - qDebug() << "new zoom level" << level; - } -} - -QString MapView::currentLocationName() const -{ - return _posName; -} - -void MapView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -{ - Q_UNUSED(widget); - if (_mapData) { - // Render to an image first - const QSize size(_mapData->windowSize().toSize()); - QImage image(size, QImage::Format_RGB32); - QImage pixmap(size, QImage::Format_MonoLSB); - - const int w = image.width(), h = image.height(); - const int npixels = w * h; - QScopedArrayPointer greys(new qreal[npixels]); - - { - QPainter p(&image); - _mapData->paint(&p, option); - } - - // Convert to a bitmap using some ad-hoc ugly algorithm... - qreal sum = 0; - for (int y = 0; y < h; y++) { - QRgb *l = reinterpret_cast(image.scanLine(y)); - for (int x = 0; x < w; x++) { - const int r = qRed(l[x]), g = qGreen(l[x]), b = qBlue(l[x]); - const qreal grey = r * 0.299f + g * 0.587f + b * 0.114f; - - greys[y * w + x] = grey; - - sum += grey; - } - } - - const qreal avg = sum / npixels; - const qreal thr = avg * 0.9; - - for (int y = 0; y < h; y++) { - for (int x = 0; x < w; x++) { - // TODO: Optimize - pixmap.setPixel(x, y, greys[y * w + x] >= thr ? Qt::color1 : Qt::color0); - } - } - - // And render into the watch - painter->drawImage(0, 0, pixmap); - - // Now render the arrow indicator - const int centerX = size.width() / 2, centerY = size.height() / 2; - painter->save(); - painter->translate(centerX, centerY); - if (_pos.hasAttribute(QGeoPositionInfo::Direction)) { - painter->rotate(_pos.attribute(QGeoPositionInfo::Direction)); - } - painter->drawImage(-_arrow.width() / 2, -_arrow.height() / 2, _arrow); - painter->restore(); - } -} - -void MapView::updateCurrentLocationName() -{ - if (_searchReply) { - qDebug() << "Search already in progress"; - return; - } - QGeoServiceProvider *provider = QMapWatchletPlugin::geoServiceProvider(); - if (!provider) { - qWarning() << "No geo service provider for map watchlet!"; - } - - // Lifetime of 'bounds' in call to reverseGeocode() is not specified anywhere. - // So we keep it "forever" until the next call to reverseGeocode(). - // which is ... now. - delete _searchArea; - - // Create the new bounds object. - if (_mapData) { - _searchArea = new QGeoBoundingBox(_mapData->viewport()); - } else { - _searchArea = 0; - } - - _posName.clear(); - - qDebug() << "Start request of current location"; - - QGeoSearchManager *manager = provider->searchManager(); - _searchReply = manager->reverseGeocode(_pos.coordinate(), _searchArea); - connect(_searchReply, SIGNAL(finished()), - SLOT(handleCurrentLocationNameSearchFinished())); - connect(_searchReply, SIGNAL(error(QGeoSearchReply::Error,QString)), - SLOT(handleCurrentLocationNameSearchError(QGeoSearchReply::Error,QString))); -} - -void MapView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) -{ - Q_UNUSED(oldGeometry); - if (_mapData) { - _mapData->setWindowSize(newGeometry.size()); - } -} - -void MapView::handlePositionUpdate(const QGeoPositionInfo& info) -{ - _pos = info; - if (_mapData) { - _mapData->setCenter(info.coordinate()); - } -} - -void MapView::handleMapChanged(const QRectF &rect) -{ - update(rect); -} - -void MapView::handleCurrentLocationNameSearchFinished() -{ - if (_searchReply) { - if (_searchReply->error() == QGeoSearchReply::NoError) { - QList places = _searchReply->places(); - qDebug() << "Current location name search got " << places.size() << " results"; - foreach (const QGeoPlace& place, places) { - QGeoAddress address = place.address(); - qDebug() << " " << address.street() << " - " << address.district() << " - " << address.city(); - } - if (!places.isEmpty()) { - QGeoAddress address = places.first().address(); - if (!address.street().isEmpty()) { - _posName = address.street(); - } else if (!address.district().isEmpty()) { - _posName = address.district(); - } else if (!address.city().isEmpty()) { - _posName = address.city(); - } else { - _posName.clear(); - } - qDebug() << "Current location name search finished:" << _posName; - emit currentLocationNameChanged(); - } - } else { - qDebug() << "Current location name search finished with error:" - << _searchReply->error(); - } - _searchReply->deleteLater(); - _searchReply = 0; - } -} - -void MapView::handleCurrentLocationNameSearchError(QGeoSearchReply::Error error, const QString &errorString) -{ - qWarning() << "Current location name search error: " << errorString; - if (_searchReply) { - _searchReply->deleteLater(); - _searchReply = 0; - } -} diff --git a/qmapwatchlet/mapview.cpp b/qmapwatchlet/mapview.cpp new file mode 100644 index 0000000..5972e07 --- /dev/null +++ b/qmapwatchlet/mapview.cpp @@ -0,0 +1,273 @@ +#include +#include +#include +#include +#include +#include +#include "qmapwatchletplugin.h" +#include "mapview.h" + +QTM_USE_NAMESPACE +using namespace sowatch; + +MapView::MapView(QDeclarativeItem *parent) : + QDeclarativeItem(parent), + _enabled(false), + _arrow(SOWATCH_QML_DIR "/qmapwatchlet/arrow.png"), + _mapData(0), + _posSource(QGeoPositionInfoSource::createDefaultSource(this)), + _searchArea(0), _searchReply(0) +{ + QGeoServiceProvider *provider = QMapWatchletPlugin::geoServiceProvider(); + if (!provider) { + qWarning() << "No geo service provider for map watchlet!"; + } + + QGeoMappingManager *manager = provider->mappingManager(); + _mapData = manager->createMapData(); + + if (_mapData) { + _mapData->init(); + _mapData->setMapType(QGraphicsGeoMap::StreetMap); + + _mapData->setZoomLevel(12); + + connect(_mapData, SIGNAL(zoomLevelChanged(qreal)), SIGNAL(zoomLevelChanged())); + connect(_mapData, SIGNAL(updateMapDisplay(QRectF)), SLOT(handleMapChanged(QRectF))); + } else { + qWarning() << "No mapdata!"; + } + + if (_posSource) { + connect(_posSource, SIGNAL(positionUpdated(QGeoPositionInfo)), + SLOT(handlePositionUpdate(QGeoPositionInfo))); + _posSource->lastKnownPosition(); + } else { + qWarning() << "No position source for moving map!"; + } + + setFlag(QGraphicsItem::ItemHasNoContents, false); +} + +MapView::~MapView() +{ + delete _mapData; + delete _searchReply; + delete _searchArea; +} + +bool MapView::updateEnabled() const +{ + return _enabled; +} + +void MapView::setUpdateEnabled(bool enabled) +{ + if (_posSource && _enabled != enabled) { + if (enabled) { + qDebug() << "Start position updates"; + _posSource->startUpdates(); + } else { + qDebug() << "Stop position updates"; + _posSource->stopUpdates(); + } + _enabled = enabled; + + emit updateEnabledChanged(); + } + +} + +int MapView::updateInterval() const +{ + if (_posSource) { + return _posSource->updateInterval(); + } else { + return 0; + } +} + +void MapView::setUpdateInterval(int msec) +{ + if (_posSource) { + _posSource->setUpdateInterval(msec); + emit updateIntervalChanged(); + } +} + +qreal MapView::zoomLevel() const +{ + if (_mapData) { + return _mapData->zoomLevel(); + } else { + return -1.0; + } +} + +void MapView::setZoomLevel(qreal level) +{ + if (_mapData) { + _mapData->setZoomLevel(level); + qDebug() << "new zoom level" << level; + } +} + +QString MapView::currentLocationName() const +{ + return _posName; +} + +void MapView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + Q_UNUSED(widget); + if (_mapData) { + // Render to an image first + const QSize size(_mapData->windowSize().toSize()); + QImage image(size, QImage::Format_RGB32); + QImage pixmap(size, QImage::Format_MonoLSB); + + const int w = image.width(), h = image.height(); + const int npixels = w * h; + QScopedArrayPointer greys(new qreal[npixels]); + + { + QPainter p(&image); + _mapData->paint(&p, option); + } + + // Convert to a bitmap using some ad-hoc ugly algorithm... + qreal sum = 0; + for (int y = 0; y < h; y++) { + QRgb *l = reinterpret_cast(image.scanLine(y)); + for (int x = 0; x < w; x++) { + const int r = qRed(l[x]), g = qGreen(l[x]), b = qBlue(l[x]); + const qreal grey = r * 0.299f + g * 0.587f + b * 0.114f; + + greys[y * w + x] = grey; + + sum += grey; + } + } + + const qreal avg = sum / npixels; + const qreal thr = avg * 0.9; + + for (int y = 0; y < h; y++) { + for (int x = 0; x < w; x++) { + // TODO: Optimize + pixmap.setPixel(x, y, greys[y * w + x] >= thr ? Qt::color1 : Qt::color0); + } + } + + // And render into the watch + painter->drawImage(0, 0, pixmap); + + // Now render the arrow indicator + const int centerX = size.width() / 2, centerY = size.height() / 2; + painter->save(); + painter->translate(centerX, centerY); + if (_pos.hasAttribute(QGeoPositionInfo::Direction)) { + painter->rotate(_pos.attribute(QGeoPositionInfo::Direction)); + } + painter->drawImage(-_arrow.width() / 2, -_arrow.height() / 2, _arrow); + painter->restore(); + } +} + +void MapView::updateCurrentLocationName() +{ + if (_searchReply) { + qDebug() << "Search already in progress"; + return; + } + QGeoServiceProvider *provider = QMapWatchletPlugin::geoServiceProvider(); + if (!provider) { + qWarning() << "No geo service provider for map watchlet!"; + } + + // Lifetime of 'bounds' in call to reverseGeocode() is not specified anywhere. + // So we keep it "forever" until the next call to reverseGeocode(). + // which is ... now. + delete _searchArea; + + // Create the new bounds object. + if (_mapData) { + _searchArea = new QGeoBoundingBox(_mapData->viewport()); + } else { + _searchArea = 0; + } + + _posName.clear(); + + qDebug() << "Start request of current location"; + + QGeoSearchManager *manager = provider->searchManager(); + _searchReply = manager->reverseGeocode(_pos.coordinate(), _searchArea); + connect(_searchReply, SIGNAL(finished()), + SLOT(handleCurrentLocationNameSearchFinished())); + connect(_searchReply, SIGNAL(error(QGeoSearchReply::Error,QString)), + SLOT(handleCurrentLocationNameSearchError(QGeoSearchReply::Error,QString))); +} + +void MapView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + Q_UNUSED(oldGeometry); + if (_mapData) { + _mapData->setWindowSize(newGeometry.size()); + } +} + +void MapView::handlePositionUpdate(const QGeoPositionInfo& info) +{ + _pos = info; + if (_mapData) { + _mapData->setCenter(info.coordinate()); + } +} + +void MapView::handleMapChanged(const QRectF &rect) +{ + update(rect); +} + +void MapView::handleCurrentLocationNameSearchFinished() +{ + if (_searchReply) { + if (_searchReply->error() == QGeoSearchReply::NoError) { + QList places = _searchReply->places(); + qDebug() << "Current location name search got " << places.size() << " results"; + foreach (const QGeoPlace& place, places) { + QGeoAddress address = place.address(); + qDebug() << " " << address.street() << " - " << address.district() << " - " << address.city(); + } + if (!places.isEmpty()) { + QGeoAddress address = places.first().address(); + if (!address.street().isEmpty()) { + _posName = address.street(); + } else if (!address.district().isEmpty()) { + _posName = address.district(); + } else if (!address.city().isEmpty()) { + _posName = address.city(); + } else { + _posName.clear(); + } + qDebug() << "Current location name search finished:" << _posName; + emit currentLocationNameChanged(); + } + } else { + qDebug() << "Current location name search finished with error:" + << _searchReply->error(); + } + _searchReply->deleteLater(); + _searchReply = 0; + } +} + +void MapView::handleCurrentLocationNameSearchError(QGeoSearchReply::Error error, const QString &errorString) +{ + qWarning() << "Current location name search error: " << errorString; + if (_searchReply) { + _searchReply->deleteLater(); + _searchReply = 0; + } +} diff --git a/qmapwatchlet/metawatch-digital.qml b/qmapwatchlet/metawatch-digital.qml deleted file mode 100644 index 9c054a4..0000000 --- a/qmapwatchlet/metawatch-digital.qml +++ /dev/null @@ -1,27 +0,0 @@ -import QtQuick 1.0 -import QtMobility.location 1.2 -import com.javispedro.sowatch.metawatch 1.0 -import com.javispedro.sowatch.qmap 1.0 - -MWPage { - MapView { - id: map - anchors.fill: parent; - updateEnabled: watch.active - updateInterval: 5000; - } - - Connections { - target: watch - onButtonPressed : { - switch(button) { - case 1: - map.zoomLevel -= 1; - break; - case 2: - map.zoomLevel += 1; - break; - } - } - } -} diff --git a/qmapwatchlet/qmapwatchlet.cpp b/qmapwatchlet/qmapwatchlet.cpp index 82132db..efc478e 100644 --- a/qmapwatchlet/qmapwatchlet.cpp +++ b/qmapwatchlet/qmapwatchlet.cpp @@ -8,6 +8,6 @@ QMapWatchlet::QMapWatchlet(WatchServer* server) : DeclarativeWatchlet(server, myId) { setFullUpdateMode(true); - setSource(QUrl(SOWATCH_QML_DIR "/qmapwatchlet/" + server->watch()->model() + ".qml")); + setSource(QUrl(SOWATCH_QML_DIR "/qmapwatchlet/map-" + server->watch()->model() + ".qml")); } diff --git a/qmapwatchlet/qmapwatchlet.pro b/qmapwatchlet/qmapwatchlet.pro index 9bfb755..ab51e30 100644 --- a/qmapwatchlet/qmapwatchlet.pro +++ b/qmapwatchlet/qmapwatchlet.pro @@ -5,11 +5,14 @@ CONFIG += plugin CONFIG += mobility MOBILITY += location -SOURCES += qmapwatchletplugin.cpp qmapwatchlet.cpp mapview.cc +SOURCES += qmapwatchletplugin.cpp qmapwatchlet.cpp mapview.cpp \ + compasswatchlet.cpp -HEADERS += qmapwatchletplugin.h qmapwatchlet.h mapview.h +HEADERS += qmapwatchletplugin.h qmapwatchlet.h mapview.h \ + compasswatchlet.h -qml_files.files = metawatch-digital.qml icon.png arrow.png +qml_files.files = map-metawatch-digital.qml map-icon.png map-arrow.png \ + compass-metawatch-digital.qml compass-icon.png LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch INCLUDEPATH += $$PWD/../libsowatch diff --git a/qmapwatchlet/qmapwatchletplugin.cpp b/qmapwatchlet/qmapwatchletplugin.cpp index 9450558..5beaf7e 100644 --- a/qmapwatchlet/qmapwatchletplugin.cpp +++ b/qmapwatchlet/qmapwatchletplugin.cpp @@ -1,6 +1,7 @@ #include "qmapwatchlet.h" #include "mapview.h" #include "qmapwatchletplugin.h" +#include "tripwatchlet.h" using namespace sowatch; QTM_USE_NAMESPACE @@ -35,9 +36,15 @@ QStringList QMapWatchletPlugin::watchlets() WatchletPluginInterface::WatchletInfo QMapWatchletPlugin::describeWatchlet(const QString &id) { WatchletInfo info; - if (id != QMapWatchlet::myId) return info; - info.name = tr("Map"); - info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/icon.png"); + if (id == QMapWatchlet::myId) { + info.name = tr("Map"); + info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/icon.png"); + } else if (id == TripWatchlet::myId) { + info.name = tr("Trip computer"); + info.icon = + } + if (id != ) return info; + return info; } -- cgit v1.2.3