From a24eb2d25cb25ece571d82c42ddd33788198c054 Mon Sep 17 00:00:00 2001 From: Dusko Angirevic Date: Thu, 8 Jun 2017 00:53:54 +0200 Subject: [PATCH] New Toot option added --- harbour-tooter.pro | 3 +- harbour-tooter.pro.user | 28 +++--- qml/lib/Worker.js | 2 +- qml/pages/Conversation.qml | 140 ++++++++++++++++++++++++++++++ qml/pages/MainPage.qml | 19 ++++ qml/pages/components/Toot.qml | 10 ++- translations/harbour-tooter-de.ts | 27 ++++++ translations/harbour-tooter.ts | 27 ++++++ 8 files changed, 239 insertions(+), 17 deletions(-) create mode 100644 qml/pages/Conversation.qml diff --git a/harbour-tooter.pro b/harbour-tooter.pro index ea57ac2..6a94e7f 100644 --- a/harbour-tooter.pro +++ b/harbour-tooter.pro @@ -55,4 +55,5 @@ DISTFILES += \ qml/pages/Browser.qml \ qml/pages/Profile.qml \ qml/pages/components/ProfileHeader.qml \ - qml/images/boosted.svg + qml/images/boosted.svg \ + qml/pages/Conversation.qml diff --git a/harbour-tooter.pro.user b/harbour-tooter.pro.user index 9a41bb8..709aa49 100644 --- a/harbour-tooter.pro.user +++ b/harbour-tooter.pro.user @@ -1,14 +1,14 @@ - + EnvironmentId - {25497605-1bff-4134-a878-76c1475dd8e3} + {41ec03ca-9430-48f3-b421-990d428b2838} ProjectExplorer.Project.ActiveTarget - 0 + 1 ProjectExplorer.Project.EditorSettings @@ -61,12 +61,12 @@ MerSDK-SailfishOS-i486 MerSDK-SailfishOS-i486 - {f49c1b5a-d715-401a-9a10-0e5fe9e5b72a} + {fd18ca89-dfc9-4054-9c53-c67be7689951} 0 2 0 - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug true @@ -138,7 +138,7 @@ true - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Release + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Release true @@ -210,7 +210,7 @@ true - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile true @@ -396,7 +396,7 @@ 13 14 - C:/Users/dysko/SF/harbour-tooter + /Users/dysko/GIT/harbour-tooter false 10234 3 @@ -426,12 +426,12 @@ MerSDK-SailfishOS-armv7hl MerSDK-SailfishOS-armv7hl - {588087e2-ecc1-41aa-b652-86f16cba9351} + {f895389d-b51a-4d4f-8b03-5ec64bda6f66} 0 2 0 - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug true @@ -503,7 +503,7 @@ true - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release true @@ -575,7 +575,7 @@ true - C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile + /Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile true @@ -761,7 +761,7 @@ 13 14 - C:/Users/dysko/SF/harbour-tooter + /Users/dysko/GIT/harbour-tooter false 10234 3 @@ -779,7 +779,7 @@ 3768 false true - false + true false true diff --git a/qml/lib/Worker.js b/qml/lib/Worker.js index d5a3f83..4962095 100644 --- a/qml/lib/Worker.js +++ b/qml/lib/Worker.js @@ -134,7 +134,7 @@ function parseToot (data){ } if(data['account']){ item['account_id'] = data['account']['id']; - item['account_username'] = data['account']['username']; + item['account_username'] = data['account']['acct']; item['account_display_name'] = data['account']['display_name']; item['account_locked'] = data['account']['locked']; item['account_avatar'] = data['account']['avatar']; diff --git a/qml/pages/Conversation.qml b/qml/pages/Conversation.qml new file mode 100644 index 0000000..8466d11 --- /dev/null +++ b/qml/pages/Conversation.qml @@ -0,0 +1,140 @@ +import QtQuick 2.0 +import Sailfish.Silica 1.0 +import "../lib/API.js" as Logic +import "./components/" + +Page { + id: conversationPage + property string type; + property alias title: header.title + property alias description: header.description + property alias avatar: header.image + property int toot_id + + WorkerScript { + id: worker + source: "../lib/Worker.js" + onMessage: { + console.log(JSON.stringify(messageObject)) + } + } + + ProfileHeader { + id: header + } + + DockedPanel { + id: panel + open: true + width: parent.width + height: toot.height + btnAddImages.height + Theme.paddingMedium + (warningContent.visible ? warningContent.height : 0) + dock: Dock.Bottom + TextField { + id: warningContent + visible: false + height: visible ? implicitHeight : 0; + anchors { + top: parent.top + topMargin: Theme.paddingMedium + left: parent.left + right: parent.right + } + autoScrollEnabled: true + labelVisible: false + placeholderText: qsTr("Content warning!") + horizontalAlignment: Text.AlignLeft + EnterKey.onClicked: { + //tweet() + } + } + TextArea { + id: toot + anchors { + top: warningContent.bottom + topMargin: Theme.paddingMedium + left: parent.left + right: parent.right + } + autoScrollEnabled: true + labelVisible: false + focus: true + text: description !== "" && (description.charAt(0) == '@' || description.charAt(0) == '#') ? description+' ' : '' + height: implicitHeight + horizontalAlignment: Text.AlignLeft + EnterKey.onClicked: { + //tweet() + } + } + IconButton { + id: btnAddImages + enabled: false + anchors { + verticalCenter: btnSend.verticalCenter + left: parent.left + leftMargin: Theme.paddingMedium + } + icon.source: "image://theme/icon-s-attach?" + (pressed + ? Theme.highlightColor + : Theme.primaryColor) + onClicked: console.log("Delete!") + } + IconButton { + id: btnContentWarning + anchors { + verticalCenter: btnSend.verticalCenter + left: btnAddImages.right + } + icon.source: "image://theme/icon-s-high-importance?" + (pressed + ? Theme.highlightColor + : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor)) + onClicked: warningContent.visible = !warningContent.visible + } + ComboBox { + id: privacy + anchors { + top: toot.bottom + left: btnContentWarning.right + right: btnSend.left + } + menu: ContextMenu { + MenuItem { text: qsTr("public") } + MenuItem { text: qsTr("unlisted") } + MenuItem { text: qsTr("followers only") } + MenuItem { text: qsTr("direct") } + } + } + IconButton { + id: btnSend + icon.source: "image://theme/icon-m-enter?" + (pressed + ? Theme.highlightColor + : Theme.primaryColor) + anchors { + top: toot.bottom + right: parent.right + rightMargin: Theme.paddingLarge + } + onClicked: { + var visibility = [ "public", "unlisted", "private", "direct"]; + var msg = { + 'action' : 'statuses', + 'method' : 'POST', + 'params' : { + "status": toot.text, + "visibility": visibility[privacy.currentIndex] + }, + 'conf' : Logic.conf + }; + if (toot_id > 0) + msg.params['in_reply_to_id'] = toot_id + + if (warningContent.visible && warningContent.text.length > 0){ + msg.params['sensitive'] = 1 + msg.params['spoiler_text'] = warningContent.text + } + + worker.sendMessage(msg); + console.log(JSON.stringify(msg)); + } + } + } +} diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index a939fa2..537d43d 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -134,6 +134,25 @@ Page { Component.onCompleted: { } } + IconButton { + anchors { + right: (mainPage.isPortrait ? parent.right : infoPanel.left) + bottom: (mainPage.isPortrait ? infoPanel.top : parent.bottom) + margins: { + left: Theme.paddingLarge + bottom: Theme.paddingLarge + } + } + + id: newTweet + width: Theme.iconSizeLarge + height: width + visible: !isPortrait ? true : !infoPanel.open + icon.source: "image://theme/icon-l-add" + onClicked: { + pageStack.push(Qt.resolvedUrl("Conversation.qml"), {title: qsTr("New Toot"), type: "new"}) + } + } function onLinkActivated(href){ if (href[0] === '#' || href[0] === '@' ) { diff --git a/qml/pages/components/Toot.qml b/qml/pages/components/Toot.qml index 7de4745..0afa99f 100644 --- a/qml/pages/components/Toot.qml +++ b/qml/pages/components/Toot.qml @@ -177,5 +177,13 @@ BackgroundItem { font.pixelSize: Theme.fontSizeSmall color: (pressed ? Theme.highlightColor : Theme.primaryColor) } - + onClicked: { + pageStack.push(Qt.resolvedUrl("../Conversation.qml"), { + toot_id: id, + title: account_display_name, + description: '@'+account_username, + avatar: account_avatar, + type: "reply" + }) + } } diff --git a/translations/harbour-tooter-de.ts b/translations/harbour-tooter-de.ts index f600799..445e36c 100644 --- a/translations/harbour-tooter-de.ts +++ b/translations/harbour-tooter-de.ts @@ -27,6 +27,29 @@ + + Conversation + + Content warning! + + + + public + + + + unlisted + + + + followers only + + + + direct + + + MainPage @@ -45,6 +68,10 @@ Search + + New Toot + + MyList diff --git a/translations/harbour-tooter.ts b/translations/harbour-tooter.ts index fd4002b..215a83e 100644 --- a/translations/harbour-tooter.ts +++ b/translations/harbour-tooter.ts @@ -27,6 +27,29 @@ Reading mode + + Conversation + + Content warning! + + + + public + + + + unlisted + + + + followers only + + + + direct + + + MainPage @@ -45,6 +68,10 @@ Search Search + + New Toot + + MyList