diff options
Diffstat (limited to 'qmapwatchlet')
-rw-r--r-- | qmapwatchlet/map-liveview-icon.png | bin | 0 -> 207 bytes | |||
-rw-r--r-- | qmapwatchlet/map-liveview.qml | 26 | ||||
-rw-r--r-- | qmapwatchlet/map-metawatch-digital-icon.png | bin | 0 -> 207 bytes | |||
-rw-r--r-- | qmapwatchlet/map-metawatch-digital.qml | 1 | ||||
-rw-r--r-- | qmapwatchlet/mapview.cpp | 62 | ||||
-rw-r--r-- | qmapwatchlet/mapview.h | 6 | ||||
-rw-r--r-- | qmapwatchlet/qmapwatchlet.pro | 3 | ||||
-rw-r--r-- | qmapwatchlet/qmapwatchletplugin.cpp | 10 | ||||
-rw-r--r-- | qmapwatchlet/qmapwatchletplugin.h | 2 |
9 files changed, 77 insertions, 33 deletions
diff --git a/qmapwatchlet/map-liveview-icon.png b/qmapwatchlet/map-liveview-icon.png Binary files differnew file mode 100644 index 0000000..4e9cd9e --- /dev/null +++ b/qmapwatchlet/map-liveview-icon.png diff --git a/qmapwatchlet/map-liveview.qml b/qmapwatchlet/map-liveview.qml new file mode 100644 index 0000000..e6ab4d4 --- /dev/null +++ b/qmapwatchlet/map-liveview.qml @@ -0,0 +1,26 @@ +import QtQuick 1.0 +import QtMobility.location 1.2 +import com.javispedro.sowatch.qmap 1.0 + +Item { + 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/map-metawatch-digital-icon.png b/qmapwatchlet/map-metawatch-digital-icon.png Binary files differnew file mode 100644 index 0000000..4e9cd9e --- /dev/null +++ b/qmapwatchlet/map-metawatch-digital-icon.png diff --git a/qmapwatchlet/map-metawatch-digital.qml b/qmapwatchlet/map-metawatch-digital.qml index a0732ed..6587636 100644 --- a/qmapwatchlet/map-metawatch-digital.qml +++ b/qmapwatchlet/map-metawatch-digital.qml @@ -14,6 +14,7 @@ MWPage { anchors.fill: parent updateEnabled: watch.active updateInterval: 5000; + decolor: true } Connections { diff --git a/qmapwatchlet/mapview.cpp b/qmapwatchlet/mapview.cpp index 3a0e902..7e78d15 100644 --- a/qmapwatchlet/mapview.cpp +++ b/qmapwatchlet/mapview.cpp @@ -12,7 +12,7 @@ using namespace sowatch; MapView::MapView(QDeclarativeItem *parent) : QDeclarativeItem(parent), - _enabled(false), + _enabled(false), _decolor(false), _arrow(SOWATCH_QML_DIR "/qmapwatchlet/arrow.png"), _mapData(0), _posSource(QGeoPositionInfoSource::createDefaultSource(this)), @@ -123,44 +123,48 @@ void MapView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q 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); + if (_decolor) { + 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<qreal> greys(new qreal[npixels]); + const int w = image.width(), h = image.height(); + const int npixels = w * h; + QScopedArrayPointer<qreal> greys(new qreal[npixels]); - { - QPainter p(&image); - _mapData->paint(&p, option); - } + { + 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<QRgb*>(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; + // Convert to a bitmap using some ad-hoc ugly algorithm... + qreal sum = 0; + for (int y = 0; y < h; y++) { + QRgb *l = reinterpret_cast<QRgb*>(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; + greys[y * w + x] = grey; - sum += grey; + sum += grey; + } } - } - const qreal avg = sum / npixels; - const qreal thr = avg * 0.9; + 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); + 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); + // And render into the watch + painter->drawImage(0, 0, pixmap); + } else { + _mapData->paint(painter, option); + } // Now render the arrow indicator const int centerX = size.width() / 2, centerY = size.height() / 2; diff --git a/qmapwatchlet/mapview.h b/qmapwatchlet/mapview.h index efd4ea5..caa2730 100644 --- a/qmapwatchlet/mapview.h +++ b/qmapwatchlet/mapview.h @@ -21,6 +21,7 @@ class MapView : public QDeclarativeItem Q_OBJECT Q_PROPERTY(bool updateEnabled READ updateEnabled WRITE setUpdateEnabled NOTIFY updateEnabledChanged) Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval NOTIFY updateIntervalChanged) + Q_PROPERTY(bool decolor READ decolor WRITE setDecolor NOTIFY decolorChanged) Q_PROPERTY(qreal zoomLevel READ zoomLevel WRITE setZoomLevel NOTIFY zoomLevelChanged) Q_PROPERTY(QString currentLocationName READ currentLocationName NOTIFY currentLocationNameChanged) @@ -34,6 +35,9 @@ public: int updateInterval() const; void setUpdateInterval(int msec); + bool decolor() const; + void setDecolor(bool decolor) const; + qreal zoomLevel() const; void setZoomLevel(qreal level); @@ -49,6 +53,7 @@ signals: void updateIntervalChanged(); void zoomLevelChanged(); void currentLocationNameChanged(); + void decolorChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); @@ -61,6 +66,7 @@ private slots: private: bool _enabled; + bool _decolor; QImage _arrow; QGeoMapData *_mapData; QGeoPositionInfoSource *_posSource; diff --git a/qmapwatchlet/qmapwatchlet.pro b/qmapwatchlet/qmapwatchlet.pro index 6ed3fcf..9c9c095 100644 --- a/qmapwatchlet/qmapwatchlet.pro +++ b/qmapwatchlet/qmapwatchlet.pro @@ -29,3 +29,6 @@ unix:!symbian { } INSTALLS += target qml_files } + +OTHER_FILES += \ + map-liveview.qml diff --git a/qmapwatchlet/qmapwatchletplugin.cpp b/qmapwatchlet/qmapwatchletplugin.cpp index b34606f..005c2f1 100644 --- a/qmapwatchlet/qmapwatchletplugin.cpp +++ b/qmapwatchlet/qmapwatchletplugin.cpp @@ -35,15 +35,19 @@ QStringList QMapWatchletPlugin::watchlets() return l; } -WatchletPluginInterface::WatchletInfo QMapWatchletPlugin::describeWatchlet(const QString &id) +WatchletPluginInterface::WatchletInfo QMapWatchletPlugin::describeWatchlet(const QString &id, const QString &watchModel) { WatchletInfo info; if (id == QMapWatchlet::myId) { info.name = tr("Map"); - info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/map-icon.png"); + info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/map-icon.png"); + info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/map-" + watchModel + "-icon.png"); + info.visible = true; } else if (id == CompassWatchlet::myId) { info.name = tr("Compass"); - info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/compass-icon.png"); + info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/compass-icon.png"); + info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmapwatchlet/compass-" + watchModel + "-icon.png"); + info.visible = true; } return info; } diff --git a/qmapwatchlet/qmapwatchletplugin.h b/qmapwatchlet/qmapwatchletplugin.h index a6f494a..61553f7 100644 --- a/qmapwatchlet/qmapwatchletplugin.h +++ b/qmapwatchlet/qmapwatchletplugin.h @@ -17,7 +17,7 @@ public: ~QMapWatchletPlugin(); QStringList watchlets(); - WatchletInfo describeWatchlet(const QString &id); + WatchletInfo describeWatchlet(const QString &id, const QString &watchModel); Watchlet* getWatchlet(const QString &id, ConfigKey *config, Watch *watch); static QtMobility::QGeoServiceProvider * geoServiceProvider(); |