From e9c1c3814185c11a4e2e73db3df90284874624da Mon Sep 17 00:00:00 2001 From: molan-git Date: Thu, 11 Jun 2020 14:11:39 +0200 Subject: [PATCH 1/2] fix contextMnu --- qml/harbour-tooter.qml | 31 ++++----- qml/pages/ConversationPage.qml | 42 ++++++------ qml/pages/LoginPage.qml | 82 ++++++++++++------------ qml/pages/components/InfoBanner.qml | 4 +- qml/pages/components/MediaFullScreen.qml | 2 +- qml/pages/components/ProfileHeader.qml | 2 +- qml/pages/components/ProfileImage.qml | 2 +- qml/pages/components/VisualContainer.qml | 18 +++--- 8 files changed, 92 insertions(+), 91 deletions(-) diff --git a/qml/harbour-tooter.qml b/qml/harbour-tooter.qml index b0f9abd..b50b096 100644 --- a/qml/harbour-tooter.qml +++ b/qml/harbour-tooter.qml @@ -35,8 +35,8 @@ import "./lib/API.js" as Logic ApplicationWindow { id: appWindow - cover: Qt.resolvedUrl("cover/CoverPage.qml") allowedOrientations: defaultAllowedOrientations + cover: Qt.resolvedUrl("cover/CoverPage.qml") Component.onCompleted: { var obj = {} Logic.mediator.installTo(obj) @@ -44,26 +44,26 @@ ApplicationWindow { console.log('confLoaded'); //console.log(JSON.stringify(Logic.conf)) if (!Logic.conf['notificationLastID']) - Logic.conf['notificationLastID'] = 0 + Logic.conf['notificationLastID'] = 0 if (Logic.conf['instance']) { - Logic.api = Logic.mastodonAPI({ - "instance": Logic.conf['instance'], - "api_user_token": "" - }) + Logic.api = Logic.mastodonAPI({ + "instance": Logic.conf['instance'], + "api_user_token": "" + }) } if (Logic.conf['login']) { - //Logic.conf['notificationLastID'] = 0 - Logic.api.setConfig("api_user_token", Logic.conf['api_user_token']) - //accounts/verify_credentials - Logic.api.get('instance', [], function(data) { - console.log(JSON.stringify(data)) - pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {}) - }) - //pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {}) + //Logic.conf['notificationLastID'] = 0 + Logic.api.setConfig("api_user_token", Logic.conf['api_user_token']) + //accounts/verify_credentials + Logic.api.get('instance', [], function(data) { + console.log(JSON.stringify(data)) + pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {}) + }) + //pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {}) } else { - pageStack.push(Qt.resolvedUrl("./pages/LoginPage.qml"), {}) + pageStack.push(Qt.resolvedUrl("./pages/LoginPage.qml"), {}) } }) Logic.init() @@ -73,6 +73,7 @@ ApplicationWindow { //Logic.conf.notificationLastID = 0; Logic.saveData() } + Connections { target: Dbus onViewtoot: { diff --git a/qml/pages/ConversationPage.qml b/qml/pages/ConversationPage.qml index a85b305..9ce3a3c 100644 --- a/qml/pages/ConversationPage.qml +++ b/qml/pages/ConversationPage.qml @@ -47,6 +47,27 @@ Page { } } + PullDownMenu { + id: pulleyConversation + visible: type === "reply" + MenuItem { + text: qsTr("Copy Link to Clipboard") + onClicked: if (toot_url === "") { + + var test = toot_uri.split("/") + console.log(toot_uri) + console.log(JSON.stringify(test)) + console.log(JSON.stringify(test.length)) + if (test.length === 8 && (test[7] === "activity")) { + var urialt = toot_uri.replace("activity", "") + Clipboard.text = urialt + } + else Clipboard.text = toot_uri + + } else onClicked: Clipboard.text = toot_url + } + } + ListModel { id: mediaModel onCountChanged: { @@ -100,27 +121,6 @@ Page { } } } - - PullDownMenu { - id: pulleyConversation - visible: type === "reply" - MenuItem { - text: qsTr("Copy Link to Clipboard") - onClicked: if (toot_url === "") { - - var test = toot_uri.split("/") - console.log(toot_uri) - console.log(JSON.stringify(test)) - console.log(JSON.stringify(test.length)) - if (test.length === 8 && (test[7] === "activity")) { - var urialt = toot_uri.replace("activity", "") - Clipboard.text = urialt - } - else Clipboard.text = toot_uri - - } else onClicked: Clipboard.text = toot_url - } - } } Rectangle { diff --git a/qml/pages/LoginPage.qml b/qml/pages/LoginPage.qml index b35ad7a..3a2cb10 100644 --- a/qml/pages/LoginPage.qml +++ b/qml/pages/LoginPage.qml @@ -39,37 +39,37 @@ Page { EnterKey.onClicked: { Logic.api = Logic.mastodonAPI({ instance: instance.text, api_user_token: "" }); Logic.api.registerApplication("Tooter", - 'http://localhost/harbour-tooter', // redirect uri, we will need this later on - ["read", "write", "follow"], //scopes - "http://grave-design.com/harbour-tooter", //website on the login screen - function(data) { + 'http://localhost/harbour-tooter', // redirect uri, we will need this later on + ["read", "write", "follow"], //scopes + "http://grave-design.com/harbour-tooter", //website on the login screen + function(data) { - console.log(data) - var conf = JSON.parse(data) - conf.instance = instance.text; - conf.login = false; + console.log(data) + var conf = JSON.parse(data) + conf.instance = instance.text; + conf.login = false; - /*conf['login'] = false; + /*conf['login'] = false; conf['mastodon_client_id'] = data['mastodon_client_id']; conf['mastodon_client_secret'] = data['mastodon_client_secret']; conf['mastodon_client_redirect_uri'] = data['mastodon_client_redirect_uri']; delete Logic.conf;*/ - Logic.conf = conf; - console.log(JSON.stringify(conf)) - console.log(JSON.stringify(Logic.conf)) - // we got our application + Logic.conf = conf; + console.log(JSON.stringify(conf)) + console.log(JSON.stringify(Logic.conf)) + // we got our application - // our user to it! - var url = Logic.api.generateAuthLink(Logic.conf["client_id"], - Logic.conf["redirect_uri"], - "code", // oauth method - ["read", "write", "follow"] //scopes - ); - console.log(url) - webView.url = url - webView.visible = true - } - ); + // our user to it! + var url = Logic.api.generateAuthLink(Logic.conf["client_id"], + Logic.conf["redirect_uri"], + "code", // oauth method + ["read", "write", "follow"] //scopes + ); + console.log(url) + webView.url = url + webView.visible = true + } + ); } } Label { @@ -109,7 +109,7 @@ Page { if ( (url+"").substr(0, 37) === 'http://localhost/harbour-tooter?code=' || (url+"").substr(0, 38) === 'https://localhost/harbour-tooter?code=' - ) { + ) { visible = false; var vars = {}; @@ -120,22 +120,22 @@ Page { console.log(authCode) Logic.api.getAccessTokenFromAuthCode( - Logic.conf["client_id"], - Logic.conf["client_secret"], - Logic.conf["redirect_uri"], - authCode, - function(data) { - // AAAND DATA CONTAINS OUR TOKEN! - console.log(data) - data = JSON.parse(data) - console.log(JSON.stringify(data)) - console.log(JSON.stringify(data.access_token)) - Logic.conf["api_user_token"] = data.access_token - Logic.conf["login"] = true; - Logic.api.setConfig("api_user_token", Logic.conf["api_user_token"]) - pageStack.replace(Qt.resolvedUrl("MainPage.qml"), {}) - } - ) + Logic.conf["client_id"], + Logic.conf["client_secret"], + Logic.conf["redirect_uri"], + authCode, + function(data) { + // AAAND DATA CONTAINS OUR TOKEN! + console.log(data) + data = JSON.parse(data) + console.log(JSON.stringify(data)) + console.log(JSON.stringify(data.access_token)) + Logic.conf["api_user_token"] = data.access_token + Logic.conf["login"] = true; + Logic.api.setConfig("api_user_token", Logic.conf["api_user_token"]) + pageStack.replace(Qt.resolvedUrl("MainPage.qml"), {}) + } + ) } diff --git a/qml/pages/components/InfoBanner.qml b/qml/pages/components/InfoBanner.qml index 8d33b9a..06601aa 100644 --- a/qml/pages/components/InfoBanner.qml +++ b/qml/pages/components/InfoBanner.qml @@ -3,7 +3,7 @@ import Sailfish.Silica 1.0 DockedPanel { - id: root + id: root dock: Dock.Top width: parent.width height: content.height @@ -28,7 +28,7 @@ DockedPanel { right: parent.right rightMargin: Theme.horizontalPageMargin verticalCenter: parent.verticalCenter - } + } } MouseArea { diff --git a/qml/pages/components/MediaFullScreen.qml b/qml/pages/components/MediaFullScreen.qml index 324fa76..38ec83a 100644 --- a/qml/pages/components/MediaFullScreen.qml +++ b/qml/pages/components/MediaFullScreen.qml @@ -27,7 +27,7 @@ FullscreenContentPage { } Flickable { - id: videoFlickable + id: videoFlickable visible: false clip: true contentWidth: imageContainer.width diff --git a/qml/pages/components/ProfileHeader.qml b/qml/pages/components/ProfileHeader.qml index 20c93d9..de9c0af 100644 --- a/qml/pages/components/ProfileHeader.qml +++ b/qml/pages/components/ProfileHeader.qml @@ -122,7 +122,7 @@ Item { rightMargin: Theme.paddingLarge } - /* Rectangle { + /* Rectangle { id: followingBg visible: (following ? true : false) radius: Theme.paddingSmall diff --git a/qml/pages/components/ProfileImage.qml b/qml/pages/components/ProfileImage.qml index 1e000b0..5c49285 100644 --- a/qml/pages/components/ProfileImage.qml +++ b/qml/pages/components/ProfileImage.qml @@ -4,7 +4,7 @@ import Sailfish.Silica 1.0 FullscreenContentPage { id: profileImage - property string image: "" + property string image: "" allowedOrientations: Orientation.All diff --git a/qml/pages/components/VisualContainer.qml b/qml/pages/components/VisualContainer.qml index 2bb06a0..7635dc9 100644 --- a/qml/pages/components/VisualContainer.qml +++ b/qml/pages/components/VisualContainer.qml @@ -23,8 +23,8 @@ BackgroundItem { height: parent.height opacity: 0.3 gradient: Gradient { - GradientStop { position: -1.5; color: "transparent" } - GradientStop { position: 0.6; color: Theme.highlightBackgroundColor } + GradientStop { position: -1.5; color: "transparent" } + GradientStop { position: 0.6; color: Theme.highlightBackgroundColor } } } @@ -37,8 +37,8 @@ BackgroundItem { height: parent.height opacity: 0.5 gradient: Gradient { - GradientStop { position: -0.5; color: "transparent" } - GradientStop { position: 0.4; color: Theme.highlightDimmerColor } + GradientStop { position: -0.5; color: "transparent" } + GradientStop { position: 0.4; color: Theme.highlightDimmerColor } } } @@ -71,8 +71,8 @@ BackgroundItem { onStatusChanged: { if (avatar.status === Image.Error) source = "../../images/icon-m-profile.svg?" + (pressed - ? Theme.highlightColor - : Theme.primaryColor) + ? Theme.highlightColor + : Theme.primaryColor) } MouseArea { @@ -165,8 +165,8 @@ BackgroundItem { textFormat: Text.RichText font.pixelSize: Theme.fontSizeSmall linkColor: if (myList.type === "notifications" && ( model.type === "favourite" || model.type === "reblog" )) { - Theme.secondaryHighlightColor - } else Theme.highlightColor + Theme.secondaryHighlightColor + } else Theme.highlightColor wrapMode: Text.Wrap color: if (myList.type === "notifications" && ( model.type === "favourite" || model.type === "reblog" )) { (pressed ? Theme.secondaryHighlightColor : (!highlight ? Theme.secondaryColor : Theme.secondaryHighlightColor)) @@ -304,7 +304,7 @@ BackgroundItem { MenuItem { id: mnuFavourite - visible: model.type !== "follow" || model.status_visibility !== "direct" + visible: model.type !== "follow" text: typeof model.favourited !== "undefined" && model.favourited ? qsTr("Unfavorite") : qsTr("Favorite") onClicked: { var status = typeof model.favourited !== "undefined" && model.favourited From 9febf8409237478ce3382b0af3bb3bd3e150fc1c Mon Sep 17 00:00:00 2001 From: molan-git Date: Thu, 11 Jun 2020 14:22:09 +0200 Subject: [PATCH 2/2] pulleyMnu fix --- qml/pages/ConversationPage.qml | 42 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/qml/pages/ConversationPage.qml b/qml/pages/ConversationPage.qml index 9ce3a3c..a85b305 100644 --- a/qml/pages/ConversationPage.qml +++ b/qml/pages/ConversationPage.qml @@ -47,27 +47,6 @@ Page { } } - PullDownMenu { - id: pulleyConversation - visible: type === "reply" - MenuItem { - text: qsTr("Copy Link to Clipboard") - onClicked: if (toot_url === "") { - - var test = toot_uri.split("/") - console.log(toot_uri) - console.log(JSON.stringify(test)) - console.log(JSON.stringify(test.length)) - if (test.length === 8 && (test[7] === "activity")) { - var urialt = toot_uri.replace("activity", "") - Clipboard.text = urialt - } - else Clipboard.text = toot_uri - - } else onClicked: Clipboard.text = toot_url - } - } - ListModel { id: mediaModel onCountChanged: { @@ -121,6 +100,27 @@ Page { } } } + + PullDownMenu { + id: pulleyConversation + visible: type === "reply" + MenuItem { + text: qsTr("Copy Link to Clipboard") + onClicked: if (toot_url === "") { + + var test = toot_uri.split("/") + console.log(toot_uri) + console.log(JSON.stringify(test)) + console.log(JSON.stringify(test.length)) + if (test.length === 8 && (test[7] === "activity")) { + var urialt = toot_uri.replace("activity", "") + Clipboard.text = urialt + } + else Clipboard.text = toot_uri + + } else onClicked: Clipboard.text = toot_url + } + } } Rectangle {