diff --git a/assets/.assets.index b/assets/.assets.index index a2ab220..17bada9 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,5 +1,6 @@ 1 -35 +36 +AppCover.qml icons/bell-slash.png icons/bell.png icons/comments.png diff --git a/assets/AppCover.qml b/assets/AppCover.qml new file mode 100644 index 0000000..ba0ea5a --- /dev/null +++ b/assets/AppCover.qml @@ -0,0 +1,30 @@ +import bb.cascades 1.4 + +Container { + topPadding: ui.du(3) + leftPadding: ui.du(3) + Container { + layout: StackLayout { + orientation: LayoutOrientation.LeftToRight + } + Label { + text: "Unread global:" + } + Label { + objectName: "global_label" + text: "0" + } + } + Container { + layout: StackLayout { + orientation: LayoutOrientation.LeftToRight + } + Label { + text: "Unread home:" + } + Label { + objectName: "home_label" + text: "0" + } + } +} diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 220f1d2..1f0a37f 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -26,6 +26,7 @@ NavigationPane { property string stream_type property string endpoint + property int unread: -1 property bool refreshpull: false Page { @@ -83,6 +84,23 @@ NavigationPane { function delRepost(pid) { pnut.deleteRepost(pid); } + attachedObjects: [ + ListScrollStateHandler { + onAtEndChanged: { + if (atEnd) { + console.log("I'm at the end!!!") + pnut.getStream(endpoint, Pnut.STREAM_OLDER); + } + } + onAtBeginningChanged: { + if (atBeginning) { + console.log("I'm at the top!!!") + unread = 0 + nav.parent.unreadContentCount = unread + } + } + } + ] } } actions: [ @@ -94,15 +112,26 @@ NavigationPane { newPostSheet.input.requestFocus(); } imageSource: "asset:///icons/ic_compose.png" + shortcuts: [ + SystemShortcut { + type: SystemShortcuts.CreateNew + } + ] }, ActionItem { - title: qsTr("Load Newer") + title: qsTr("To Top") ActionBar.placement: ActionBarPlacement.InOverflow onTriggered: { - refreshpull = true - pnut.getStream(endpoint, Pnut.STREAM_NEWER); + //refreshpull = true + //pnut.getStream(endpoint, Pnut.STREAM_NEWER); + streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); } imageSource: "asset:///icons/ic_to_top.png" + shortcuts: [ + SystemShortcut { + type: SystemShortcuts.JumpToTop + } + ] }, ActionItem { title: qsTr("Reload") @@ -116,13 +145,18 @@ NavigationPane { imageSource: "asset:///icons/ic_reload.png" }, ActionItem { - title: qsTr("Load Older") + title: qsTr("To Bottom") ActionBar.placement: ActionBarPlacement.InOverflow onTriggered: { streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None); - pnut.getStream(endpoint, Pnut.STREAM_OLDER); + //pnut.getStream(endpoint, Pnut.STREAM_OLDER); } imageSource: "asset:///icons/ic_to_bottom.png" + shortcuts: [ + SystemShortcut { + type: SystemShortcuts.JumpToBottom + } + ] } ] actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll @@ -161,6 +195,7 @@ NavigationPane { id: pnut onStreamReceived: { + //nav.parent.unreadContentCount = stream.length switch (rtype) { case Pnut.STREAM_OLDER: //streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None); @@ -168,6 +203,9 @@ NavigationPane { break; case Pnut.STREAM_NEWER: postModel.insert(0, stream); + if (stream.length > 0) { + update_app_cover(stream.length) + } if (refreshpull) { refreshpull = false streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); @@ -208,6 +246,15 @@ NavigationPane { pnut.sinceId = 0 pnut.getStream(endpoint, Pnut.STREAM_OLDER) } + + function update_app_cover(count) { + if (count > 0 && unread >=0) { + unread += count + } else { + unread = 0 + } + nav.parent.unreadContentCount = unread + } } ] onPopTransitionEnded: { diff --git a/assets/main.qml b/assets/main.qml index b781365..cde67cc 100644 --- a/assets/main.qml +++ b/assets/main.qml @@ -50,6 +50,9 @@ TabbedPane { } } imageSource: "asset:///icons/home.png" + onUnreadContentCountChanged: { + _activeFrame.setHomeUnread(unreadContentCount) + } } Tab { @@ -62,6 +65,9 @@ TabbedPane { } } imageSource: "asset:///icons/globe.png" + onUnreadContentCountChanged: { + _activeFrame.setGlobalUnread(unreadContentCount) + } } } diff --git a/buildnum b/buildnum index b854a29..eafdfb0 100644 --- a/buildnum +++ b/buildnum @@ -1 +1 @@ -128 \ No newline at end of file +138 \ No newline at end of file diff --git a/config.pri b/config.pri index 716508b..f9dd25a 100644 --- a/config.pri +++ b/config.pri @@ -66,6 +66,7 @@ simulator { config_pri_assets { OTHER_FILES += \ + $$quote($$BASEDIR/assets/AppCover.qml) \ $$quote($$BASEDIR/assets/LoginSheet.qml) \ $$quote($$BASEDIR/assets/NewPostSheet.qml) \ $$quote($$BASEDIR/assets/PostItem.qml) \ @@ -105,6 +106,7 @@ config_pri_assets { config_pri_source_group1 { SOURCES += \ + $$quote($$BASEDIR/src/ActiveFrameQML.cpp) \ $$quote($$BASEDIR/src/Pnut.cpp) \ $$quote($$BASEDIR/src/Pnut_test.cpp) \ $$quote($$BASEDIR/src/WebImageView.cpp) \ @@ -112,6 +114,7 @@ config_pri_source_group1 { $$quote($$BASEDIR/src/main.cpp) HEADERS += \ + $$quote($$BASEDIR/src/ActiveFrameQML.h) \ $$quote($$BASEDIR/src/Pnut.h) \ $$quote($$BASEDIR/src/WebImageView.h) \ $$quote($$BASEDIR/src/applicationui.hpp) \ diff --git a/src/ActiveFrameQML.cpp b/src/ActiveFrameQML.cpp new file mode 100644 index 0000000..badd99b --- /dev/null +++ b/src/ActiveFrameQML.cpp @@ -0,0 +1,41 @@ +/* + * ActiveFrameQML.cpp + * + * Created on: Oct 21, 2016 + * Author: morga + */ + +#include +#include +#include +#include +#include + +using namespace bb::cascades; + +ActiveFrameQML::ActiveFrameQML(QObject *parent) : SceneCover(parent) +{ + QmlDocument *qml = QmlDocument::create("asset:///AppCover.qml").parent(parent); + Container *mainContainer = qml->createRootObject(); + setContent(mainContainer); + + global_unread_label = mainContainer->findChild("global_label"); + global_unread_label->setParent(mainContainer); + home_unread_label = mainContainer->findChild("home_label"); + home_unread_label->setParent(mainContainer); +} + +ActiveFrameQML::~ActiveFrameQML() +{ + // TODO Auto-generated destructor stub +} + +void ActiveFrameQML::setGlobalUnread(QString count) +{ + global_unread_label->setText(count); +} + +void ActiveFrameQML::setHomeUnread(QString count) +{ + home_unread_label->setText(count); +} diff --git a/src/ActiveFrameQML.h b/src/ActiveFrameQML.h new file mode 100644 index 0000000..97a6f5c --- /dev/null +++ b/src/ActiveFrameQML.h @@ -0,0 +1,32 @@ +/* + * ActiveFrameQML.h + * + * Created on: Oct 21, 2016 + * Author: morga + */ + +#ifndef ACTIVEFRAMEQML_H_ +#define ACTIVEFRAMEQML_H_ + +#include +#include +#include + +using namespace ::bb::cascades; + +class ActiveFrameQML: public SceneCover +{ + Q_OBJECT +public: + ActiveFrameQML(QObject *parent=0); + virtual ~ActiveFrameQML(); + + Q_INVOKABLE void setGlobalUnread(QString count); + Q_INVOKABLE void setHomeUnread(QString count); + +private: + bb::cascades::Label *global_unread_label; + bb::cascades::Label *home_unread_label; +}; + +#endif /* ACTIVEFRAMEQML_H_ */ diff --git a/src/applicationui.cpp b/src/applicationui.cpp index 044c5ce..aed9dc8 100644 --- a/src/applicationui.cpp +++ b/src/applicationui.cpp @@ -17,6 +17,7 @@ #include "applicationui.hpp" #include "Pnut.h" #include "WebImageView.h" +#include "ActiveFrameQML.h" #include #include @@ -54,6 +55,10 @@ ApplicationUI::ApplicationUI() : qml->setContextProperty("_app", this); + ActiveFrameQML *activeFrame = new ActiveFrameQML(); + Application::instance()->setCover(activeFrame); + qml->setContextProperty("_activeFrame", activeFrame); + // Create root object for the UI AbstractPane *root = qml->createRootObject(); diff --git a/translations/Goober.ts b/translations/Goober.ts index a1dfb66..719cf46 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -129,25 +129,25 @@ StreamTab - + New Post - - Load Newer + + To Top - + + To Bottom + + + + Reload - - - Load Older - - main @@ -162,7 +162,7 @@ - + Global