summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libsowatch/watchletplugininterface.h9
-rw-r--r--libsowatch/watchletsmodel.cpp15
-rw-r--r--libsowatch/watchletsmodel.h11
-rw-r--r--libsowatch/watchserver.cpp1
-rw-r--r--liveview/liveview.cpp117
-rw-r--r--liveview/liveview.h17
-rw-r--r--liveview/liveviewpaintengine.cpp4
-rw-r--r--metawatchwatchlets/metawatchwatchletsplugin.cpp14
-rw-r--r--metawatchwatchlets/metawatchwatchletsplugin.h2
-rw-r--r--nekowatchlet/liveview-icon.pngbin0 -> 225 bytes
-rw-r--r--nekowatchlet/metawatch-digital-icon.pngbin0 -> 225 bytes
-rw-r--r--nekowatchlet/nekowatchletplugin.cpp6
-rw-r--r--nekowatchlet/nekowatchletplugin.h2
-rw-r--r--notificationswatchlet/notificationswatchletplugin.cpp6
-rw-r--r--notificationswatchlet/notificationswatchletplugin.h2
-rw-r--r--qmafwwatchlet/qmafwwatchletplugin.h2
-rw-r--r--qmapwatchlet/map-liveview-icon.pngbin0 -> 207 bytes
-rw-r--r--qmapwatchlet/map-liveview.qml26
-rw-r--r--qmapwatchlet/map-metawatch-digital-icon.pngbin0 -> 207 bytes
-rw-r--r--qmapwatchlet/map-metawatch-digital.qml1
-rw-r--r--qmapwatchlet/mapview.cpp62
-rw-r--r--qmapwatchlet/mapview.h6
-rw-r--r--qmapwatchlet/qmapwatchlet.pro3
-rw-r--r--qmapwatchlet/qmapwatchletplugin.cpp10
-rw-r--r--qmapwatchlet/qmapwatchletplugin.h2
-rw-r--r--qmsgwatchlet/qmsgwatchletplugin.cpp6
-rw-r--r--qmsgwatchlet/qmsgwatchletplugin.h2
-rw-r--r--qorgwatchlet/qorgwatchletplugin.cpp6
-rw-r--r--qorgwatchlet/qorgwatchletplugin.h2
-rw-r--r--sowatchui/configuredwatchletsmodel.cpp8
-rw-r--r--sysinfowatchlet/sysinfoplugin.cpp6
-rw-r--r--sysinfowatchlet/sysinfoplugin.h2
32 files changed, 252 insertions, 98 deletions
diff --git a/libsowatch/watchletplugininterface.h b/libsowatch/watchletplugininterface.h
index ed90467..4c135b3 100644
--- a/libsowatch/watchletplugininterface.h
+++ b/libsowatch/watchletplugininterface.h
@@ -22,17 +22,18 @@ public:
struct WatchletInfo {
QString name;
QUrl icon;
- bool hidden;
+ QUrl phoneIcon;
+ bool visible;
QUrl configQmlUrl;
- inline WatchletInfo() :
- hidden(false)
+ inline WatchletInfo() : visible(false)
{
+
}
};
virtual QStringList watchlets() = 0;
- virtual WatchletInfo describeWatchlet(const QString& id) = 0;
+ virtual WatchletInfo describeWatchlet(const QString& id, const QString& watchModel) = 0;
virtual Watchlet* getWatchlet(const QString& id, ConfigKey *settings, Watch *watch) = 0;
};
diff --git a/libsowatch/watchletsmodel.cpp b/libsowatch/watchletsmodel.cpp
index 9e06928..5989872 100644
--- a/libsowatch/watchletsmodel.cpp
+++ b/libsowatch/watchletsmodel.cpp
@@ -11,10 +11,21 @@ WatchletsModel::WatchletsModel(QObject *parent) :
{
QHash<int, QByteArray> roles = roleNames();
roles[TitleRole] = QByteArray("title");
+ roles[IconRole] = QByteArray("icon");
roles[ObjectRole] = QByteArray("object");
setRoleNames(roles);
}
+QString WatchletsModel::watchModel() const
+{
+ return _watchModel;
+}
+
+void WatchletsModel::setWatchModel(const QString &s)
+{
+ _watchModel = s;
+}
+
int WatchletsModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : _list.count();
@@ -35,6 +46,8 @@ QVariant WatchletsModel::data(const QModelIndex &index, int role) const
switch (role) {
case Qt::DisplayRole:
return QVariant::fromValue(info.name);
+ case IconRole:
+ return QVariant::fromValue(info.icon);
case ObjectRole:
return QVariant::fromValue(const_cast<sowatch::Watchlet*>(watchlet));
}
@@ -109,7 +122,7 @@ WatchletsModel::WatchletInfo WatchletsModel::getInfoForWatchlet(const Watchlet *
QString id = w->id();
WatchletPluginInterface *plugin = Registry::registry()->getWatchletPlugin(id);
if (plugin) {
- return plugin->describeWatchlet(id);
+ return plugin->describeWatchlet(id, _watchModel);
} else {
return WatchletInfo();
}
diff --git a/libsowatch/watchletsmodel.h b/libsowatch/watchletsmodel.h
index cdb6be4..3bbabf9 100644
--- a/libsowatch/watchletsmodel.h
+++ b/libsowatch/watchletsmodel.h
@@ -12,15 +12,20 @@ namespace sowatch
class WatchletsModel : public QAbstractListModel
{
Q_OBJECT
+ Q_PROPERTY(QString watchModel READ watchModel WRITE setWatchModel NOTIFY watchModelChanged)
public:
explicit WatchletsModel(QObject *parent = 0);
enum DataRoles {
ObjectRole = Qt::UserRole,
- TitleRole = Qt::DisplayRole
+ TitleRole = Qt::DisplayRole,
+ IconRole = Qt::DecorationRole
};
+ QString watchModel() const;
+ void setWatchModel(const QString& s);
+
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
@@ -35,14 +40,16 @@ public:
void remove(int position);
signals:
+ void watchModelChanged();
void modelChanged();
protected:
typedef WatchletPluginInterface::WatchletInfo WatchletInfo;
- static WatchletInfo getInfoForWatchlet(const Watchlet *w);
+ WatchletInfo getInfoForWatchlet(const Watchlet *w);
private:
+ QString _watchModel;
QList<Watchlet*> _list;
QList<WatchletInfo> _info;
diff --git a/libsowatch/watchserver.cpp b/libsowatch/watchserver.cpp
index eaea040..da93730 100644
--- a/libsowatch/watchserver.cpp
+++ b/libsowatch/watchserver.cpp
@@ -30,6 +30,7 @@ WatchServer::WatchServer(Watch* watch, QObject* parent) :
_syncTimeTimer->setSingleShot(true);
_syncTimeTimer->setInterval(24 * 3600 * 1000); // Once a day
+ _watchlets->setWatchModel(_watch->model());
_watch->setWatchletsModel(_watchlets);
}
diff --git a/liveview/liveview.cpp b/liveview/liveview.cpp
index 746c04a..c36f944 100644
--- a/liveview/liveview.cpp
+++ b/liveview/liveview.cpp
@@ -16,6 +16,7 @@ LiveView::LiveView(ConfigKey* settings, QObject* parent) :
_screenWidth(0), _screenHeight(0),
_mode(RootMenuMode),
_paintEngine(0),
+ _rootMenuFirstWatchlet(0),
_sendTimer(new QTimer(this))
{
_sendTimer->setInterval(DelayBetweenMessages);
@@ -90,6 +91,7 @@ void LiveView::setDateTime(const QDateTime& dateTime)
// the phone to be sending it.
// Wonder what will happen during DST changes?
// Do nothing here.
+ Q_UNUSED(dateTime);
}
void LiveView::queryDateTime()
@@ -154,6 +156,7 @@ void LiveView::setWatchletsModel(WatchletsModel *model)
_watchlets = model;
if (_watchlets) {
connect(_watchlets, SIGNAL(modelChanged()), SLOT(handleWatchletsChanged()));
+ handleWatchletsChanged();
}
}
@@ -164,13 +167,9 @@ QImage* LiveView::image()
void LiveView::renderImage(int x, int y, const QImage &image)
{
- QBuffer buffer;
- buffer.open(QIODevice::WriteOnly);
- if (image.save(&buffer, "PNG")) {
- displayBitmap(x, y, buffer.buffer());
- qDebug() << "render image at" << x << 'x' << y << "size" << image.size();
- } else {
- qWarning() << "Failed to encode image";
+ QByteArray data = encodeImage(image);
+ if (!data.isEmpty()) {
+ displayBitmap(x, y, data);
}
}
@@ -194,10 +193,62 @@ void LiveView::desetupBluetoothWatch()
_sendingMsgs.clear();
}
+void LiveView::recreateWatchletsMenu()
+{
+ // Erase all current watchlets frm the menu
+ QList<RootMenuItem>::iterator it = _rootMenu.begin();
+ it += _rootMenuFirstWatchlet;
+ _rootMenu.erase(it, _rootMenu.end());
+
+ if (_watchlets) {
+ const int num_watchlets = _watchlets->size();
+ for (int i = 0; i < num_watchlets; i++) {
+ RootMenuItem item;
+ QModelIndex index = _watchlets->index(i);
+ item.type = MenuOther;
+ item.title = _watchlets->data(index, WatchletsModel::TitleRole).toString();
+ item.icon = encodeImage(_watchlets->data(index, WatchletsModel::IconRole).toUrl());
+ item.unread = 0;
+ item.watchletId = _watchlets->at(i)->id();
+ _rootMenu.append(item);
+ }
+ }
+}
+
void LiveView::refreshMenu()
{
if (_mode == RootMenuMode) {
- setMenuSize(3);
+ setMenuSize(_rootMenu.size());
+ }
+}
+
+QByteArray LiveView::encodeImage(const QImage& image) const
+{
+ QBuffer buffer;
+ buffer.open(QIODevice::WriteOnly);
+ if (image.save(&buffer, "PNG")) {
+ return buffer.buffer();
+ } else {
+ qWarning() << "Failed to encode image";
+ return QByteArray();
+ }
+}
+
+QByteArray LiveView::encodeImage(const QUrl& url) const
+{
+ if (url.encodedPath().endsWith(".png")) {
+ // Just load the image
+ QFile f(url.toLocalFile());
+ if (f.open(QIODevice::ReadOnly)) {
+ qDebug() << "Encoding local PNG" << url.toLocalFile();
+ return f.readAll();
+ } else {
+ qWarning() << "Could not read image:" << url.toString();
+ return QByteArray();
+ }
+ } else {
+ qDebug() << "Encoding local nonPNG" << url.toLocalFile();
+ return encodeImage(QImage(url.toLocalFile()));
}
}
@@ -359,13 +410,11 @@ void LiveView::handleNavigation(const Message &msg)
return;
}
- int menu_id = msg.data[4];
- int item_id = msg.data[3];
- int event = msg.data[2];
+ int menu_id = static_cast<unsigned char>(msg.data[4]);
+ int item_id = static_cast<unsigned char>(msg.data[3]);
+ int event = static_cast<unsigned char>(msg.data[2]);
qDebug() << "navigation" << event << item_id << menu_id;
-
-
switch (event) {
case SelectLongPress:
if (_mode == ApplicationMode) {
@@ -375,8 +424,22 @@ void LiveView::handleNavigation(const Message &msg)
}
break;
case SelectMenu:
- sendResponse(NavigationResponse, ResponseOk);
- emit watchletRequested("com.javispedro.sowatch.neko");
+ if (item_id <= _rootMenu.size()) {
+ sendResponse(NavigationResponse, ResponseError);
+
+ switch(_rootMenu[item_id].type) {
+ case MenuNotificationList:
+ Q_ASSERT(false); // TODO
+ break;
+ case MenuOther:
+ emit watchletRequested(_rootMenu[item_id].watchletId);
+ break;
+ }
+
+ } else {
+ sendResponse(NavigationResponse, ResponseError);
+ }
+
return;
}
@@ -387,22 +450,13 @@ void LiveView::handleNavigation(const Message &msg)
void LiveView::handleMenuItemsRequest(const Message &msg)
{
qDebug() << "Sending menu items";
- QFile icon_file;
-
- icon_file.setFileName(SOWATCH_RESOURCES_DIR "/liveview/graphics/menu_notifications.png");
- icon_file.open(QIODevice::ReadOnly);
- sendMenuItem(0, MenuNotificationList, 2, tr("Notifications"), icon_file.readAll());
- icon_file.close();
-
- icon_file.setFileName(SOWATCH_RESOURCES_DIR "/liveview/graphics/menu_missed_calls.png");
- icon_file.open(QIODevice::ReadOnly);
- sendMenuItem(1, MenuNotificationList, 1, tr("Missed calls"), icon_file.readAll());
- icon_file.close();
-
- icon_file.setFileName(SOWATCH_RESOURCES_DIR "/liveview/graphics/menu_messages.png");
- icon_file.open(QIODevice::ReadOnly);
- sendMenuItem(2, MenuOther, 0, tr("Messages"), icon_file.readAll());
- icon_file.close();
+ if (_mode == RootMenuMode) {
+ for (int i = 0; i < _rootMenu.size(); i++) {
+ qDebug() << "Sending one menu item";
+ sendMenuItem(i, _rootMenu[i].type, _rootMenu[i].unread,
+ _rootMenu[i].title, _rootMenu[i].icon);
+ }
+ }
}
void LiveView::handleDateTimeRequest(const Message &msg)
@@ -567,6 +621,7 @@ void LiveView::handleSendTimerTick()
void LiveView::handleWatchletsChanged()
{
+ recreateWatchletsMenu();
if (_connected) {
refreshMenu();
}
diff --git a/liveview/liveview.h b/liveview/liveview.h
index bd8a3ac..4df7f10 100644
--- a/liveview/liveview.h
+++ b/liveview/liveview.h
@@ -120,12 +120,25 @@ protected:
{ }
};
+ struct RootMenuItem {
+ MenuItemType type;
+ QByteArray icon;
+ QString title;
+ int unread;
+ QString watchletId;
+ };
+
void setupBluetoothWatch();
void desetupBluetoothWatch();
+ /** Recreate the device menu (after watchlets change) */
+ void recreateWatchletsMenu();
/** Update the device menu (after a power on, etc.) */
void refreshMenu();
+ QByteArray encodeImage(const QImage& image) const;
+ QByteArray encodeImage(const QUrl& url) const;
+
protected:
void send(const Message& msg);
void sendResponse(MessageType type, ResponseType response);
@@ -169,6 +182,10 @@ private:
mutable LiveViewPaintEngine* _paintEngine;
QImage _image;
+ QList<RootMenuItem> _rootMenu;
+ /** Keeps the index of the first watchlet. */
+ int _rootMenuFirstWatchlet;
+
/** Message outbox queue. */
QQueue<Message> _sendingMsgs;
QTimer* _sendTimer;
diff --git a/liveview/liveviewpaintengine.cpp b/liveview/liveviewpaintengine.cpp
index 1caa1e3..9f7ffec 100644
--- a/liveview/liveviewpaintengine.cpp
+++ b/liveview/liveviewpaintengine.cpp
@@ -35,7 +35,7 @@ void LiveViewPaintEngine::drawRects(const QRectF *rects, int rectCount)
for (i = 0; i < rectCount; i++) {
const QRectF& r = rects[i];
if (_hasBrush && fillsEntireImage(r.toRect()) && _isBrushBlack) {
- _watch->clear();
+ //_watch->clear();
_damaged = QRegion();
continue;
}
@@ -58,7 +58,7 @@ void LiveViewPaintEngine::drawRects(const QRect *rects, int rectCount)
for (i = 0; i < rectCount; i++) {
const QRect& r = rects[i];
if (_hasBrush && fillsEntireImage(r) && _isBrushBlack) {
- _watch->clear();
+ //_watch->clear();
_damaged = QRegion();
continue;
}
diff --git a/metawatchwatchlets/metawatchwatchletsplugin.cpp b/metawatchwatchlets/metawatchwatchletsplugin.cpp
index 601e659..4acf721 100644
--- a/metawatchwatchlets/metawatchwatchletsplugin.cpp
+++ b/metawatchwatchlets/metawatchwatchletsplugin.cpp
@@ -20,15 +20,19 @@ QStringList MetaWatchWatchletsPlugin::watchlets()
return l;
}
-WatchletPluginInterface::WatchletInfo MetaWatchWatchletsPlugin::describeWatchlet(const QString &id)
+WatchletPluginInterface::WatchletInfo MetaWatchWatchletsPlugin::describeWatchlet(const QString &id, const QString& watchModel)
{
WatchletInfo info;
if (id == MetaWatchFaceWatchlet::myId) {
- info.name = "MetaWatch Face Watchlet";
- info.hidden = true;
+ if (watchModel == "metawatch-digital") {
+ info.name = "MetaWatch Face Watchlet";
+ // Keep non visible
+ }
} else if (id == MetaWatchNotificationWatchlet::myId) {
- info.name = "MetaWatch Notification Watchlet";
- info.hidden = true;
+ if (watchModel == "metawatch-digital") {
+ info.name = "MetaWatch Notification Watchlet";
+ // Keep non visible
+ }
}
return info;
}
diff --git a/metawatchwatchlets/metawatchwatchletsplugin.h b/metawatchwatchlets/metawatchwatchletsplugin.h
index a7ba34b..44fd944 100644
--- a/metawatchwatchlets/metawatchwatchletsplugin.h
+++ b/metawatchwatchlets/metawatchwatchletsplugin.h
@@ -16,7 +16,7 @@ public:
~MetaWatchWatchletsPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString& watchModel);
Watchlet* getWatchlet(const QString& id, ConfigKey *settings, Watch* watch);
};
diff --git a/nekowatchlet/liveview-icon.png b/nekowatchlet/liveview-icon.png
new file mode 100644
index 0000000..cbc5382
--- /dev/null
+++ b/nekowatchlet/liveview-icon.png
Binary files differ
diff --git a/nekowatchlet/metawatch-digital-icon.png b/nekowatchlet/metawatch-digital-icon.png
new file mode 100644
index 0000000..cbc5382
--- /dev/null
+++ b/nekowatchlet/metawatch-digital-icon.png
Binary files differ
diff --git a/nekowatchlet/nekowatchletplugin.cpp b/nekowatchlet/nekowatchletplugin.cpp
index aee7923..7d3aa87 100644
--- a/nekowatchlet/nekowatchletplugin.cpp
+++ b/nekowatchlet/nekowatchletplugin.cpp
@@ -19,12 +19,14 @@ QStringList NekoWatchletPlugin::watchlets()
return l;
}
-WatchletPluginInterface::WatchletInfo NekoWatchletPlugin::describeWatchlet(const QString &id)
+WatchletPluginInterface::WatchletInfo NekoWatchletPlugin::describeWatchlet(const QString &id, const QString &watchModel)
{
WatchletInfo info;
if (id != NekoWatchlet::myId) return info;
info.name = "Neko";
- info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/nekowatchlet/icon.png");
+ info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/nekowatchlet/" + watchModel + "-icon.png");
+ info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/nekowatchlet/icon.png");
+ info.visible = true;
return info;
}
diff --git a/nekowatchlet/nekowatchletplugin.h b/nekowatchlet/nekowatchletplugin.h
index b03df53..452361e 100644
--- a/nekowatchlet/nekowatchletplugin.h
+++ b/nekowatchlet/nekowatchletplugin.h
@@ -16,7 +16,7 @@ public:
~NekoWatchletPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString& id, ConfigKey *settings, Watch* watch);
};
diff --git a/notificationswatchlet/notificationswatchletplugin.cpp b/notificationswatchlet/notificationswatchletplugin.cpp
index 4b26a14..19d3b91 100644
--- a/notificationswatchlet/notificationswatchletplugin.cpp
+++ b/notificationswatchlet/notificationswatchletplugin.cpp
@@ -19,12 +19,14 @@ QStringList NotificationsWatchletPlugin::watchlets()
return l;
}
-WatchletPluginInterface::WatchletInfo NotificationsWatchletPlugin::describeWatchlet(const QString &id)
+WatchletPluginInterface::WatchletInfo NotificationsWatchletPlugin::describeWatchlet(const QString &id, const QString &watchModel)
{
WatchletInfo info;
if (id != "com.javispedro.sowatch.notifications") return info;
info.name = "Pending notifications";
- info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/notificationswatchlet/icon.png");
+ info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/notificationswatchlet/" + watchModel + "-icon.png");
+ info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/notificationswatchlet/icon.png");
+ info.visible = true;
return info;
}
diff --git a/notificationswatchlet/notificationswatchletplugin.h b/notificationswatchlet/notificationswatchletplugin.h
index 472af5c..a52e638 100644
--- a/notificationswatchlet/notificationswatchletplugin.h
+++ b/notificationswatchlet/notificationswatchletplugin.h
@@ -16,7 +16,7 @@ public:
~NotificationsWatchletPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString& id, ConfigKey *settings, Watch* watch);
};
diff --git a/qmafwwatchlet/qmafwwatchletplugin.h b/qmafwwatchlet/qmafwwatchletplugin.h
index 7087a1a..b24dcff 100644
--- a/qmafwwatchlet/qmafwwatchletplugin.h
+++ b/qmafwwatchlet/qmafwwatchletplugin.h
@@ -16,7 +16,7 @@ public:
explicit QMafwWatchletPlugin(QObject *parent = 0);
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString &id, ConfigKey *config, WatchServer *server);
};
diff --git a/qmapwatchlet/map-liveview-icon.png b/qmapwatchlet/map-liveview-icon.png
new file mode 100644
index 0000000..4e9cd9e
--- /dev/null
+++ b/qmapwatchlet/map-liveview-icon.png
Binary files differ
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
new file mode 100644
index 0000000..4e9cd9e
--- /dev/null
+++ b/qmapwatchlet/map-metawatch-digital-icon.png
Binary files differ
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();
diff --git a/qmsgwatchlet/qmsgwatchletplugin.cpp b/qmsgwatchlet/qmsgwatchletplugin.cpp
index 91c6387..f919138 100644
--- a/qmsgwatchlet/qmsgwatchletplugin.cpp
+++ b/qmsgwatchlet/qmsgwatchletplugin.cpp
@@ -23,12 +23,14 @@ QStringList QMsgWatchletPlugin::watchlets()
return l;
}
-WatchletPluginInterface::WatchletInfo QMsgWatchletPlugin::describeWatchlet(const QString &id)
+WatchletPluginInterface::WatchletInfo QMsgWatchletPlugin::describeWatchlet(const QString &id, const QString &watchModel)
{
WatchletInfo info;
if (id != "com.javispedro.sowatch.qmsg") return info;
info.name = "Inbox";
- info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmsgwatchlet/icon.png");
+ info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmsgwatchlet/" + watchModel + "-icon.png");
+ info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qmsgwatchlet/icon.png");
+ info.visible = true;
return info;
}
diff --git a/qmsgwatchlet/qmsgwatchletplugin.h b/qmsgwatchlet/qmsgwatchletplugin.h
index 728ed0b..6bc3e85 100644
--- a/qmsgwatchlet/qmsgwatchletplugin.h
+++ b/qmsgwatchlet/qmsgwatchletplugin.h
@@ -16,7 +16,7 @@ public:
~QMsgWatchletPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString &id, ConfigKey *config, Watch *watch);
};
diff --git a/qorgwatchlet/qorgwatchletplugin.cpp b/qorgwatchlet/qorgwatchletplugin.cpp
index 8416f0f..24db91f 100644
--- a/qorgwatchlet/qorgwatchletplugin.cpp
+++ b/qorgwatchlet/qorgwatchletplugin.cpp
@@ -24,12 +24,14 @@ QStringList QOrgWatchletPlugin::watchlets()
return l;
}
-WatchletPluginInterface::WatchletInfo QOrgWatchletPlugin::describeWatchlet(const QString &id)
+WatchletPluginInterface::WatchletInfo QOrgWatchletPlugin::describeWatchlet(const QString &id, const QString &watchModel)
{
WatchletInfo info;
if (id != "com.javispedro.sowatch.qorg") return info;
info.name = "Calendar";
- info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qorgwatchlet/icon.png");
+ info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qorgwatchlet/icon.png");
+ info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/qorgwatchlet/" + watchModel + "-icon.png");
+ info.visible = true;
return info;
}
diff --git a/qorgwatchlet/qorgwatchletplugin.h b/qorgwatchlet/qorgwatchletplugin.h
index 9f4d3d5..21c8f1f 100644
--- a/qorgwatchlet/qorgwatchletplugin.h
+++ b/qorgwatchlet/qorgwatchletplugin.h
@@ -16,7 +16,7 @@ public:
~QOrgWatchletPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString &id, ConfigKey *config, Watch *watch);
};
diff --git a/sowatchui/configuredwatchletsmodel.cpp b/sowatchui/configuredwatchletsmodel.cpp
index dd301b7..0bea11e 100644
--- a/sowatchui/configuredwatchletsmodel.cpp
+++ b/sowatchui/configuredwatchletsmodel.cpp
@@ -70,7 +70,7 @@ QVariant ConfiguredWatchletsModel::data(const QModelIndex &index, int role) cons
case Qt::DisplayRole:
return QVariant::fromValue(_info[id].name);
case Qt::DecorationRole:
- return QVariant::fromValue(_info[id].icon);
+ return QVariant::fromValue(_info[id].phoneIcon);
case NameRole:
return QVariant::fromValue(id);
case ConfigQmlUrlRole:
@@ -131,11 +131,13 @@ void ConfiguredWatchletsModel::reload()
qDebug() << "Reloading watchlets";
+ QString watchModel = _config->value("driver").toString();
+
QStringList all = registry->allWatchlets();
foreach (const QString& s, all) {
WatchletPluginInterface *plugin = registry->getWatchletPlugin(s);
if (plugin) {
- _info[s] = plugin->describeWatchlet(s);
+ _info[s] = plugin->describeWatchlet(s, watchModel);
} else {
WatchletPluginInterface::WatchletInfo info;
info.name = s;
@@ -149,7 +151,7 @@ void ConfiguredWatchletsModel::reload()
if (_unadded) {
qDebug() << "Listing unadded watchlets from" << all;
foreach (const QString& s, all) {
- if (!_info[s].hidden && !_enabled.contains(s)) {
+ if (_info[s].visible && !_enabled.contains(s)) {
_list.append(s);
}
}
diff --git a/sysinfowatchlet/sysinfoplugin.cpp b/sysinfowatchlet/sysinfoplugin.cpp
index c87e864..9254940 100644
--- a/sysinfowatchlet/sysinfoplugin.cpp
+++ b/sysinfowatchlet/sysinfoplugin.cpp
@@ -19,12 +19,14 @@ QStringList SysInfoPlugin::watchlets()
return l;
}
-SysInfoPlugin::WatchletInfo SysInfoPlugin::describeWatchlet(const QString &id)
+SysInfoPlugin::WatchletInfo SysInfoPlugin::describeWatchlet(const QString &id, const QString &watchModel)
{
WatchletInfo info;
if (id != "com.javispedro.sowatch.sysinfo") return info;
info.name = "Phone info";
- info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/sysinfowatchlet/icon.png");
+ info.phoneIcon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/sysinfowatchlet/icon.png");
+ info.icon = QUrl::fromLocalFile(SOWATCH_QML_DIR "/sysinfowatchlet/" + watchModel + "-icon.png");
+ info.visible = true;
return info;
}
diff --git a/sysinfowatchlet/sysinfoplugin.h b/sysinfowatchlet/sysinfoplugin.h
index e22e00b..6a22ad6 100644
--- a/sysinfowatchlet/sysinfoplugin.h
+++ b/sysinfowatchlet/sysinfoplugin.h
@@ -16,7 +16,7 @@ public:
~SysInfoPlugin();
QStringList watchlets();
- WatchletInfo describeWatchlet(const QString &id);
+ WatchletInfo describeWatchlet(const QString &id, const QString &watchModel);
Watchlet* getWatchlet(const QString &id, ConfigKey *settings, Watch *watch);
};