diff --git a/assets/.assets.index b/assets/.assets.index index 3495f3d..4a5571a 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,5 +1,5 @@ 1 -43 +45 AboutPage.qml AppCover.qml icons/at.png @@ -43,3 +43,5 @@ RefreshItem.qml SettingsPage.qml StreamTab.qml ThreadPage.qml +UserItem.qml +UserPage.qml diff --git a/assets/PostItem.qml b/assets/PostItem.qml index 1440892..0cc6deb 100644 --- a/assets/PostItem.qml +++ b/assets/PostItem.qml @@ -64,13 +64,14 @@ Container { Container { Label { id: username - text: "" + ListItemData.user.username + "" - activeTextHandler: ActiveTextHandler { - onTriggered: { - postitem.ListItem.view.viewProfile(ListItemData.user) - } - } - textFormat: TextFormat.Html + text: ListItemData.user.username +// text: "" + ListItemData.user.username + "" +// activeTextHandler: ActiveTextHandler { +// onTriggered: { +// postitem.ListItem.view.viewProfile(ListItemData.user) +// } +// } +// textFormat: TextFormat.Html } } } diff --git a/assets/ProfilePage.qml b/assets/ProfilePage.qml index 4894f57..55466d2 100644 --- a/assets/ProfilePage.qml +++ b/assets/ProfilePage.qml @@ -1,18 +1,18 @@ /* * Copyright (C) 2016 Morgan McMillian - * + * * This file is apart of the Goober application, a client for pnut.io - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -21,22 +21,24 @@ import bb.cascades 1.4 import org.labsquare 1.0 Page { - + property variant user - property variant theme : Application.themeSupport.theme.colorTheme.style + property variant theme: Application.themeSupport.theme.colorTheme.style property string lorem: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non enim tellus. Donec vestibulum enim urna, eget faucibus diam commodo a. Donec eget hendrerit metus. Pellentesque vehicula nisi nec vehicula ullamcorper. Aliquam a elit eget mi fringilla porta fermentum eget eros. Phasellus vestibulum nulla sed elit congue adipiscing. Cras imperdiet urna ac ipsum volutpat lobortis. Maecenas vehicula tortor at viverra convallis. Curabitur nibh massa, tristique id felis ut, venenatis faucibus dui. Donec fringilla, mi nec tincidunt dignissim, neque nunc semper mi, quis rutrum diam turpis sit amet erat. Cras a sodales nisi. Nunc sit amet diam sed lectus molestie cursus convallis et erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis vitae varius leo. Mauris eu leo a nunc bibendum rutrum euismod et ipsum. " - + signal follow(string uid) signal unfollow(string uid) signal block(string uid) signal unblock(string uid) signal mute(string uid) signal unmute(string uid) - + signal getPosts(string uid) + ScrollView { Container { Container { - layout: DockLayout {} + layout: DockLayout { + } horizontalAlignment: HorizontalAlignment.Fill preferredHeight: cover.height Container { @@ -79,7 +81,7 @@ Page { text: user.name textStyle.fontWeight: FontWeight.Bold textStyle.fontSize: FontSize.Large - + } } Container { @@ -87,20 +89,21 @@ Page { //text: "thrrgilag" text: user.username textStyle.fontSize: FontSize.Medium - + } - + } } - + } - + } Container { topPadding: ui.sdu(3) leftPadding: ui.sdu(3) rightPadding: ui.sdu(3) - layout: DockLayout {} + layout: DockLayout { + } horizontalAlignment: HorizontalAlignment.Fill Container { preferredWidth: ui.du(45) @@ -122,7 +125,7 @@ Page { horizontalAlignment: HorizontalAlignment.Right Label { text: qsTr("Following") - + } Label { text: user.counts.following @@ -135,7 +138,7 @@ Page { horizontalAlignment: HorizontalAlignment.Right Label { text: qsTr("Followers") - + } Label { text: user.counts.followers @@ -148,7 +151,7 @@ Page { horizontalAlignment: HorizontalAlignment.Right Label { text: qsTr("Posts") - + } Label { text: user.counts.posts @@ -161,16 +164,66 @@ Page { horizontalAlignment: HorizontalAlignment.Right Label { text: qsTr("Bookmarks") - + } Label { text: user.counts.bookmarks } } } - + + } + Divider { + + } + Container { + layout: StackLayout { + orientation: LayoutOrientation.LeftToRight + } + Container { + leftPadding: ui.sdu(1) + rightPadding: ui.sdu(.5) + Button { + text: qsTr("Posts") + onClicked: { + var page = postPage.createObject() + pnut.userStreamReceived.connect(page.loadThread) + pnut.getUserStream(user.id) + nav.push(page) + } + } + } + Container { + leftPadding: ui.sdu(.5) + rightPadding: ui.sdu(.5) + Button { + text: qsTr("Following") + onClicked: { + var page = userListPage.createObject() + pnut.followSuccess.connect(page.updateUser) + pnut.unfollowSuccess.connect(page.updateUser) + pnut.userListReceived.connect(page.loadThread) + pnut.getFollowing(user.id) + nav.push(page) + } + } + } + Container { + leftPadding: ui.sdu(.5) + rightPadding: ui.sdu(1) + Button { + text: qsTr("Followers") + onClicked: { + var page = userListPage.createObject() + pnut.followSuccess.connect(page.updateUser) + pnut.unfollowSuccess.connect(page.updateUser) + pnut.userListReceived.connect(page.loadThread) + pnut.getFollowers(user.id) + nav.push(page) + } + } + } } - } } @@ -215,4 +268,15 @@ Page { enabled: (_app.setting("username") === user.username) ? false : true } ] + + attachedObjects: [ + ComponentDefinition { + id: postPage + source: "ThreadPage.qml" + }, + ComponentDefinition { + id: userListPage + source: "UserPage.qml" + } + ] } diff --git a/assets/SettingsPage.qml b/assets/SettingsPage.qml index 4d677ed..67b85c1 100644 --- a/assets/SettingsPage.qml +++ b/assets/SettingsPage.qml @@ -110,6 +110,29 @@ Page { } } Divider {} + Container { + leftPadding: ui.sdu(3) + rightPadding: ui.sdu(3) + DropDown { + title: qsTr("Theme") + Option { + text: qsTr("Bright") + value: VisualStyle.Bright + selected: Application.themeSupport.theme.colorTheme.style == VisualStyle.Bright + } + Option { + text: qsTr("Dark") + value: VisualStyle.Dark + selected: Application.themeSupport.theme.colorTheme.style == VisualStyle.Dark + } + onSelectedOptionChanged: { + _app.setSetting("theme", selectedValue) + Application.themeSupport.setVisualStyle(selectedValue) + } + } + + } + Divider {} // Container { // layout: DockLayout {} // horizontalAlignment: HorizontalAlignment.Fill diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index 82a8d29..50a9fdc 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -74,12 +74,15 @@ NavigationPane { function viewProfile(userobj) { var page = profilePage.createObject(); page.user = userobj + //pnut.userStreamReceived.connect(page.loadThread) + //pnut.getUserStream(userobj.id) page.follow.connect(pnut.followUser) page.unfollow.connect(pnut.unfollowUser) page.block.connect(pnut.blockUser) page.unblock.connect(pnut.unblockUser) page.mute.connect(pnut.muteUser) page.unmute.connect(pnut.unmuteUser) + //page.getPosts.connect(pnut.getUserStream) nav.push(page); } function sendReply(text, pid) { diff --git a/assets/UserItem.qml b/assets/UserItem.qml new file mode 100644 index 0000000..380bdeb --- /dev/null +++ b/assets/UserItem.qml @@ -0,0 +1,69 @@ +import bb.cascades 1.4 +import org.labsquare 1.0 + +Container { + id: useritem + + property variant theme : Application.themeSupport.theme.colorTheme.style + property string lorem: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse non enim tellus. Donec vestibulum enim urna, eget faucibus diam commodo a. Donec eget hendrerit metus. Pellentesque vehicula nisi nec vehicula ullamcorper. Aliquam a elit eget mi fringilla porta fermentum eget eros. Phasellus vestibulum nulla sed elit congue adipiscing. Cras imperdiet urna ac ipsum volutpat lobortis. Maecenas vehicula tortor at viverra convallis. Curabitur nibh massa, tristique id felis ut, venenatis faucibus dui. Donec fringilla, mi nec tincidunt dignissim, neque nunc semper mi, quis rutrum diam turpis sit amet erat. Cras a sodales nisi. Nunc sit amet diam sed lectus molestie cursus convallis et erat. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Duis vitae varius leo. Mauris eu leo a nunc bibendum rutrum euismod et ipsum. " + + leftPadding: ui.sdu(3.0) + rightPadding: ui.sdu(3.0) + topPadding: ui.sdu(2.0) + Container { + layout: DockLayout { + } + Container { + layout: StackLayout { + orientation: LayoutOrientation.LeftToRight + } + Container { + minWidth: ui.du(12) + background: (theme === VisualStyle.Bright) ? Color.create("#e9e9e9") : Color.create("#282828") + WebImageView { + id: avatar + url: ListItemData.content.avatar_image.link + maxWidth: ui.du(12) + maxHeight: ui.du(12) + //imageSource: "asset:///icons/laughing_man.png" + } + } + Container { + preferredWidth: 1440 + leftMargin: ui.sdu(3.0) + Container { + Label { + id: username + text: ListItemData.username + textStyle.fontWeight: FontWeight.Bold + } + } + Container { + Label { + id: description + text: ListItemData.content.html + multiline: true + textFormat: TextFormat.Html + } + } + } + Container { + minWidth: ui.du(24) + verticalAlignment: VerticalAlignment.Center + Button { + text: (ListItemData.you_follow) ? qsTr("Unfollow") : qsTr("Follow") + onClicked: { + if (ListItemData.you_follow) { + useritem.ListItem.view.unfollow(ListItemData) + } else { + useritem.ListItem.view.follow(ListItemData) + } + } + } + } + } + } + Divider { + + } +} diff --git a/assets/UserPage.qml b/assets/UserPage.qml new file mode 100644 index 0000000..b7687f7 --- /dev/null +++ b/assets/UserPage.qml @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Morgan McMillian + * + * This file is apart of the Goober application, a client for pnut.io + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import bb.cascades 1.4 + +Page { + + property variant updateUserObj + + Container { + ListView { + id: userListView + dataModel: ArrayDataModel { + id: listModel + } + listItemComponents: [ + ListItemComponent { + id: root + UserItem {} + } + ] + function follow(usero) { + console.log("---> follow") + updateUserObj = usero + pnut.followUser(usero.id) + } + function unfollow(usero) { + console.log("---> unfollow") + updateUserObj = usero + pnut.unfollowUser(usero.id) + } + } + } + + function loadThread(data) { + listModel.append(data); + } + + function updateUser(userobj) { + console.log("---> updating entry " + listModel.indexOf(updateUserObj)) + listModel.replace(listModel.indexOf(updateUserObj), userobj) + } +} diff --git a/assets/main.qml b/assets/main.qml index 77d37d3..1138ac3 100644 --- a/assets/main.qml +++ b/assets/main.qml @@ -172,4 +172,13 @@ TabbedPane { } ] + onCreationCompleted: { + var style = _app.setting("theme").toString() + if (style === "1") { + Application.themeSupport.setVisualStyle(VisualStyle.Bright) + } else if (style === "2") { + Application.themeSupport.setVisualStyle(VisualStyle.Dark) + } + } + } diff --git a/config.pri b/config.pri index 5f84b1b..f94503d 100644 --- a/config.pri +++ b/config.pri @@ -76,6 +76,8 @@ config_pri_assets { $$quote($$BASEDIR/assets/SettingsPage.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \ + $$quote($$BASEDIR/assets/UserItem.qml) \ + $$quote($$BASEDIR/assets/UserPage.qml) \ $$quote($$BASEDIR/assets/icons/at.png) \ $$quote($$BASEDIR/assets/icons/bell-slash.png) \ $$quote($$BASEDIR/assets/icons/bell.png) \ diff --git a/src/Pnut.cpp b/src/Pnut.cpp index 7e8b4a0..7ad1cfc 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -192,7 +192,7 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) qDebug() << "- onAuthorizedRequestReady"; qDebug() << "- id: " << id; qDebug() << "- endpoint: " << endpoint; -// qDebug() << data; + qDebug() << data; QVariant variant; bb::data::JsonDataAccess jda; @@ -223,6 +223,16 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) emit threadReceived(variant.toMap()["data"].toList()); req_map.remove(id); } + else if (endpoint == ":userstream") + { + emit userStreamReceived(variant.toMap()["data"].toList()); + req_map.remove(id); + } + else if (endpoint == ":followers" || endpoint == ":following") + { + emit userListReceived(variant.toMap()["data"].toList()); + req_map.remove(id); + } else if (endpoint == ":logout") { qDebug() << "Logout successful!"; @@ -485,3 +495,27 @@ void Pnut::getPost(QString pid) req_map[++req_id] = ":getpost:" + pid; getRequest(url, parameters, req_id); } + +void Pnut::getUserStream(QString uid) +{ + QUrl url(PNUT_API_ROOT + "/users/" + uid + "/posts"); + KQOAuthParameters parameters; + req_map[++req_id] = ":userstream"; + getRequest(url, parameters, req_id); +} + +void Pnut::getFollowers(QString uid) +{ + QUrl url(PNUT_API_ROOT + "/users/" + uid + "/followers"); + KQOAuthParameters parameters; + req_map[++req_id] = ":followers"; + getRequest(url, parameters, req_id); +} + +void Pnut::getFollowing(QString uid) +{ + QUrl url(PNUT_API_ROOT + "/users/" + uid + "/following"); + KQOAuthParameters parameters; + req_map[++req_id] = ":following"; + getRequest(url, parameters, req_id); +} diff --git a/src/Pnut.h b/src/Pnut.h index 3176981..4c1db5f 100644 --- a/src/Pnut.h +++ b/src/Pnut.h @@ -85,6 +85,9 @@ public: Q_INVOKABLE void logout(); Q_INVOKABLE void deletePost(QString pid); Q_INVOKABLE void getPost(QString pid); + Q_INVOKABLE void getUserStream(QString uid); + Q_INVOKABLE void getFollowers(QString uid); + Q_INVOKABLE void getFollowing(QString uid); public slots: void onRequestReady(QByteArray data); @@ -103,6 +106,8 @@ Q_SIGNALS: void muteSuccess(QVariantMap user); void unmuteSuccess(QVariantMap user); void postReceived(QVariantMap post); + void userStreamReceived(QVariantList stream); + void userListReceived(QVariantList users); private: static const QString PNUT_API_ROOT; diff --git a/translations/Goober.ts b/translations/Goober.ts index aca0054..db39926 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -30,52 +30,52 @@ PostItem - + <i>{{POST DELETED}}</i> - + Reply - + Reply All - + Add Bookmark - + Delete Bookmark - + Repost - + Delete Repost - + Quote - + View Profile - + Delete @@ -83,52 +83,55 @@ ProfilePage - + + Following - + + Followers - + + Posts - + Bookmarks - + Unfollow - + Follow - + Unmute - + Mute - + Unblock - + Block @@ -168,30 +171,58 @@ Additional mentions follow / + + + Theme + + + + + Bright + + + + + Dark + + StreamTab - + New Post - + To Top - + To Bottom - + Reload + + UserItem + + + Unfollow + + + + + Follow + + + main