From e46e53da16aa8762ed51273411d7ff54a6384e20 Mon Sep 17 00:00:00 2001 From: Mark Washeim Date: Wed, 30 Nov 2022 16:50:50 +0100 Subject: [PATCH] Add additiona; media element for audio. --- harbour-tooterb.pro | 1 + harbour-tooterb.pro.user | 4 +-- qml/harbour-tooterb.qml | 2 ++ qml/pages/ConversationPage.qml | 41 ++++++++++++--------- qml/pages/MainPage.qml | 2 +- qml/pages/components/MediaBlock.qml | 11 +++++- qml/pages/components/MediaFullScreen.qml | 8 +++++ qml/pages/components/MyList.qml | 9 ++--- qml/pages/components/MyMedia.qml | 46 +++++++++++++++++++++--- qml/pages/components/VisualContainer.qml | 14 +++++--- rpm/harbour-tooterb.spec | 7 ++-- translations/harbour-tooterb-de.ts | 15 ++++++++ translations/harbour-tooterb-el.ts | 15 ++++++++ translations/harbour-tooterb-es.ts | 15 ++++++++ translations/harbour-tooterb-fr.ts | 15 ++++++++ translations/harbour-tooterb-it.ts | 15 ++++++++ translations/harbour-tooterb-nl.ts | 15 ++++++++ translations/harbour-tooterb-nl_BE.ts | 15 ++++++++ translations/harbour-tooterb-oc.ts | 15 ++++++++ translations/harbour-tooterb-pl.ts | 15 ++++++++ translations/harbour-tooterb-ru.ts | 15 ++++++++ translations/harbour-tooterb-sr.ts | 15 ++++++++ translations/harbour-tooterb-sv.ts | 15 ++++++++ translations/harbour-tooterb-zh_CN.ts | 15 ++++++++ translations/harbour-tooterb.ts | 15 ++++++++ 25 files changed, 319 insertions(+), 36 deletions(-) diff --git a/harbour-tooterb.pro b/harbour-tooterb.pro index dc6000a..8b6193e 100644 --- a/harbour-tooterb.pro +++ b/harbour-tooterb.pro @@ -68,6 +68,7 @@ DISTFILES += qml/harbour-tooterb.qml \ qml/pages/components/MyList.qml \ qml/pages/components/ProfileHeader.qml \ qml/pages/components/MediaBlock.qml \ + qml/pages/components/MediaItem.qml \ qml/cover/CoverPage.qml \ qml/pages/MainPage.qml \ qml/pages/LoginPage.qml \ diff --git a/harbour-tooterb.pro.user b/harbour-tooterb.pro.user index 160f0bd..4e5e8fc 100644 --- a/harbour-tooterb.pro.user +++ b/harbour-tooterb.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -112,7 +112,7 @@ true QtProjectManager.QMakeBuildStep - false + true diff --git a/qml/harbour-tooterb.qml b/qml/harbour-tooterb.qml index 60e8399..90838fa 100644 --- a/qml/harbour-tooterb.qml +++ b/qml/harbour-tooterb.qml @@ -67,6 +67,8 @@ ApplicationWindow { } }) Logic.init() + + } Component.onDestruction: { diff --git a/qml/pages/ConversationPage.qml b/qml/pages/ConversationPage.qml index f641278..36191b8 100644 --- a/qml/pages/ConversationPage.qml +++ b/qml/pages/ConversationPage.qml @@ -8,6 +8,7 @@ import "./components/" Page { id: conversationPage + property bool debug: false property ListModel suggestedModel property ListModel mdl property int tootMaxChar: 500 @@ -25,9 +26,11 @@ Page { property string status_link: if (status_url === "") { var test = status_uri.split("/") - console.log(status_uri) - console.log(JSON.stringify(test)) - console.log(JSON.stringify(test.length)) + if (debug) { + console.log(status_uri) + console.log(JSON.stringify(test)) + console.log(JSON.stringify(test.length)) + } if (test.length === 8 && (test[7] === "activity")) { var urialt = status_uri.replace("activity", "") status_link = urialt @@ -37,7 +40,7 @@ Page { allowedOrientations: Orientation.All onSuggestedUserChanged: { - console.log(suggestedUser) + //console.log(suggestedUser) suggestedModel = Qt.createQmlObject( 'import QtQuick 2.0; ListModel { }', Qt.application, 'InternalQmlObject' ) predictionList.visible = false if (suggestedUser.length > 0) { @@ -67,7 +70,9 @@ Page { WorkerScript { id: worker source: "../lib/Worker.js" - onMessage: { console.log(JSON.stringify(messageObject)) } + onMessage: { + //console.log(JSON.stringify(messageObject)) + } } SilicaListView { @@ -98,7 +103,7 @@ Page { if (mdl) for (var i = 0; i < mdl.count; i++) { if (mdl.get(i).status_id === status_id) { - console.log(mdl.get(i).status_id) + //console.log(mdl.get(i).status_id) positionViewAtIndex(i, ListView.Center) } } @@ -266,7 +271,7 @@ Page { textOperations.select( textOperations.selectionStart ? textOperations.selectionStart - 1 : 0, textOperations.selectionEnd) - console.log(toot.text.length) + //console.log(toot.text.length) suggestedUser = "" if (textOperations.selectedText.charAt(0) === "@") { suggestedUser = textOperations.selectedText.trim().substring(1) @@ -292,7 +297,9 @@ Page { right: parent.right rightMargin: Theme.paddingSmall } - onSelectionChanged: { console.log(selection) } + onSelectionChanged: { + //console.log(selection) + } onClicked: pageStack.push(emojiDialog) } @@ -321,7 +328,7 @@ Page { } onClicked: { var idx = index - console.log(idx) + //console.log(idx) //mediaModel.remove(idx) remorse.execute(myDelegate, "", function () { mediaModel.remove(idx) @@ -381,7 +388,9 @@ Page { var imagePicker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { "allowedOrientations": Orientation.All }) imagePicker.selectedContentChanged.connect(function () { var imagePath = imagePicker.selectedContent - console.log(imagePath) + + // console.log(imagePath) + imageUploader.setUploadUrl(Logic.conf.instance + "/api/v1/media") imageUploader.setFile(imagePath) imageUploader.setAuthorizationHeader(Logic.conf.api_user_token) @@ -393,19 +402,19 @@ Page { ImageUploader { id: imageUploader onProgressChanged: { - console.log("progress " + progress) + // console.log("progress " + progress) uploadProgress.width = parent.width * progress } onSuccess: { uploadProgress.width = 0 - console.log(replyData) + //console.log(replyData) mediaModel.append(JSON.parse(replyData)) } onFailure: { uploadProgress.width = 0 btnAddImage.enabled = true - console.log(status) - console.log(statusText) + //console.log(status) + //console.log(statusText) } } @@ -447,7 +456,7 @@ Page { var visibility = ["public", "unlisted", "private", "direct"] var media_ids = [] for (var k = 0; k < mediaModel.count; k++) { - console.log(mediaModel.get(k).id) + // console.log(mediaModel.get(k).id) media_ids.push(mediaModel.get(k).id) } var msg = { @@ -511,7 +520,7 @@ Page { privacy.currentIndex = setIndex } - console.log(JSON.stringify()) + // console.log(JSON.stringify()) worker.sendMessage({ "action": 'statuses/' + mdl.get(0).status_id + '/context', diff --git a/qml/pages/MainPage.qml b/qml/pages/MainPage.qml index 5f62890..381f767 100644 --- a/qml/pages/MainPage.qml +++ b/qml/pages/MainPage.qml @@ -290,7 +290,7 @@ Page { tlSearch.search = "#"+decodeURIComponent(test[4]) slideshow.positionViewAtIndex(5, ListView.SnapToItem) navigation.navigateTo('search') - console.log("search tag") + if (debug) console.log("search tag") } else if (test.length === 4 && test[3][0] === "@" ) { tlSearch.search = decodeURIComponent("@"+test[3].substring(1)+"@"+test[2]) diff --git a/qml/pages/components/MediaBlock.qml b/qml/pages/components/MediaBlock.qml index e3bb587..aacc34e 100644 --- a/qml/pages/components/MediaBlock.qml +++ b/qml/pages/components/MediaBlock.qml @@ -10,14 +10,17 @@ Item { property double wRatio : 16/9 property double hRatio : 9/16 + property bool debug: true width: width height: height Component.onCompleted: { + console.log("MB: " + JSON.stringify(model.get(0))) if (model && model.count && model.get(0).type === "video") { + //console.log("Mediablock") + //console.log(JSON.stringify(model.get(0).type)) while (model.count>1) { model.remove(model.count-1) } - //console.log(JSON.stringify(model.get(0))) } var count = 0 if (model && model.count) @@ -89,6 +92,8 @@ Item { type = model.get(0).type previewURL = model.get(0).preview_url mediaURL = model.get(0).url + url = model.get(0).url + if(debug) console.log( model.get(0).url ) height = Theme.itemSizeLarge return true } else { @@ -108,6 +113,8 @@ Item { type = model.get(1).type previewURL = model.get(1).preview_url mediaURL = model.get(1).url + url = model.get(0).url + if(debug) console.log( model.get(1).url ) height = Theme.itemSizeLarge return true } else { @@ -127,6 +134,7 @@ Item { type = model.get(2).type previewURL = model.get(2).preview_url mediaURL = model.get(2).url + url = model.get(0).url height = Theme.itemSizeLarge return true } else { @@ -146,6 +154,7 @@ Item { type = model.get(3).type previewURL = model.get(3).preview_url mediaURL = model.get(3).url + url = model.get(0).url height = Theme.itemSizeLarge return true } else { diff --git a/qml/pages/components/MediaFullScreen.qml b/qml/pages/components/MediaFullScreen.qml index f4adf7d..027c45d 100644 --- a/qml/pages/components/MediaFullScreen.qml +++ b/qml/pages/components/MediaFullScreen.qml @@ -9,6 +9,7 @@ FullscreenContentPage { property string type: "" property string previewURL: "" property string mediaURL: "" + property string url: "" allowedOrientations: Orientation.All Component.onCompleted: function() { @@ -18,6 +19,13 @@ FullscreenContentPage { if (type != 'gifv' && type != 'video') { imagePreview.source = mediaURL imageFlickable.visible = true + } else if( type == 'audio'){ + video.source = url + videoFlickable.visible = true + playerIcon.visible = true + playerProgress.visible = true + video.play() + hideTimer.start() } else { video.source = mediaURL video.fillMode = VideoOutput.PreserveAspectFit diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index 23ddd73..5b6fe3d 100644 --- a/qml/pages/components/MyList.qml +++ b/qml/pages/components/MyList.qml @@ -7,6 +7,7 @@ import "." SilicaListView { id: myList + property bool debug:false property string type property string title property string description @@ -25,7 +26,7 @@ SilicaListView { signal notify (string what, int num) onNotify: { - console.log(what + " - " + num) + if(debug) console.log(what + " - " + num) } signal openDrawer (bool setDrawer) onOpenDrawer: { @@ -33,7 +34,7 @@ SilicaListView { } signal send (string notice) onSend: { - console.log("LIST send signal emitted with notice: " + notice) + if (debug) console.log("LIST send signal emitted with notice: " + notice) } header: PageHeader { @@ -178,7 +179,7 @@ SilicaListView { Timer { triggeredOnStart: false; interval: 5*60*1000; running: true; repeat: true onTriggered: { - console.log(title + ' ' +Date().toString()) + if(debug) console.log(title + ' ' +Date().toString()) loadData("prepend") } } @@ -204,7 +205,7 @@ SilicaListView { 'conf' : Logic.conf } - console.log(JSON.stringify(msg)) + if (debug) console.log(JSON.stringify(msg)) if (type !== "") worker.sendMessage(msg) } diff --git a/qml/pages/components/MyMedia.qml b/qml/pages/components/MyMedia.qml index 4e5c980..aa459d7 100644 --- a/qml/pages/components/MyMedia.qml +++ b/qml/pages/components/MyMedia.qml @@ -9,6 +9,7 @@ Item { property string type : "" property string previewURL: "" property string mediaURL: "" + property string url: "" Rectangle { opacity: 0.4 @@ -31,13 +32,36 @@ Item { source: "image://theme/icon-m-file-video?" anchors.centerIn: parent } - - Image { + Text { + anchors{ + topMargin: 10 + } + id: audioUrl visible: type == 'audio' - //opacity: img.status === Image.Ready ? 0.0 : 1.0 + text: "" + 'Audio file' + '' + font.pixelSize: Theme.fontSizeLarge + } + + + //Image { + MediaItem { + id: audioContent + visible: type == 'audio' + opacity: img.status === Image.Ready ? 0.0 : 1.0 Behavior on opacity { FadeAnimator {} } - source: "image://theme/icon-m-file-audio?" + mimeType: 'audio/mp3' + url: url + //source: "image://theme/icon-m-file-audio?" anchors.centerIn: parent + /*MouseArea { + anchors.fill: parent + onClicked: { + pageStack.push(Qt.resolvedUrl("./MediaFullScreen.qml"), { + "url": url, + "type": type + }) + } + }*/ } Rectangle { @@ -109,5 +133,19 @@ Item { onClicked: parent.visible = false } } + IconButton { + id: mediaDlBtn + icon.source: "image://theme/icon-m-cloud-download" + anchors { + right: parent.right + rightMargin: Theme.horizontalPageMargin + bottom: parent.bottom + bottomMargin: Theme.horizontalPageMargin + } + onClicked: { + var filename = url.split("/") + FileDownloader.downloadFile(url, filename[filename.length-1]) + } + } } } diff --git a/qml/pages/components/VisualContainer.qml b/qml/pages/components/VisualContainer.qml index af62906..a5b6db3 100644 --- a/qml/pages/components/VisualContainer.qml +++ b/qml/pages/components/VisualContainer.qml @@ -6,6 +6,8 @@ import "../../lib/API.js" as Logic BackgroundItem { id: delegate + property bool debug:false + signal send (string notice) signal navigateTo(string link) @@ -195,9 +197,11 @@ BackgroundItem { } onLinkActivated: { var test = link.split("/") - console.log(link) - console.log(JSON.stringify(test)) - console.log(JSON.stringify(test.length)) + if (debug) { + console.log(link) + console.log(JSON.stringify(test)) + console.log(JSON.stringify(test.length)) + } if (test.length === 5 && (test[3] === "tags" || test[3] === "tag") ) { pageStack.pop(pageStack.find(function(page) { var check = page.isFirstPage === true; @@ -447,11 +451,11 @@ BackgroundItem { } onPressAndHold: { - console.log(JSON.stringify(mdl.get(index))) + if (debug) console.log(JSON.stringify(mdl.get(index))) mnu.open(delegate) } onDoubleClicked: { - console.log("double click") + if (debug) console.log("double click") } } diff --git a/rpm/harbour-tooterb.spec b/rpm/harbour-tooterb.spec index e05bc9f..ff1b5c7 100644 --- a/rpm/harbour-tooterb.spec +++ b/rpm/harbour-tooterb.spec @@ -14,7 +14,7 @@ Name: harbour-tooterb %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Tooter β Version: 1.0.9 -Release: 1 +Release: 2 Group: Qt/Qt License: GPLv3 URL: https://github.com/poetaster/harbour-tooter#readme @@ -43,10 +43,11 @@ Categories: - Network PackagerName: Mark Washeim (poetaster) Custom: - - Repo: https://github.com/poetaster/harbour-tooter + - Repo: https://github.com/molan-git/harbour-tooter + - PackagingRepo: https://github.com/poetaster/harbour-tooter Icon: https://raw.githubusercontent.com/poetaster/harbour-tooter/master/icons/256x256/harbour-tooterb.png Url: - Homepage: https://github.com/poetaster/harbour-tooter + - Bugtracker: https://github.com/poetaster/harbour-tooter/issues %endif %prep diff --git a/translations/harbour-tooterb-de.ts b/translations/harbour-tooterb-de.ts index 5010304..a98e776 100644 --- a/translations/harbour-tooterb-de.ts +++ b/translations/harbour-tooterb-de.ts @@ -161,6 +161,21 @@ Ladefehler + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-el.ts b/translations/harbour-tooterb-el.ts index 96d86eb..de29ec0 100644 --- a/translations/harbour-tooterb-el.ts +++ b/translations/harbour-tooterb-el.ts @@ -161,6 +161,21 @@ + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-es.ts b/translations/harbour-tooterb-es.ts index 1ceff33..df2b7a8 100644 --- a/translations/harbour-tooterb-es.ts +++ b/translations/harbour-tooterb-es.ts @@ -161,6 +161,21 @@ Error al cargar + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-fr.ts b/translations/harbour-tooterb-fr.ts index b4bc409..c4487cf 100644 --- a/translations/harbour-tooterb-fr.ts +++ b/translations/harbour-tooterb-fr.ts @@ -161,6 +161,21 @@ Erreur au chargement + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-it.ts b/translations/harbour-tooterb-it.ts index c605f81..1f76a2c 100644 --- a/translations/harbour-tooterb-it.ts +++ b/translations/harbour-tooterb-it.ts @@ -161,6 +161,21 @@ Errore durante caricamento + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-nl.ts b/translations/harbour-tooterb-nl.ts index a434985..10ce180 100644 --- a/translations/harbour-tooterb-nl.ts +++ b/translations/harbour-tooterb-nl.ts @@ -161,6 +161,21 @@ Laadfout + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-nl_BE.ts b/translations/harbour-tooterb-nl_BE.ts index 117be0f..febdf3f 100644 --- a/translations/harbour-tooterb-nl_BE.ts +++ b/translations/harbour-tooterb-nl_BE.ts @@ -161,6 +161,21 @@ + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-oc.ts b/translations/harbour-tooterb-oc.ts index 12881ac..37895d9 100644 --- a/translations/harbour-tooterb-oc.ts +++ b/translations/harbour-tooterb-oc.ts @@ -161,6 +161,21 @@ + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-pl.ts b/translations/harbour-tooterb-pl.ts index b5a30e3..7206219 100644 --- a/translations/harbour-tooterb-pl.ts +++ b/translations/harbour-tooterb-pl.ts @@ -161,6 +161,21 @@ + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-ru.ts b/translations/harbour-tooterb-ru.ts index 3bc83f8..7733981 100644 --- a/translations/harbour-tooterb-ru.ts +++ b/translations/harbour-tooterb-ru.ts @@ -161,6 +161,21 @@ Ошибка при загрузке + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-sr.ts b/translations/harbour-tooterb-sr.ts index 164a2f4..143797c 100644 --- a/translations/harbour-tooterb-sr.ts +++ b/translations/harbour-tooterb-sr.ts @@ -161,6 +161,21 @@ + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-sv.ts b/translations/harbour-tooterb-sv.ts index 24c6693..57672e9 100644 --- a/translations/harbour-tooterb-sv.ts +++ b/translations/harbour-tooterb-sv.ts @@ -161,6 +161,21 @@ Fel vid inläsning + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb-zh_CN.ts b/translations/harbour-tooterb-zh_CN.ts index d5a9094..5e9f72b 100644 --- a/translations/harbour-tooterb-zh_CN.ts +++ b/translations/harbour-tooterb-zh_CN.ts @@ -161,6 +161,21 @@ 加载错误 + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus diff --git a/translations/harbour-tooterb.ts b/translations/harbour-tooterb.ts index fa78494..92daad6 100644 --- a/translations/harbour-tooterb.ts +++ b/translations/harbour-tooterb.ts @@ -161,6 +161,21 @@ Error loading + + MediaItem + + Image + + + + Video + + + + PDF document + + + MiniStatus