diff --git a/assets/.assets.index b/assets/.assets.index index 17bada9..aedfdc8 100644 --- a/assets/.assets.index +++ b/assets/.assets.index @@ -1,6 +1,7 @@ 1 -36 +38 AppCover.qml +icons/at.png icons/bell-slash.png icons/bell.png icons/comments.png @@ -34,5 +35,6 @@ NewPostSheet.qml PostItem.qml ProfilePage.qml RefreshItem.qml +SettingsPage.qml StreamTab.qml ThreadPage.qml diff --git a/assets/SettingsPage.qml b/assets/SettingsPage.qml index 2449976..c96849a 100644 --- a/assets/SettingsPage.qml +++ b/assets/SettingsPage.qml @@ -3,16 +3,17 @@ import bb.cascades 1.4 Page { id: settingsPage - signal modifySetting(string setting, variant value) - titleBar: TitleBar { title: qsTr("Settings") } + + signal reload() + ScrollView { Container { layout: StackLayout {} Container { - topPadding: 15.0 + topPadding: ui.sdu(2) } Container { layout: DockLayout {} @@ -22,75 +23,85 @@ Page { verticalAlignment: VerticalAlignment.Center leftPadding: ui.sdu(3) Label { - text: "This is my toggle" + text: qsTr("Unified Home") + textStyle.fontSize: FontSize.Medium + textStyle.fontWeight: FontWeight.Bold + } + Label { + text: qsTr("Include mentions in home stream") + textStyle.fontSize: FontSize.Small } } Container { rightPadding: ui.sdu(3) horizontalAlignment: HorizontalAlignment.Right + verticalAlignment: VerticalAlignment.Center ToggleButton { - checked: true + checked: _app.setting("unified") onCheckedChanged: { if (checked) { - modifySetting("datenew", true) + _app.setSetting("unified", true) + reload() } else { - modifySetting("datenew", false) + _app.setSetting("unified", false) + reload() } } + accessibility.name: "unified" } } } Divider {} - Container { - layout: DockLayout {} - horizontalAlignment: HorizontalAlignment.Fill - Container { - leftPadding: ui.sdu(3) - rightPadding: ui.sdu(3) - DropDown { - title: "Dropdown" - preferredWidth: 1440.0 - onSelectedIndexChanged: { - modifySetting("sort", selectedValue) - } - Option { - text: "Option Zero" - value: 0 - selected: sort == 0 - } - Option { - text: "Option Three" - value: 3 - selected: sort == 3 - } - Option { - text: "Option One" - value: 1 - selected: sort == 1 - } - Option { - text: "Option Two" - value: 2 - selected: sort == 2 - } - } - } - } - Divider {} - Container { - layout: DockLayout {} - horizontalAlignment: HorizontalAlignment.Fill - leftPadding: 30.0 - rightPadding: 30.0 - Button { - preferredWidth: 1440.0 - text: "Button" - onClicked: { - console.log("button") - } - } - } - Divider {} +// Container { +// layout: DockLayout {} +// horizontalAlignment: HorizontalAlignment.Fill +// Container { +// leftPadding: ui.sdu(3) +// rightPadding: ui.sdu(3) +// DropDown { +// title: "Dropdown" +// preferredWidth: 1440.0 +// onSelectedIndexChanged: { +// modifySetting("sort", selectedValue) +// } +// Option { +// text: "Option Zero" +// value: 0 +// selected: sort == 0 +// } +// Option { +// text: "Option Three" +// value: 3 +// selected: sort == 3 +// } +// Option { +// text: "Option One" +// value: 1 +// selected: sort == 1 +// } +// Option { +// text: "Option Two" +// value: 2 +// selected: sort == 2 +// } +// } +// } +// } +// Divider {} +// Container { +// layout: DockLayout {} +// horizontalAlignment: HorizontalAlignment.Fill +// leftPadding: 30.0 +// rightPadding: 30.0 +// Button { +// preferredWidth: 1440.0 +// text: "Button" +// onClicked: { +// console.log("button") +// } +// } +// } +// Divider {} } } } diff --git a/assets/StreamTab.qml b/assets/StreamTab.qml index b3f81e3..a189ded 100644 --- a/assets/StreamTab.qml +++ b/assets/StreamTab.qml @@ -150,10 +150,7 @@ NavigationPane { title: qsTr("Reload") ActionBar.placement: ActionBarPlacement.InOverflow onTriggered: { - postModel.clear() - pnut.beforeId = 0 - pnut.sinceId = 0 - pnut.getStream(endpoint, Pnut.STREAM_OLDER); + reload() } imageSource: "asset:///icons/ic_reload.png" }, @@ -251,10 +248,7 @@ NavigationPane { function update_user_page(user) { nav.top.user = user - postModel.clear() - pnut.beforeId = 0 - pnut.sinceId = 0 - pnut.getStream(endpoint, Pnut.STREAM_OLDER) + reload() } function update_app_cover(count) { @@ -271,15 +265,7 @@ NavigationPane { page.destroy(); } onCreationCompleted: { - switch (stream_type) { - case "Home": - endpoint = "/posts/streams/unified" - break; - case "Global": - default: - endpoint = "/posts/streams/global" - break; - } + setEndpoint() if (_app.setting("access_token") && _app.setting("access_token").length > 0) { console.log("__I think I'm authenticated") pnut.getUserInfo() @@ -291,10 +277,32 @@ NavigationPane { timer.stop() } } + function setEndpoint() { + switch (stream_type) { + case "Home": + var hometype = (_app.setting("unified") === "true") ? "unified" : "me" + endpoint = "/posts/streams/" + hometype + break; + case "Mentions": + endpoint = "/users/me/mentions" + break; + case "Global": + default: + endpoint = "/posts/streams/global" + break; + } + } function login() { pnut.authorize() } function logout() { pnut.logout() } + function reload() { + setEndpoint() + postModel.clear() + pnut.beforeId = 0 + pnut.sinceId = 0 + pnut.getStream(endpoint, Pnut.STREAM_OLDER); + } } diff --git a/assets/icons/at.png b/assets/icons/at.png new file mode 100644 index 0000000..f187149 Binary files /dev/null and b/assets/icons/at.png differ diff --git a/assets/main.qml b/assets/main.qml index ddb893f..84d33d0 100644 --- a/assets/main.qml +++ b/assets/main.qml @@ -25,7 +25,9 @@ TabbedPane { Menu.definition: MenuDefinition { settingsAction: SettingsActionItem { onTriggered: { - // + var page = settingsPage.createObject() + page.reload.connect(activePane.reload) + activePane.push(page) } } actions: [ @@ -39,11 +41,23 @@ TabbedPane { ] } - activeTab: globalStream + activeTab: { + switch(_app.setting("activetab")) { + case "GlobalTab": + return globalStream + break; + case "HomeTab": + return homeStream + break; + default: + return globalStream + } + } Tab { id: homeStream title: qsTr("Home") + objectName: "HomeTab" delegate: Delegate { StreamTab { title: qsTr("Home") @@ -62,9 +76,32 @@ TabbedPane { } } + Tab { + id: mentionStream + title: qsTr("Mentions") + objectName: "MentionTab" + delegate: Delegate { + StreamTab { + title: qsTr("Mentions") + stream_type: "Mentions" + onOpenLogin: { + loginSheet.open() + } + onCloseLogin: { + loginSheet.close() + } + } + } + imageSource: "asset:///icons/at.png" + onUnreadContentCountChanged: { + _activeFrame.setGlobalUnread(unreadContentCount) + } + } + Tab { id: globalStream title: qsTr("Global") + objectName: "GlobalTab" delegate: Delegate { StreamTab { title: qsTr("Global") @@ -83,12 +120,20 @@ TabbedPane { } } + onActiveTabChanged: { + _app.setSetting("activetab", activeTab.objectName) + } + attachedObjects: [ LoginSheet { id: loginSheet onLogin: { activePane.login() } + }, + ComponentDefinition { + id: settingsPage + source: "SettingsPage.qml" } ] diff --git a/buildnum b/buildnum index a5b5e0f..ae4ee13 100644 --- a/buildnum +++ b/buildnum @@ -1 +1 @@ -181 \ No newline at end of file +200 \ No newline at end of file diff --git a/config.pri b/config.pri index 6b5b4df..c3a7058 100644 --- a/config.pri +++ b/config.pri @@ -75,6 +75,7 @@ config_pri_assets { $$quote($$BASEDIR/assets/SettingsPage.qml) \ $$quote($$BASEDIR/assets/StreamTab.qml) \ $$quote($$BASEDIR/assets/ThreadPage.qml) \ + $$quote($$BASEDIR/assets/icons/at.png) \ $$quote($$BASEDIR/assets/icons/bell-slash.png) \ $$quote($$BASEDIR/assets/icons/bell.png) \ $$quote($$BASEDIR/assets/icons/comments.png) \ diff --git a/src/Pnut.cpp b/src/Pnut.cpp index eeae90a..b9ec009 100644 --- a/src/Pnut.cpp +++ b/src/Pnut.cpp @@ -201,7 +201,7 @@ void Pnut::onAuthorizedRequestReady(QByteArray data, int id) { case Pnut::OK: { - if (endpoint.startsWith("/posts/streams/")) + if (endpoint.startsWith("/posts/streams/") || endpoint == "/users/me/mentions") { Pnut::RequestType rtype = rtype_map[id]; emit streamReceived(variant.toMap()["data"].toList(), rtype); diff --git a/translations/Goober.ts b/translations/Goober.ts index 0aa1ecb..a6db05f 100644 --- a/translations/Goober.ts +++ b/translations/Goober.ts @@ -126,6 +126,24 @@ + + SettingsPage + + + Settings + + + + + Unified Home + + + + + Include mentions in home stream + + + StreamTab @@ -139,7 +157,7 @@ - + To Bottom @@ -152,19 +170,25 @@ main - + Logout - - + + Home - - + + + Mentions + + + + + Global