diff --git a/assets/.assets.index b/assets/.assets.index index 785da60..eecceda 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,8 +1,10 @@ 1 -17 +25 +icons/comments.png icons/globe.png icons/ic_add.png icons/ic_add_bookmarks.png +icons/ic_del_bookmarks.png icons/ic_favorite.png icons/ic_reload.png icons/ic_reply.png @@ -11,9 +13,15 @@ icons/ic_to_bottom.png icons/ic_to_top.png icons/laughing_man.png icons/messages.png +icons/quote-left.png +icons/refresh.png +icons/retweet.png +icons/star-o.png +icons/star.png main.qml moment.js NewPostSheet.qml PostItem.qml +RefreshItem.qml StreamTab.qml ThreadPage.qml diff --git a/assets/PostItem.qml b/assets/PostItem.qml index 0d89fdb..818eb00 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -75,8 +75,9 @@ Container { topMargin: ui.sdu(1.0) Container { ImageView { - visible: (ListItemData.counts.threads > 0 || ListItemData.counts.replies > 0 || ListItemData.id !== ListItemData.thread_id) - imageSource: "asset:///icons/messages.png" + // (ListItemData.counts.threads > 0 || ListItemData.counts.replies > 0 || ListItemData.id !== ListItemData.thread_id) + visible: (ListItemData.counts.threads > 0 || ListItemData.id !== ListItemData.thread_id) + imageSource: "asset:///icons/comments.png" filterColor: (theme == VisualStyle.Bright) ? Color.Black : false maxWidth: ui.du(6) maxHeight: ui.du(6) @@ -99,7 +100,23 @@ Container { maxHeight: ui.du(6) accessibility.name: "favorite" } - + } + Container { + verticalAlignment: VerticalAlignment.Bottom + Label { + text: (ListItemData.counts.reposts > 0) ? ListItemData.counts.reposts : "" + textStyle.fontSize: FontSize.XXSmall + } + } + Container { + ImageView { + visible: (ListItemData.counts.reposts > 0) + imageSource: "asset:///icons/retweet.png" + filterColor: (theme == VisualStyle.Bright) ? Color.Black : false + maxWidth: ui.du(6) + maxHeight: ui.du(6) + accessibility.name: "repost" + } } } } @@ -157,12 +174,35 @@ Container { imageSource: "asset:///icons/ic_reply_all.png" } ActionItem { - title: qsTr("Add Bookmark") - imageSource: "asset:///icons/ic_add_bookmarks.png" + title: (ListItemData.you_bookmarked) ? qsTr("Delete Bookmark") : qsTr("Add Bookmark") + imageSource: "asset:///icons/ic_favorite.png" //(ListItemData.you_bookmarked) ? "asset:///icons/star.png" : "asset:///icons/star-o.png" onTriggered: { - postitem.ListItem.view.addBookmark(ListItemData.id); + if (ListItemData.you_bookmarked) { + postitem.ListItem.view.delBookmark(ListItemData.id); + } else { + postitem.ListItem.view.addBookmark(ListItemData.id); + } + } + } + ActionItem { + title: (ListItemData.you_reposted) ? qsTr("Delete Repost") : qsTr("Repost") + imageSource: "asset:///icons/retweet.png" + onTriggered: { + if (ListItemData.you_reposted) { + postitem.ListItem.view.delRepost(ListItemData.id); + } else { + postitem.ListItem.view.repost(ListItemData.id); + } + } + } + ActionItem { + title: qsTr("Quote") + imageSource: "asset:///icons/quote-left.png" + onTriggered: { + replySheet.text = " >> @" + ListItemData.user.username + ": " + ListItemData.content.text; + replySheet.open(); + // replySheet.input.requestFocus(); } - enabled: false } } ] diff --git a/assets/RefreshItem.qml b/assets/RefreshItem.qml new file mode 100644 index 0000000..22e45e0 --- /dev/null +++ b/assets/RefreshItem.qml @@ -0,0 +1,29 @@ +import bb.cascades 1.4 + +Container { + signal refresh + Label { + id: label_refresh + text: qsTr("Load Newer") + horizontalAlignment: HorizontalAlignment.Center + } + ImageView { + id: icon_refresh + imageSource: "asset:///icons/refresh.png" + horizontalAlignment: HorizontalAlignment.Center + filterColor: (theme == VisualStyle.Bright) ? Color.Black : false + } + Divider {} + attachedObjects: [ + LayoutUpdateHandler { + onLayoutFrameChanged: { + icon_refresh.rotationZ = layoutFrame.y + if (layoutFrame.y >= 0.0 * layoutFrame.height) { + if (layoutFrame.y == 0) { + refresh() + } + } + } + } + ] +} diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 1aeed18..1199628 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -34,6 +34,11 @@ NavigationPane { dataModel: ArrayDataModel { id: postModel } + leadingVisual: RefreshItem { + onRefresh: { + pnut.getStream(endpoint, Pnut.STREAM_NEWER); + } + } listItemComponents: [ ListItemComponent { id: root @@ -53,8 +58,16 @@ NavigationPane { return _app.setting("username"); } function addBookmark(pid) { - // pnut.setBookmark(pid); - console.log("- needs fixing -"); + pnut.setBookmark(pid); + } + function delBookmark(pid) { + pnut.deleteBookmark(pid); + } + function repost(pid) { + pnut.repost(pid); + } + function delRepost(pid) { + pnut.deleteRepost(pid); } } } @@ -94,19 +107,10 @@ NavigationPane { pnut.getStream(endpoint, Pnut.STREAM_OLDER); } imageSource: "asset:///icons/ic_to_bottom.png" - }, - ActionItem { - title: qsTr("Logout") - ActionBar.placement: ActionBarPlacement.InOverflow - onTriggered: { - postModel.clear() - pnut.beforeId = 0 - pnut.sinceId = 0 - _app.setSetting("access_token", ""); - } } ] actionBarAutoHideBehavior: ActionBarAutoHideBehavior.HideOnScroll + actionBarVisibility: ChromeVisibility.Overlay } attachedObjects: [ ComponentDefinition { @@ -133,10 +137,12 @@ NavigationPane { onStreamReceived: { switch (rtype) { case Pnut.STREAM_OLDER: + streamView.scrollToPosition(ScrollPosition.End, ScrollAnimation.None); postModel.append(stream); break; case Pnut.STREAM_NEWER: postModel.insert(0, stream); + streamView.scrollToPosition(ScrollPosition.Beginning, ScrollAnimation.None); break; } pnut.beforeId = postModel.value(postModel.size() - 1).id; diff --git a/assets/icons/comments.png b/assets/icons/comments.png new file mode 100644 index 0000000..47335f6 Binary files /dev/null and b/assets/icons/comments.png differ diff --git a/assets/icons/ic_del_bookmarks.png b/assets/icons/ic_del_bookmarks.png new file mode 100644 index 0000000..bdd39cc Binary files /dev/null and b/assets/icons/ic_del_bookmarks.png differ diff --git a/assets/icons/quote-left.png b/assets/icons/quote-left.png new file mode 100644 index 0000000..9fb35d4 Binary files /dev/null and b/assets/icons/quote-left.png differ diff --git a/assets/icons/refresh.png b/assets/icons/refresh.png new file mode 100644 index 0000000..8ce0d5f Binary files /dev/null and b/assets/icons/refresh.png differ diff --git a/assets/icons/retweet.png b/assets/icons/retweet.png new file mode 100644 index 0000000..8b22e7d Binary files /dev/null and b/assets/icons/retweet.png differ diff --git a/assets/icons/sign-out.png b/assets/icons/sign-out.png new file mode 100644 index 0000000..e7b84ac Binary files /dev/null and b/assets/icons/sign-out.png differ diff --git a/assets/icons/star-o.png b/assets/icons/star-o.png new file mode 100644 index 0000000..cefe2e1 Binary files /dev/null and b/assets/icons/star-o.png differ diff --git a/assets/icons/star.png b/assets/icons/star.png new file mode 100644 index 0000000..e98513e Binary files /dev/null and b/assets/icons/star.png differ diff --git a/assets/main.qml b/assets/main.qml index c65f410..61a1279 100644 --- a/assets/main.qml +++ b/assets/main.qml @@ -21,8 +21,24 @@ import bb.cascades 1.4 TabbedPane { id: main - showTabsOnActionBar: false - + + Menu.definition: MenuDefinition { + settingsAction: SettingsActionItem { + onTriggered: { + // + } + } + actions: [ + ActionItem { + title: qsTr("Logout") + imageSource: "asset:///icons/sign-out.png" + onTriggered: { + // + } + } + ] + } + Tab { id: globalStream title: qsTr("Global") diff --git a/bar-descriptor.xml b/bar-descriptor.xml index 1443274..b2a331a 100644 --- a/bar-descriptor.xml +++ b/bar-descriptor.xml @@ -30,7 +30,7 @@ armle-v7 Goober - lib/libkqoauth.so.1 + lib/libkqoauth.so.1 Qnx/Cascades diff --git a/buildnum b/buildnum index c24b6ae..2fb681e 100644 --- a/buildnum +++ b/buildnum @@ -1 +1 @@ -38 \ No newline at end of file +71 \ No newline at end of file diff --git a/config.pri b/config.pri index 7f16a96..6cc9595 100644 --- a/config.pri +++ b/config.pri @@ -68,11 +68,14 @@ config_pri_assets { OTHER_FILES += \ $$quote($$BASEDIR/assets/NewPostSheet.qml) \ $$quote($$BASEDIR/assets/PostItem.qml) \ + $$quote($$BASEDIR/assets/RefreshItem.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \ + $$quote($$BASEDIR/assets/icons/comments.png) \ $$quote($$BASEDIR/assets/icons/globe.png) \ $$quote($$BASEDIR/assets/icons/ic_add.png) \ $$quote($$BASEDIR/assets/icons/ic_add_bookmarks.png) \ + $$quote($$BASEDIR/assets/icons/ic_del_bookmarks.png) \ $$quote($$BASEDIR/assets/icons/ic_favorite.png) \ $$quote($$BASEDIR/assets/icons/ic_reload.png) \ $$quote($$BASEDIR/assets/icons/ic_reply.png) \ @@ -81,6 +84,11 @@ config_pri_assets { $$quote($$BASEDIR/assets/icons/ic_to_top.png) \ $$quote($$BASEDIR/assets/icons/laughing_man.png) \ $$quote($$BASEDIR/assets/icons/messages.png) \ + $$quote($$BASEDIR/assets/icons/quote-left.png) \ + $$quote($$BASEDIR/assets/icons/refresh.png) \ + $$quote($$BASEDIR/assets/icons/retweet.png) \ + $$quote($$BASEDIR/assets/icons/star-o.png) \ + $$quote($$BASEDIR/assets/icons/star.png) \ $$quote($$BASEDIR/assets/main.qml) \ $$quote($$BASEDIR/assets/moment.js) } diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 39b7616..6e59c8f 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -166,10 +166,11 @@ void Pnut::onRequestReady(QByteArray data) switch (oauthManager->lastError()) { case KQOAuthManager::NetworkError: - qDebug() << "- NetworkError - assume re-authorization"; - m_appSettings->remove("access_token"); - m_appSettings->remove("username"); - authorize(); + qDebug() << "- NetworkError -"; + qDebug() << data; +// m_appSettings->remove("access_token"); +// m_appSettings->remove("username"); +// authorize(); break; } } @@ -177,10 +178,10 @@ void Pnut::onRequestReady(QByteArray data) void Pnut::onAuthorizedRequestReady(QByteArray data, int id) { QString endpoint = req_map[id]; -// qDebug() << "- onAuthorizedRequestReady"; -// qDebug() << "- id: " << id; -// qDebug() << "- endpoint: " << endpoint; -// qDebug() << data; + qDebug() << "- onAuthorizedRequestReady"; + qDebug() << "- id: " << id; + qDebug() << "- endpoint: " << endpoint; + qDebug() << data; QVariant variant; bb::data::JsonDataAccess jda; @@ -316,3 +317,18 @@ void Pnut::deleteBookmark(QString pid) req_map[++req_id] = ":bookmark"; deleteRequest(url, parameters, req_id); } + +void Pnut::repost(QString pid) { + QUrl url(PNUT_API_ROOT + "/posts/" + pid + "/repost"); + KQOAuthParameters parameters; + req_map[++req_id] = ":repost"; + putRequest(url, parameters, req_id); +} + +void Pnut::deleteRepost(QString pid) +{ + QUrl url(PNUT_API_ROOT + "/posts/" + pid + "/repost"); + KQOAuthParameters parameters; + req_map[++req_id] = ":repost"; + deleteRequest(url, parameters, req_id); +} diff --git a/src/Pnut.h b/src/Pnut.h index 5f50f87..3a5336b 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -74,6 +74,8 @@ public: Q_INVOKABLE void getThread(QString pid); Q_INVOKABLE void setBookmark(QString pid); Q_INVOKABLE void deleteBookmark(QString pid); + Q_INVOKABLE void repost(QString pid); + Q_INVOKABLE void deleteRepost(QString pid); public slots: void onRequestReady(QByteArray data); diff --git a/translations/Goober.ts b/translations/Goober.ts index ca1a765..368bd8e 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -22,53 +22,81 @@ PostItem - + Reply - + Reply All - + Add Bookmark + + + Delete Bookmark + + + + + Repost + + + + + Delete Repost + + + + + Quote + + + + + RefreshItem + + + Load Newer + + StreamTab - + New Post - + Load Newer - + Reload - + Load Older - - - Logout - - main - + + Logout + + + + Global