summaryrefslogtreecommitdiff
path: root/metawatch
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-19 01:51:04 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-19 01:51:04 +0200
commit77a98ac21c2520d9fb4bb9c8f70967a8e36dc872 (patch)
tree687d1cc8820296d56e06c8fab3eaf9ef935cba23 /metawatch
parent03af539d69d903dfb5df19b447707a35ebaa4a54 (diff)
downloadsowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.tar.gz
sowatch-77a98ac21c2520d9fb4bb9c8f70967a8e36dc872.zip
adding notification provider plugins, idle screen
Diffstat (limited to 'metawatch')
-rw-r--r--metawatch/metawatch.cpp92
-rw-r--r--metawatch/metawatch.h5
-rw-r--r--metawatch/metawatch.pro14
-rw-r--r--metawatch/metawatch_16pt_11pxl.ttfbin0 -> 14576 bytes
-rw-r--r--metawatch/metawatch_8pt_5pxl_CAPS.ttfbin0 -> 12408 bytes
-rw-r--r--metawatch/metawatch_8pt_7pxl_CAPS.ttfbin0 -> 15212 bytes
-rw-r--r--metawatch/metawatchplugin.cpp14
-rw-r--r--metawatch/metawatchplugin.h4
-rw-r--r--metawatch/uires.qrc13
-rw-r--r--metawatch/weather_cloudy.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_rain.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_snow.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_sunny.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_thunderstorm.bmpbin0 -> 158 bytes
-rw-r--r--metawatch/weather_wind.bmpbin0 -> 158 bytes
15 files changed, 124 insertions, 18 deletions
diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp
index 08b9890..e6a28f4 100644
--- a/metawatch/metawatch.cpp
+++ b/metawatch/metawatch.cpp
@@ -85,7 +85,8 @@ MetaWatch::MetaWatch(const QBluetoothAddress& address, QObject *parent) :
_connectAlignedTimer(new QSystemAlignedTimer(this)),
_sendTimer(new QTimer(this)),
_currentMode(IdleMode),
- _paintMode(IdleMode)
+ _paintMode(IdleMode),
+ _nMails(0), _nCalls(0), _nIms(0), _nSms(0)
{
QImage baseImage(screenWidth, screenHeight, QImage::Format_MonoLSB);
baseImage.setColor(0, QColor(Qt::white).rgb());
@@ -191,8 +192,25 @@ void MetaWatch::setDateTime(const QDateTime &dateTime)
void MetaWatch::updateNotificationCount(Notification::Type type, int count)
{
- Q_UNUSED(type);
- Q_UNUSED(count); // TODO
+ switch (type) {
+ case Notification::MissedCallNotification:
+ _nCalls = count;
+ break;
+ case Notification::EmailNotification:
+ _nMails = count;
+ break;
+ case Notification::ImNotification:
+ _nIms = count;
+ break;
+ case Notification::SmsNotification:
+ _nSms = count;
+ break;
+ default:
+ // Ignore
+ break;
+ }
+
+ renderIdleCounts();
}
void MetaWatch::vibrate(bool on)
@@ -202,7 +220,7 @@ void MetaWatch::vibrate(bool on)
void MetaWatch::showNotification(const Notification &n)
{
- Q_UNUSED(n); // TODO
+ qDebug() << "It's time for a notification" << n.title();
}
MetaWatch::Mode MetaWatch::currentMode() const
@@ -248,20 +266,64 @@ void MetaWatch::clear(Mode mode, bool black)
void MetaWatch::renderIdleScreen()
{
_paintMode = IdleMode;
+
+ QFont smallFont("MetaWatch Small caps 8pt", 6);
+ QImage idle_mail(QString(":/metawatch/graphics/idle_gmail.bmp"));
+ QImage idle_call(QString(":/metawatch/graphics/idle_call.bmp"));
+ QImage idle_sms(QString(":/metawatch/graphics/idle_sms.bmp"));
QPainter p(this);
+
p.fillRect(0, 0, screenWidth, screenHeight, Qt::white);
+
p.setPen(QPen(Qt::black, 1.0, Qt::DashLine));
- p.drawLine(0, systemAreaHeight + 2, screenWidth, systemAreaHeight + 2);
- p.drawLine(0, systemAreaHeight * 2 + 3, screenWidth, systemAreaHeight * 2 + 3);
- p.setPen(Qt::black);
- p.drawText(1, systemAreaHeight + 16, "Space Weather!");
- QImage idle_mail(QString(":/metawatch/idle_gmail.bmp"));
- QImage idle_call(QString(":/metawatch/idle_call.bmp"));
- QImage idle_sms(QString(":/metawatch/idle_sms.bmp"));
- p.drawImage(4, systemAreaHeight * 2 + 6, idle_mail);
- p.drawImage(32 + 4, systemAreaHeight * 2 + 6, idle_call);
- p.drawImage(32 * 2 + 4, systemAreaHeight * 2 + 6, idle_sms);
- p.drawText(14, 93, "Too many!");
+ p.drawLine(1, systemAreaHeight + 2, screenWidth - 2, systemAreaHeight + 2);
+ p.drawLine(1, systemAreaHeight * 2 + 3, screenWidth - 2, systemAreaHeight * 2 + 3);
+
+ p.drawImage(3, systemAreaHeight * 2 + 6, idle_mail);
+ p.drawImage(32 + 3, systemAreaHeight * 2 + 6, idle_call);
+ p.drawImage(32 * 2 + 3, systemAreaHeight * 2 + 6, idle_sms);
+
+ p.end();
+ renderIdleWeather();
+ renderIdleCounts();
+ _paintMode = _currentMode;
+}
+
+void MetaWatch::renderIdleWeather()
+{
+ _paintMode = IdleMode;
+ QFont smallFont("MetaWatch Small caps 8pt", 6);
+ QImage rain(QString(":/metawatch/graphics/weather_rain.bmp"));
+ QPainter p(this);
+
+ p.setFont(smallFont);
+ p.drawText(46, systemAreaHeight + 14, "Rain");
+ p.drawImage(screenWidth - 26, systemAreaHeight + 6, rain);
+
+ _paintMode = _currentMode;
+}
+
+void MetaWatch::renderIdleCounts()
+{
+ _paintMode = IdleMode;
+ QFont medFont("MetaWatch Large caps 8pt", 6);
+ QString s;
+ QPainter p(this);
+ QTextOption opt(Qt::AlignCenter);
+ const int y = systemAreaHeight * 2 + 25;
+ const int w = 24;
+ const int h = screenHeight - (y + 1);
+ const int mails = _nMails;
+ const int calls = _nCalls;
+ const int sms = _nSms + _nIms;
+
+ qDebug() << "unread counts" << mails << calls << sms;
+
+ p.setFont(medFont);
+ p.fillRect(QRect(0, y, screenWidth, h), Qt::white);
+ p.drawText(QRect(4, y, w, h), s.sprintf("%d", mails), opt);
+ p.drawText(QRect(32 + 4, y, w, h), s.sprintf("%d", calls), opt);
+ p.drawText(QRect(32 * 2 + 4, y, w, h), s.sprintf("%d", sms), opt);
}
quint16 MetaWatch::calcCrc(const QByteArray &data, int size)
diff --git a/metawatch/metawatch.h b/metawatch/metawatch.h
index 68e24c3..d15054f 100644
--- a/metawatch/metawatch.h
+++ b/metawatch/metawatch.h
@@ -88,6 +88,8 @@ public:
void update(Mode mode, const QList<QRect>& rects = QList<QRect>());
void renderIdleScreen();
+ void renderIdleWeather();
+ void renderIdleCounts();
protected:
mutable MetaWatchPaintEngine* _paintEngine;
@@ -120,6 +122,9 @@ protected:
Mode _paintMode;
quint8 _buttonState;
+ // Notifications: Unread count
+ uint _nMails, _nCalls, _nIms, _nSms;
+
static const quint8 bitRevTable[16];
static const quint16 crcTable[256];
quint16 calcCrc(const QByteArray& data, int size);
diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro
index f4b86f8..9a661ba 100644
--- a/metawatch/metawatch.pro
+++ b/metawatch/metawatch.pro
@@ -32,7 +32,16 @@ RESOURCES += \
OTHER_FILES += \
idle_sms.bmp \
idle_gmail.bmp \
- idle_call.bmp
+ idle_call.bmp \
+ weather_wind.bmp \
+ weather_thunderstorm.bmp \
+ weather_sunny.bmp \
+ weather_snow.bmp \
+ weather_rain.bmp \
+ weather_cloudy.bmp \
+ metawatch_16pt_11pxl.ttf \
+ metawatch_8pt_7pxl_CAPS.ttf \
+ metawatch_8pt_5pxl_CAPS.ttf
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/release/ -lsowatch
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libsowatch/debug/ -lsowatch
@@ -47,7 +56,7 @@ symbian {
TARGET.UID3 = 0xE4DC26B0
TARGET.CAPABILITY =
TARGET.EPOCALLOWDLLDATA = 1
- addFiles.sources = metawatch.dll
+ addFiles.sources = metawatchdriver.dll
addFiles.path = !:/sys/bin
DEPLOYMENT += addFiles
}
@@ -60,3 +69,4 @@ unix:!symbian {
}
INSTALLS += target
}
+
diff --git a/metawatch/metawatch_16pt_11pxl.ttf b/metawatch/metawatch_16pt_11pxl.ttf
new file mode 100644
index 0000000..9aeb8b3
--- /dev/null
+++ b/metawatch/metawatch_16pt_11pxl.ttf
Binary files differ
diff --git a/metawatch/metawatch_8pt_5pxl_CAPS.ttf b/metawatch/metawatch_8pt_5pxl_CAPS.ttf
new file mode 100644
index 0000000..a6b8f30
--- /dev/null
+++ b/metawatch/metawatch_8pt_5pxl_CAPS.ttf
Binary files differ
diff --git a/metawatch/metawatch_8pt_7pxl_CAPS.ttf b/metawatch/metawatch_8pt_7pxl_CAPS.ttf
new file mode 100644
index 0000000..72eda9e
--- /dev/null
+++ b/metawatch/metawatch_8pt_7pxl_CAPS.ttf
Binary files differ
diff --git a/metawatch/metawatchplugin.cpp b/metawatch/metawatchplugin.cpp
index e56d6db..751cff9 100644
--- a/metawatch/metawatchplugin.cpp
+++ b/metawatch/metawatchplugin.cpp
@@ -1,3 +1,4 @@
+#include <QtGui/QFontDatabase>
#include <QtConnectivity/QBluetoothAddress>
#include "metawatch.h"
#include "metawatchsimulator.h"
@@ -6,6 +7,19 @@
using namespace sowatch;
QTM_USE_NAMESPACE
+bool MetaWatchPlugin::fontsLoaded = false;
+
+MetaWatchPlugin::MetaWatchPlugin()
+{
+ if (!fontsLoaded) {
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_16pt_11pxl.ttf");
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_8pt_7pxl_CAPS.ttf");
+ QFontDatabase::addApplicationFont(":/metawatch/fonts/metawatch_8pt_5pxl_CAPS.ttf");
+ // "MetaWatch Large 16pt", "MetaWatch Large caps 8pt", "MetaWatch Small caps 8pt"
+ fontsLoaded = true;
+ }
+}
+
MetaWatchPlugin::~MetaWatchPlugin()
{
diff --git a/metawatch/metawatchplugin.h b/metawatch/metawatchplugin.h
index 9662ec0..57b1029 100644
--- a/metawatch/metawatchplugin.h
+++ b/metawatch/metawatchplugin.h
@@ -11,10 +11,14 @@ class MetaWatchPlugin : public QObject, public WatchPluginInterface {
Q_INTERFACES(sowatch::WatchPluginInterface)
public:
+ MetaWatchPlugin();
~MetaWatchPlugin();
virtual QStringList drivers();
virtual Watch* getWatch(const QString& driver, QSettings& settings, QObject *parent = 0);
+
+protected:
+ static bool fontsLoaded;
};
}
diff --git a/metawatch/uires.qrc b/metawatch/uires.qrc
index 4be7fc8..24d70fb 100644
--- a/metawatch/uires.qrc
+++ b/metawatch/uires.qrc
@@ -1,7 +1,18 @@
<RCC>
- <qresource prefix="/metawatch">
+ <qresource prefix="/metawatch/graphics">
<file>idle_call.bmp</file>
<file>idle_gmail.bmp</file>
<file>idle_sms.bmp</file>
+ <file>weather_cloudy.bmp</file>
+ <file>weather_rain.bmp</file>
+ <file>weather_snow.bmp</file>
+ <file>weather_sunny.bmp</file>
+ <file>weather_thunderstorm.bmp</file>
+ <file>weather_wind.bmp</file>
+ </qresource>
+ <qresource prefix="/metawatch/fonts">
+ <file>metawatch_8pt_5pxl_CAPS.ttf</file>
+ <file>metawatch_8pt_7pxl_CAPS.ttf</file>
+ <file>metawatch_16pt_11pxl.ttf</file>
</qresource>
</RCC>
diff --git a/metawatch/weather_cloudy.bmp b/metawatch/weather_cloudy.bmp
new file mode 100644
index 0000000..506c24a
--- /dev/null
+++ b/metawatch/weather_cloudy.bmp
Binary files differ
diff --git a/metawatch/weather_rain.bmp b/metawatch/weather_rain.bmp
new file mode 100644
index 0000000..fc12c6e
--- /dev/null
+++ b/metawatch/weather_rain.bmp
Binary files differ
diff --git a/metawatch/weather_snow.bmp b/metawatch/weather_snow.bmp
new file mode 100644
index 0000000..d328105
--- /dev/null
+++ b/metawatch/weather_snow.bmp
Binary files differ
diff --git a/metawatch/weather_sunny.bmp b/metawatch/weather_sunny.bmp
new file mode 100644
index 0000000..df9f774
--- /dev/null
+++ b/metawatch/weather_sunny.bmp
Binary files differ
diff --git a/metawatch/weather_thunderstorm.bmp b/metawatch/weather_thunderstorm.bmp
new file mode 100644
index 0000000..f101610
--- /dev/null
+++ b/metawatch/weather_thunderstorm.bmp
Binary files differ
diff --git a/metawatch/weather_wind.bmp b/metawatch/weather_wind.bmp
new file mode 100644
index 0000000..59bd81b
--- /dev/null
+++ b/metawatch/weather_wind.bmp
Binary files differ