diff options
-rw-r--r-- | libsowatch/declarativewatchlet.cpp | 3 | ||||
-rw-r--r-- | metawatch/metawatch.cpp | 1 | ||||
-rw-r--r-- | metawatch/metawatch.pro | 11 | ||||
-rw-r--r-- | metawatch/qml/MWTitle.qml | 6 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml (renamed from metawatch/qml/MWListView.qml) | 63 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml | 16 | ||||
-rw-r--r-- | metawatch/qml/com/javispedro/sowatch/metawatch/qmldir | 2 | ||||
-rw-r--r-- | notificationswatchlet/metawatch-digital.qml | 57 | ||||
-rw-r--r-- | notificationswatchlet/notificationswatchlet.pro | 1 | ||||
-rw-r--r-- | sowatch.pro | 17 | ||||
-rw-r--r-- | sowatchui/sowatchui.pro | 3 |
11 files changed, 82 insertions, 98 deletions
diff --git a/libsowatch/declarativewatchlet.cpp b/libsowatch/declarativewatchlet.cpp index 34a1d2a..275af2a 100644 --- a/libsowatch/declarativewatchlet.cpp +++ b/libsowatch/declarativewatchlet.cpp @@ -24,8 +24,9 @@ DeclarativeWatchlet::DeclarativeWatchlet(WatchServer* server, const QString& id) } _engine = new QDeclarativeEngine(this); - _wrapper = new DeclarativeWatchWrapper(server, server->watch(), this); + _engine->addImportPath(SOWATCH_QML_DIR); + _wrapper = new DeclarativeWatchWrapper(server, server->watch(), this); _engine->rootContext()->setContextProperty("watch", _wrapper); } diff --git a/metawatch/metawatch.cpp b/metawatch/metawatch.cpp index e829c94..2106277 100644 --- a/metawatch/metawatch.cpp +++ b/metawatch/metawatch.cpp @@ -696,6 +696,7 @@ void MetaWatch::socketConnected() grabButton(NotificationMode, BtnE); grabButton(NotificationMode, BtnF); + // Call the MetaWatch Model-specific setup routines handleWatchConnected(); emit connected(); diff --git a/metawatch/metawatch.pro b/metawatch/metawatch.pro index d0ffddf..c7cf74b 100644 --- a/metawatch/metawatch.pro +++ b/metawatch/metawatch.pro @@ -31,7 +31,7 @@ FORMS += \ metawatchsimulatorform.ui res_files.files += res/graphics res/fonts -qml_files.files += qml/MWListView.qml +qml_files.files += qml/com 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 @@ -56,16 +56,11 @@ unix:!symbian { QMAKE_RPATHDIR += /opt/sowatch/lib target.path = /opt/sowatch/lib/drivers res_files.path = /opt/sowatch/share/metawatch - qml_files.path = /opt/sowatch/qml/metawatch + qml_files.path = /opt/sowatch/qml } else { target.path = /usr/lib/sowatch/drivers res_files.path = /usr/share/sowatch/metawatch - qml_files.path = /usr/share/sowatch/qml/metawatch + qml_files.path = /usr/share/sowatch/qml } INSTALLS += target res_files qml_files } - -OTHER_FILES += \ - qml/MWTitle.qml - - diff --git a/metawatch/qml/MWTitle.qml b/metawatch/qml/MWTitle.qml deleted file mode 100644 index 44f4f70..0000000 --- a/metawatch/qml/MWTitle.qml +++ /dev/null @@ -1,6 +0,0 @@ -import QtQuick 1.0 - -Rectangle { - width: 100 - height: 62 -} diff --git a/metawatch/qml/MWListView.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml index e49905b..3e445fb 100644 --- a/metawatch/qml/MWListView.qml +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWListView.qml @@ -5,55 +5,52 @@ ListView { property bool selectable: true - //interactive: false + interactive: false highlightFollowsCurrentItem: false boundsBehavior: Flickable.StopAtBounds - property real currentItemTop: currentItem.y - contentY - property real currentItemBottom: currentItemTop + currentItem.height + property real currentItemTop: currentItem !== null ? currentItem.y - contentY : 0 + property real currentItemBottom: currentItem !== null ? currentItemTop + currentItem.height : 0 - function _scrollSelectable(dir) { - var maxy = contentHeight - height; - if (maxy < 0) maxy = 0; - - console.log(contentHeight); - - var newy = contentY; - - if (dir > 0) { + function scrollDown() { + if (count == 0) { + return; // No items + } + if (selectable) { + if (currentIndex == -1) { + // If no item is selected, select the first one. + currentItem = 0; + return; + } if (currentIndex < count && currentItemBottom < height) { // If the next item is visible, highlight it - list.incrementCurrentIndex(); + incrementCurrentIndex(); } if (currentItemBottom >= height) { // If the next item now is still not visible, scroll - newy += 96/3; + contentY += 96/3; + } + } + } + + function scrollUp() { + if (count == 0) { + return; // No items + } + if (selectable) { + if (currentIndex == -1) { + // If no item is selected, select the last one. + currentIndex = count - 1; + return; } - } else { if (currentIndex >= 0 && currentItemTop > 0) { // If the previous item is visible, highlight it - list.decrementCurrentIndex(); + decrementCurrentIndex(); } if (currentItemTop <= 0) { // If the previous item now is still not visible, scroll - newy -= 96/3; + contentY -= 96/3; } } - - //if (newy < 0) newy = 0; - //if (newy > maxy) newy = maxy; - list.contentY = newy; - } - - function scrollDown() { - if (selectable) { - _scrollSelectable(+1); - } - } - - function scrollUp() { - if (selectable) { - _scrollSelectable(-1); - } } } diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml new file mode 100644 index 0000000..8aa494c --- /dev/null +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/MWTitle.qml @@ -0,0 +1,16 @@ +import QtQuick 1.0 + +Rectangle { + width: 96 + height: 16 + + property alias text: label.text + + Row { + anchors.fill: parent + Text { + id: label + font.bold: true + } + } +} diff --git a/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir new file mode 100644 index 0000000..02221c3 --- /dev/null +++ b/metawatch/qml/com/javispedro/sowatch/metawatch/qmldir @@ -0,0 +1,2 @@ +MWTitle 1.0 MWTitle.qml +MWListView 1.0 MWListView.qml 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: "<b>" + model.modelData.title + "</b><br>" + 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 { diff --git a/sowatch.pro b/sowatch.pro index 6c03912..a97d90a 100644 --- a/sowatch.pro +++ b/sowatch.pro @@ -33,20 +33,3 @@ OTHER_FILES += \ qtc_packaging/debian_fremantle/control \ qtc_packaging/debian_fremantle/compat \ qtc_packaging/debian_fremantle/changelog - - - - - - - - - - - - - - - - - diff --git a/sowatchui/sowatchui.pro b/sowatchui/sowatchui.pro index 297e394..2265ad6 100644 --- a/sowatchui/sowatchui.pro +++ b/sowatchui/sowatchui.pro @@ -43,6 +43,3 @@ OTHER_FILES += \ qml/main.qml \ sowatch_harmattan.desktop \ sowatch.desktop - - - |