From d5b5cfc83e1247ebc18ef2024f07bdd37d41164b Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Fri, 2 Dec 2011 23:02:51 +0100 Subject: provide a set of metawatch common qml elements --- notificationswatchlet/metawatch-digital.qml | 57 ++++++++++++------------- notificationswatchlet/notificationswatchlet.pro | 1 + 2 files changed, 28 insertions(+), 30 deletions(-) (limited to 'notificationswatchlet') diff --git a/notificationswatchlet/metawatch-digital.qml b/notificationswatchlet/metawatch-digital.qml index be662ab..e5764ec 100644 --- a/notificationswatchlet/metawatch-digital.qml +++ b/notificationswatchlet/metawatch-digital.qml @@ -1,4 +1,5 @@ import QtQuick 1.0 +import com.javispedro.sowatch.metawatch 1.0 Rectangle { width: 96 @@ -6,33 +7,39 @@ Rectangle { color: "white" - ListView { + MWTitle { + id: title + text: qsTr("Notifications") + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + } + + MWListView { id: notifs - anchors.fill: parent + anchors.top: title.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom model: watch.notifications - delegate: Column { - width: parent.width - Text { - width: parent.width - text: model.modelData.title - wrapMode: Text.Wrap - } + delegate: Rectangle { + property bool selected: ListView.isCurrentItem + width: notifs.width + height: childrenRect.height + color: ListView.isCurrentItem ? "black" : "white" Text { - width: parent.width - text: model.modelData.body - wrapMode: Text.Wrap - } - Rectangle { - width: parent.width - height: 1 - color: "black" + width: 96 + text: "" + model.modelData.title + "
" + model.modelData.body + wrapMode: Text.WrapAtWordBoundaryOrAnywhere + color: parent.selected ? "white" : "black" } } visible: count > 0; } Text { - anchors.fill: parent + anchors.top: title.bottom + anchors.horizontalCenter: parent.horizontalCenter text: qsTr("No notifications"); visible: notifs.count == 0; wrapMode: Text.Wrap @@ -41,22 +48,12 @@ Rectangle { Connections { target: watch onButtonPressed : { - var increment = (3 * (notifs.width / 4)); - var maxy = notifs.contentHeight - notifs.height; - var newy; - - if (maxy < 0) maxy = 0; - switch (button) { case 1: - newy = notifs.contentY - increment; - if (newy < 0) newy = 0; - notifs.contentY = newy; + notifs.scrollUp(); break; case 2: - newy = notifs.contentY + increment; - if (newy > maxy) newy = maxy; - notifs.contentY = newy; + notifs.scrollDown(); break; } } diff --git a/notificationswatchlet/notificationswatchlet.pro b/notificationswatchlet/notificationswatchlet.pro index cf3beff..9791ed6 100644 --- a/notificationswatchlet/notificationswatchlet.pro +++ b/notificationswatchlet/notificationswatchlet.pro @@ -17,6 +17,7 @@ else:unix: LIBS += -L$$OUT_PWD/../libsowatch/ -lsowatch INCLUDEPATH += $$PWD/../libsowatch DEPENDPATH += $$PWD/../libsowatch +QML_IMPORT_PATH += $$PWD/../metawatch/qml unix:!symbian { !isEmpty(MEEGO_VERSION_MAJOR)|maemo5 { -- cgit v1.2.3