From b80fafa99cad3414aa79085ec9bb19e24ce54e29 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Sat, 1 Oct 2016 06:40:48 -0700 Subject: [PATCH] updated visuals, added pull to load new, add/remove bookmarks and reposts, and quote a post. --- assets/.assets.index | 10 +++++- assets/PostItem.qml | 54 ++++++++++++++++++++++++++---- assets/RefreshItem.qml | 29 ++++++++++++++++ assets/StreamTab.qml | 30 ++++++++++------- assets/icons/comments.png | Bin 0 -> 1291 bytes assets/icons/ic_del_bookmarks.png | Bin 0 -> 1313 bytes assets/icons/quote-left.png | Bin 0 -> 1052 bytes assets/icons/refresh.png | Bin 0 -> 1185 bytes assets/icons/retweet.png | Bin 0 -> 834 bytes assets/icons/sign-out.png | Bin 0 -> 788 bytes assets/icons/star-o.png | Bin 0 -> 1363 bytes assets/icons/star.png | Bin 0 -> 1070 bytes assets/main.qml | 20 +++++++++-- bar-descriptor.xml | 2 +- buildnum | 2 +- config.pri | 8 +++++ src/Pnut.cpp | 32 +++++++++++++----- src/Pnut.h | 2 ++ translations/Goober.ts | 54 +++++++++++++++++++++++------- 19 files changed, 198 insertions(+), 45 deletions(-) create mode 100644 assets/RefreshItem.qml create mode 100644 assets/icons/comments.png create mode 100644 assets/icons/ic_del_bookmarks.png create mode 100644 assets/icons/quote-left.png create mode 100644 assets/icons/refresh.png create mode 100644 assets/icons/retweet.png create mode 100644 assets/icons/sign-out.png create mode 100644 assets/icons/star-o.png create mode 100644 assets/icons/star.png 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 0000000000000000000000000000000000000000..47335f611f304000984666c6240a0297de61b97f GIT binary patch literal 1291 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X)(7~6xc(mnqaiSKLZE)HMmaDA zGnNGT1v5B2yO9RsBze2LFm$lWdH^|`1s;*b3=G`DAk4@xYmNj^kiEpy*OmPN7b6Rk z^z>tALx6g&db&7X9JP)Z`+pilyo0EH5u1SpgMCBSp^ z2QC8pl>iy60!9EUfN~|kJr<<=y)eWRNCdnlTn1cCd43xh0wgs8+@Pk(^TEJal^_}U ziSWHjkc|99cmVVR8Z`pk%1?woz!a4r8TkoPhC-B}bn+9S4(JQK(FkxWKM{HW->3x1 z$WMetDnT;x6X69=Y9BQM9FKm0PC%tfkbC_PPKH8~pwE?`2ybjQRHqT(R(>M11*%no zWaKB9Nm(col&SngXvEZp9%ux(m7mn}^Ln8s6as2;*mto?kc|99NMcsXZfgX%m7kA; z%;zWwfqiFlFb%vG1wAz->neaSdAJDCpIR6~51h^B*MC_=&K%WlW@r}SXpdxPP z=Q{!-lmMITRveh~?*q$#zw>3lWihS-_#GG!i1SZiZv1%SYbhdAoB~Dx$2@m@1F#;b z%D3}fM?fmp0>1zqJk0GEVeUI~0?GA&;lN@0=mYlIk^j=AQOR=j6<{2&OW5)Cm~!=M z*Up!YfK*fid&#n*m;=sYIw$T*ow!d+l9MsTJ(nrwK;WI^N&B=S_O)Ys{jx}ji|ow4 zdtAQriGaBRHmkCj71smLi0M8wUkDfkj25sf-a+jP0rQ0HR$%U^Q38bQ76Y>joq+zp zctQJ>g-*a+%#x-QW+1qX>I(sq=nPCNR02wYNgfP>szN1TP7I&nPvBOL$CxeU3uyx8 z=df=B@FOq_v-G)(?7u6h6qrzG1oXtzf3m?fn>p>UPJe;vOPUGPh9pCh1XKcTve<7g zFb25P%zJ-fdXs(&B^{L{Ak)cLJ?374HMCr}e-13SBl=;=>rq?DS3pOb`lfEfB%B~s zj{d?rr`>1%{~1i({$7T5dI38zci3#kLr4*@1k)k$DZB@^0$UKS+uQ3)bCP*7mxGpg zJo&1{w0!>?qul|(ufW6%qAxX@AmX2s1H=SR`_orDCXn|xix^yFO0lid>hL$PZK zY7aaDx-@xxH?RSCm1o=6Z5rwW9s$E#kBS*hoL^_P-bK4&gUw`i+lz3UG+Ecf804=A z=nZ_?%zN*E|7;nh&NTt4U#54;W;yp9+P?uz&2rz4Xp=P(GVa#1eikV-GM2I zu_VYZn8D%MjWiG^$=lt9p@UV{1IXbl@Q5sCVBi)8VMc~ob0mO*>?NMQuIvxE7+K_W zPV$(t0rkXrx;Tbp+*s35Ny7of*-?Oi;1)ZICVfHTuSE0bof?i+sZwPZcg<95y(^_MF>9d(Hj}pI80`20nwQtDnm{r-UW|_*e9Q literal 0 HcmV?d00001 diff --git a/assets/icons/refresh.png b/assets/icons/refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..8ce0d5f56a863c1071b4d4a4722b623bb342ff0d GIT binary patch literal 1185 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X3IcpWT>p=P(GZ|x2+Xckcn3^^ zj3q&S!3+-1Zlr-YN#5=*3>~bp9zYIffk$L90|U1(2s1Lwnj--eWH0gbb!C6R#mLIb zRjo5S4yb39r;B4q#=W;Qe7%_s1=>DWN3W9W>WZEq_lM!NqpOP-f7ep2j;&W+KQ1}C zqp9rQq@`T5|9YjXJ$9V&{7UZq%KK+8scbfM3lwn;^f0mZH%OQ0tlmC<;eo~l|81vi z(tW&-TW-^(L*f#42Tw0m-n#j<-o<|cVo7s|}XESkU zlVCi+lv^JfC*N6S10Iw9+uPuY>}JzK-xaC)-1^t^TY z9qbzTkF&>BXOT|X`lpQg`(|+#TOZ&{oU!WH8-_;RQ_=~As>*o{6Qvsz@9%eLxW4}( z$NLJ#px&a;hW+*ahnN$VN9_^%RrL8Vt6z=G1`*ahnn~%OJma>{7rw(HudpTNYSo!{ zl7HD*;~!gWQE#=kWAvv_F8aQ1;^RFT_8A@9Q)c(?Uw=L~*I(2%P(8v=YnT>p=P0Sy8Eryak6QNmaf zlIxA0U*#&FU}bAvy|?rG z&fsmfyEbo@HEk1c;!tc6kpINq$}Rcmj__RUJ4|C%|%;Ahzl3%^OH z|Ll?2^S-ySDLQq!s$arOCgF(R4J=Rn^b!U1FEGvgvry`I{OWn$_lko4K9Zhsz-%k? z1P5uG?`3_PRYY30au+<)zo1_@^TDNU3+`__Fk^4+m&+VePA>g>sPO;N2l1?Xr?EuF zUW@t5`ux|PIn~@!LiMlhUFDA3J4|3=Y1~&gQ7^dKQnK-r!qy)7!$Q81_fN7;eVQV^ zGxPyh$Zd_4%MRJ?3VGG|NZ3(jL(OlO3P(jg?Pg&W(ZmkkfC)ihAe}ptDnm{r-UW|$lEX7 literal 0 HcmV?d00001 diff --git a/assets/icons/sign-out.png b/assets/icons/sign-out.png new file mode 100644 index 0000000000000000000000000000000000000000..e7b84acc1e379adfc0704d16131cbd7907c0c171 GIT binary patch literal 788 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4y>^8$QAT>p;(I)=ct8!mjn2w*G; z@(X5gcy=QV#7XjYcVXyYmGuB}I14-?iy0WWg+Z8+Vb&Z8pdfpRr>`sf11?53CJpUL z6*@pY@}4e^AsP4H&e+X&$biT7bFRUm15CnB3JV??eh?`AaNk&AiBsFJi`s!7W=79f zTRG{+G7%O>0hWXH#`E@E%>5`jeUGidm#gV{f(G+tpLX76dD`*kemvKS=>2vfzNg$z z1lQ~SV)Onx^U2le3eoHvgx60BRQS(p6t%!SgY{M9C2kJgfWCuDCo&pO1#qm>Ij9%W z@k%@Fm$N~-rkkUxm_U?5Z02qU3vW3`H*S~Y51d9(2TY?5eBa0YAo$AX`%|j+g$h({ z{(Xs=y)I>038Vb4McLe{8x}kdcmMHJyrwpM`>d$OwXL_9XCGL(tk-nwqx0eB8{GB? zs>;mvJhW}IhT`3p#17lMl@|;9G$vU6R9c^UyU*r@!ggsz=Yt9yO$r=!{p`}Q1{+=| SNU{P$kHOQ`&t;ucLK6UQR|{1D literal 0 HcmV?d00001 diff --git a/assets/icons/star-o.png b/assets/icons/star-o.png new file mode 100644 index 0000000000000000000000000000000000000000..cefe2e1e9ea5dba55370d44b07ae2bb6855ddc05 GIT binary patch literal 1363 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X76kZ&xc(mnqaiSeLqPYSI4dy8 zGL{7S1v5B2yO9RsBze2LFm$lWdH^|`1s;*b3=G`DAk4@xYmNj^kiEpy*OmPN7bCN| z>6<)}6~NT4$J@IAP2n~nu*zogFtQSlefz7L!(>&=z7J>a{i(Nkz!jRVVvr#o8% z3M{nWz1M0u;M{RJvxK4l;+O5kQw(!kV|vcNJh9X%@5=YN1-tic)AWgvTww67AX`{9 zGV{V&)2`-{680Y^FYZXYw77*AY)IS_?DS&V<8@E)Z73#onh2FQ4Mz`m*8o z0{OKL?K95LE@@-B_tCYlRhhA$_t)hUMY z%!}B6iK(T$_2j>23QGNkdybsVJ)`q2Der=t#EtwVMkcDeeU=nGIeKn#&9h5PSGI56 pC-DE&n&VHne)w~22WQ%mvv4FO#p=3&I|wm literal 0 HcmV?d00001 diff --git a/assets/icons/star.png b/assets/icons/star.png new file mode 100644 index 0000000000000000000000000000000000000000..e98513ec2149d758812a0369a86f008f6a4806b3 GIT binary patch literal 1070 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD3?#3*wF4!X%maKvT>p=P(GVa#1eikV-GM2I zu_VYZn8D%MjWiG^$=lt9p@UV{1IXbl@Q5sCVBi)8VMc~ob0mO*>?NMQuIvxE7#Z|c z3tN=V0QD4jx;Tbp+CDv2C)63Gx_o#^p3$t_4xQshUH_UoU8 zUl*ii>@H7xr`Y{_@3|_w_jBjol)Ywo*q~=W`+>9j+2u~MGB|HzcvG|Cb0^!j1@_`L z6SxzmGECsjaV!rk@YZ8^v5__5dGp-$c?sNl(^zGT7`!iH8-E# zj%NPlb~ioE969_mOUoKFx*BdD?Y}Qt^62yVQ|b@rL?2*ZyW@x3*WN1~C+(-`H2?ij z^KjQa-m~{7>phjd^d~HD{?nY_IqtLn{p>tt?6%mpc-fPh{Zh;NvN>v3J>B#p=69~s z$G400POf+7@Kb3@-hNEi=-_|xn3F8i4>oP|`QY|0prZds|JGgyM}Msyfp0D(EV!{) z)N}ngTVdAC!ahzyBJ=gzUbZOyu$!jIu}w^9-Sqa`7uBDIUA6xsW#9Gc!s+wVc@|fh z{C>OQ&8)yJ3qIw{?Kzwtxy$$2lYX(bM2WVIY 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