summaryrefslogtreecommitdiff
path: root/liveview
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2013-07-07 13:50:28 +0200
committerJavier S. Pedro <maemo@javispedro.com>2013-07-07 13:50:28 +0200
commitf61dfc6557303a8bba5301927f42e5b2a7ffcac6 (patch)
treefdba31b412015684d46c7a3cb070b8a57ff37ef4 /liveview
parent92475d094cfddf7dd3036f5f1a9d6845a83ee350 (diff)
downloadsowatch-f61dfc6557303a8bba5301927f42e5b2a7ffcac6.tar.gz
sowatch-f61dfc6557303a8bba5301927f42e5b2a7ffcac6.zip
add some notification support to liveview
Diffstat (limited to 'liveview')
-rw-r--r--liveview/liveview.cpp65
-rw-r--r--liveview/liveview.h16
-rw-r--r--liveview/liveview.pro3
-rw-r--r--liveview/liveviewscanner.cpp1
-rw-r--r--liveview/qml/com/javispedro/sowatch/liveview/LVPage.qml7
-rw-r--r--liveview/qml/com/javispedro/sowatch/liveview/qmldir2
-rw-r--r--liveview/qml/liveview-config.qml53
7 files changed, 141 insertions, 6 deletions
diff --git a/liveview/liveview.cpp b/liveview/liveview.cpp
index 450e802..754bf2f 100644
--- a/liveview/liveview.cpp
+++ b/liveview/liveview.cpp
@@ -6,7 +6,7 @@
using namespace sowatch;
QTM_USE_NAMESPACE
-#define PROTOCOL_DEBUG 1
+#define PROTOCOL_DEBUG 0
const int LiveView::MaxBitmapSize = 64;
QMap<LiveView::MessageType, LiveView::MessageType> LiveView::_ackMap;
@@ -17,7 +17,7 @@ LiveView::LiveView(ConfigKey* settings, QObject* parent) :
_settings(settings->getSubkey(QString(), this)),
_watchlets(0), _notifications(0),
_24hMode(settings->value("24h-mode", false).toBool()),
- _screenWidth(0), _screenHeight(0),
+ _screenWidth(128), _screenHeight(128),
_mode(RootMenuMode),
_paintEngine(0),
_rootMenuFirstWatchlet(0),
@@ -131,6 +131,7 @@ void LiveView::displayIdleScreen()
{
qDebug() << "LiveView display idle screen (cur mode=" << _mode << ")";
if (_mode != RootMenuMode) {
+ displayClear();
_mode = RootMenuMode;
refreshMenu();
}
@@ -139,17 +140,22 @@ void LiveView::displayIdleScreen()
void LiveView::displayNotification(Notification *notification)
{
qDebug() << "LiveView display notification" << notification->title();
+ _mode = NotificationMode;
+ setScreenMode(ScreenMax);
+ setMenuSize(0);
+ enableLed(Qt::green, 0, 250);
+ vibrate(0, 200);
}
void LiveView::displayApplication()
{
_mode = ApplicationMode;
- setMenuSize(0); // TODO
+ setMenuSize(0); // This clears up the menu.
}
void LiveView::vibrate(int msecs)
{
- // TODO
+ vibrate(0, msecs);
}
void LiveView::setWatchletsModel(WatchletsModel *model)
@@ -166,7 +172,6 @@ void LiveView::setWatchletsModel(WatchletsModel *model)
void LiveView::setNotificationsModel(NotificationsModel *model)
{
- qDebug() << Q_FUNC_INFO;
if (_notifications) {
disconnect(_notifications, 0, this, 0);
}
@@ -219,6 +224,8 @@ void LiveView::initializeAckMap()
_ackMap[DisplayClear] = DisplayClearResponse;
//_ackMap[SetMenuSize] = SetMenuSizeResponse; // fw does not send this, for some reason.
_ackMap[EnableLed] = EnableLedResponse;
+ _ackMap[Vibrate] = VibrateResponse;
+ _ackMap[SetScreenMode] = SetScreenModeResponse;
}
}
@@ -366,7 +373,9 @@ void LiveView::send(const Message &msg)
if (_waitingForAck == NoMessage) {
sendMessageFromQueue();
} else {
+#if PROTOCOL_DEBUG
qDebug() << "Enqueing message while waiting for ack" << _waitingForAck;
+#endif
}
}
@@ -480,11 +489,31 @@ void LiveView::enableLed(const QColor& color, unsigned short delay, unsigned sho
send(Message(EnableLed, data));
}
+void LiveView::vibrate(unsigned short delay, unsigned short time)
+{
+ QByteArray data;
+
+ data.append((delay & 0xFF00U) >> 8);
+ data.append(delay & 0x00FFU);
+ data.append((time & 0xFF00U) >> 8);
+ data.append(time & 0x00FFU);
+
+ send(Message(Vibrate, data));
+}
+
+void LiveView::setScreenMode(ScreenBrigthness mode)
+{
+ qDebug() << "Set screenmode to" << mode;
+ send(Message(SetScreenMode, QByteArray(1, mode)));
+}
+
void LiveView::handleMessage(const Message &msg)
{
send(Message(Ack, QByteArray(1, msg.type)));
if (msg.type == _waitingForAck) {
+#if PROTOCOL_DEBUG
qDebug() << "Got ack to" << _waitingForAck;
+#endif
_waitingForAck = NoMessage;
sendMessageFromQueue();
}
@@ -512,11 +541,15 @@ void LiveView::handleMessage(const Message &msg)
handleDateTimeRequest(msg);
break;
case EnableLedResponse:
+ case VibrateResponse:
// Nothing to do
break;
case GetDisplayPropertiesResponse:
handleDisplayProperties(msg);
break;
+ case SetScreenModeResponse:
+ // Nothing to do
+ break;
case GetSoftwareVersionResponse:
handleSoftwareVersion(msg);
break;
@@ -530,6 +563,21 @@ void LiveView::handleDeviceStatusChange(const Message &msg)
if (msg.data.size() == 1) {
DeviceStatus status = static_cast<DeviceStatus>(msg.data.at(0));
qDebug() << "liveview device status change" << status;
+ switch (status) {
+ case DeviceOff:
+ if (_mode == NotificationMode) {
+ emit idling();
+ }
+ break;
+ case DeviceOn:
+ if (_notifications && _notifications->size() > 0) {
+ enableLed(Qt::green, 0, 250);
+ }
+ break;
+ case DeviceMenu:
+ qDebug() << "Device in menu";
+ break;
+ }
}
sendResponse(DeviceStatusChangeResponse, ResponseOk);
}
@@ -652,6 +700,10 @@ void LiveView::handleNavigation(const Message &msg)
sendResponse(NavigationResponse, ResponseCancel);
emit closeWatchledRequested();
return;
+ } else if (_mode == NotificationMode) {
+ sendResponse(NavigationResponse, ResponseCancel);
+ emit nextWatchletRequested();
+ return;
} else if (_mode == NotificationListMode) {
sendResponse(NavigationResponse, ResponseCancel);
_mode = RootMenuMode;
@@ -684,6 +736,7 @@ void LiveView::handleNavigation(const Message &msg)
void LiveView::handleMenuItemsRequest(const Message &msg)
{
+ Q_UNUSED(msg);
qDebug() << "Sending menu items";
if (_mode == NotificationListMode) {
_mode = RootMenuMode; // Switch to the root menu
@@ -829,8 +882,10 @@ void LiveView::handleDataReceived()
}
_receivingMsg.data.resize(data_size);
+#if PROTOCOL_DEBUG
qDebug() << "got header (type=" << _receivingMsg.type <<
"size=" << data_size << ")";
+#endif
}
/* We have the header; now, try to get the complete packet. */
diff --git a/liveview/liveview.h b/liveview/liveview.h
index b85a574..13a8f0a 100644
--- a/liveview/liveview.h
+++ b/liveview/liveview.h
@@ -79,7 +79,11 @@ protected:
DateTimeResponse = 39,
EnableLed = 40,
EnableLedResponse = 41,
+ Vibrate = 42,
+ VibrateResponse = 43,
Ack = 44,
+ SetScreenMode = 64,
+ SetScreenModeResponse = 65,
GetSoftwareVersion = 68,
GetSoftwareVersionResponse = 69
};
@@ -106,6 +110,7 @@ protected:
enum Mode {
RootMenuMode = 0,
ApplicationMode,
+ NotificationMode,
NotificationListMode
};
@@ -128,6 +133,12 @@ protected:
NotificationShowPrev = 4
};
+ enum ScreenBrigthness {
+ ScreenOff = 49,
+ ScreenDim = 50,
+ ScreenMax = 51
+ };
+
struct Message {
MessageType type;
QByteArray data;
@@ -183,6 +194,8 @@ protected:
void sendMenuItem(unsigned char id, MenuItemType type, unsigned short unread, const QString& text, const QByteArray& image);
void sendNotification(unsigned short id, unsigned short unread, unsigned short count, const QString& date, const QString& header, const QString& body, const QByteArray& image);
void enableLed(const QColor& color, unsigned short delay, unsigned short time);
+ void vibrate(unsigned short delay, unsigned short time);
+ void setScreenMode(ScreenBrigthness mode);
void handleMessage(const Message& msg);
void handleDeviceStatusChange(const Message& msg);
@@ -207,12 +220,15 @@ private:
WatchletsModel *_watchlets;
NotificationsModel *_notifications;
+ // Configurable settings
bool _24hMode : 1;
+ // Watch properties
int _screenWidth;
int _screenHeight;
QStringList _buttons;
+ // Runtime variables
Mode _mode;
int _curNotificationIndex;
diff --git a/liveview/liveview.pro b/liveview/liveview.pro
index bb7ccee..21e7a94 100644
--- a/liveview/liveview.pro
+++ b/liveview/liveview.pro
@@ -21,6 +21,7 @@ HEADERS += liveviewplugin.h \
liveviewpaintengine.h
res_files.files += res/graphics res/fonts
+qml_files.files += qml/com qml/liveview-config.qml
LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch
INCLUDEPATH += $$PWD/../libsowatch
@@ -40,4 +41,4 @@ DEPENDPATH += $$PWD/../libsowatchbt
res_files.path = /usr/share/sowatch/liveview
qml_files.path = /usr/share/sowatch/qml
}
-INSTALLS += target res_files
+INSTALLS += target res_files qml_files
diff --git a/liveview/liveviewscanner.cpp b/liveview/liveviewscanner.cpp
index dbb47f3..4645906 100644
--- a/liveview/liveviewscanner.cpp
+++ b/liveview/liveviewscanner.cpp
@@ -20,6 +20,7 @@ void LiveViewScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
foundInfo["driver"] = QString("liveview");
foundInfo["address"] = dev.address().toString();
foundInfo["name"] = deviceName;
+ foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.liveview.notification");
emit watchFound(foundInfo);
}
}
diff --git a/liveview/qml/com/javispedro/sowatch/liveview/LVPage.qml b/liveview/qml/com/javispedro/sowatch/liveview/LVPage.qml
new file mode 100644
index 0000000..f3eaf96
--- /dev/null
+++ b/liveview/qml/com/javispedro/sowatch/liveview/LVPage.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Rectangle {
+ width: 128
+ height: 128
+ color: "black"
+}
diff --git a/liveview/qml/com/javispedro/sowatch/liveview/qmldir b/liveview/qml/com/javispedro/sowatch/liveview/qmldir
new file mode 100644
index 0000000..82dc2a2
--- /dev/null
+++ b/liveview/qml/com/javispedro/sowatch/liveview/qmldir
@@ -0,0 +1,2 @@
+LVPage 1.0 LVPage.qml
+LVLabel 1.0 LVLabel.qml
diff --git a/liveview/qml/liveview-config.qml b/liveview/qml/liveview-config.qml
new file mode 100644
index 0000000..f6c84b0
--- /dev/null
+++ b/liveview/qml/liveview-config.qml
@@ -0,0 +1,53 @@
+import QtQuick 1.1
+import com.nokia.meego 1.1
+import com.javispedro.sowatch 1.0
+
+Column {
+ property string configKey;
+
+ Item {
+ id: hourModeItem
+ width: parent.width
+ height: UiConstants.ListItemHeightDefault
+
+ GConfKey {
+ id: hourModeKey
+ key: configKey + "/24h-mode"
+ }
+ MouseArea {
+ id: hourModeArea
+ anchors.fill: parent
+ onClicked: hourModeSelect.open();
+ }
+ SelectionDialog {
+ id: hourModeSelect
+ titleText: qsTr("Time format")
+ selectedIndex: hourModeKey.value ? 1 : 0
+ model: ListModel {
+ ListElement { name: QT_TR_NOOP("12 hour") }
+ ListElement { name: QT_TR_NOOP("24 hour") }
+ }
+ onSelectedIndexChanged: hourModeKey.value = selectedIndex == 1
+ }
+ Column {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.left: parent.left
+
+ Label {
+ text: qsTr("Time format")
+ font: UiConstants.TitleFont
+ }
+
+ Label {
+ text: qsTr(hourModeSelect.model.get(hourModeSelect.selectedIndex).name)
+ font: UiConstants.FieldLabelFont
+ color: UiConstants.FieldLabelColor
+ }
+ }
+ Image {
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ source: "image://theme/meegotouch-combobox-indicator" + (theme.inverted ? "-inverted" : "")
+ }
+ }
+}