diff --git a/harbour-tooterb.desktop b/harbour-tooterb.desktop index 6511311..34fe20f 100644 --- a/harbour-tooterb.desktop +++ b/harbour-tooterb.desktop @@ -4,3 +4,9 @@ X-Nemo-Application-Type=silica-qt5 Icon=harbour-tooterb Exec=harbour-tooterb Name=Tooter β + +#[X-Sailjail] +#OrganizationName=de.poetaster +#ApplicationName=harbour-tooterb +#Permissions=Compatibility;Internet;Camera;Audio;MediaIndexing;RemovableMedia;UserDirs + diff --git a/qml/pages/ConversationPage.qml b/qml/pages/ConversationPage.qml index 36191b8..c7d6192 100644 --- a/qml/pages/ConversationPage.qml +++ b/qml/pages/ConversationPage.qml @@ -1,5 +1,6 @@ -import QtQuick 2.0 +import QtQuick 2.6 import Sailfish.Silica 1.0 +import Sailfish.Pickers 1.0 import harbour.tooterb.Uploader 1.0 import "../lib/API.js" as Logic import "./components/" @@ -38,6 +39,17 @@ Page { else status_link = status_uri } else status_link = status_url + + + // This function is used by the upload Pickers + function fileUpload(file,mime) { + imageUploader.setUploadUrl(Logic.conf.instance + "/api/v1/media") + imageUploader.setFile(file) + imageUploader.setMime(mime) + imageUploader.setAuthorizationHeader(Logic.conf.api_user_token) + imageUploader.upload() + } + allowedOrientations: Orientation.All onSuggestedUserChanged: { //console.log(suggestedUser) @@ -375,7 +387,7 @@ Page { IconButton { id: btnAddImage enabled: mediaModel.count < 4 - icon.source: "image://theme/icon-s-attach?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) ) + icon.source: "image://theme/icon-m-file-image?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) ) anchors { top: toot.bottom topMargin: -Theme.paddingSmall * 1.5 @@ -385,20 +397,79 @@ Page { onClicked: { btnAddImage.enabled = false var once = true - var imagePicker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { "allowedOrientations": Orientation.All }) - imagePicker.selectedContentChanged.connect(function () { - var imagePath = imagePicker.selectedContent - - // console.log(imagePath) - - imageUploader.setUploadUrl(Logic.conf.instance + "/api/v1/media") - imageUploader.setFile(imagePath) - imageUploader.setAuthorizationHeader(Logic.conf.api_user_token) - imageUploader.upload() - }) + pageStack.push(imagePickerPage) } } + IconButton { + id: btnAddMusic + enabled: mediaModel.count < 4 + icon.source: "image://theme/icon-m-file-audio?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) ) + anchors { + top: toot.bottom + topMargin: -Theme.paddingSmall * 1.5 + left: btnAddImage.right + leftMargin: Theme.paddingSmall + } + onClicked: { + btnAddMusic.enabled = false + var once = true + pageStack.push(musicPickerPage) + } + } + IconButton { + id: btnAddVideo + enabled: mediaModel.count < 4 + icon.source: "image://theme/icon-m-file-video?" + ( pressed ? Theme.highlightColor : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor) ) + anchors { + top: toot.bottom + topMargin: -Theme.paddingSmall * 1.5 + left: btnAddMusic.right + leftMargin: Theme.paddingSmall + } + onClicked: { + btnAddVideo.enabled = false + var once = true + pageStack.push(videoPickerPage) + } + } + Component { + id: musicPickerPage + MusicPickerPage { + onSelectedContentPropertiesChanged: { + var imagePath = selectedContentProperties.url + var mimeType = selectedContentProperties.mimeType + fileUpload(imagePath,mimeType) + /* + imageUploader.setUploadUrl(Logic.conf.instance + "/api/v1/media") + imageUploader.setFile(imagePath) + imageUploader.setMime(mimeType) + imageUploader.setAuthorizationHeader(Logic.conf.api_user_token) + imageUploader.upload() + */ + } + } + } + Component { + id: imagePickerPage + ImagePickerPage { + onSelectedContentPropertiesChanged: { + var imagePath = selectedContentProperties.url + var mimeType = selectedContentProperties.mimeType + fileUpload(imagePath,mimeType) + } + } + } + Component { + id: videoPickerPage + VideoPickerPage { + onSelectedContentPropertiesChanged: { + var imagePath = selectedContentProperties.url + var mimeType = selectedContentProperties.mimeType + fileUpload(imagePath,mimeType) + } + } + } ImageUploader { id: imageUploader onProgressChanged: { @@ -413,6 +484,8 @@ Page { onFailure: { uploadProgress.width = 0 btnAddImage.enabled = true + btnAddMusic.enabled = true + btnAddVideo.enabled = true //console.log(status) //console.log(statusText) } @@ -437,7 +510,7 @@ Page { anchors { top: toot.bottom topMargin: -Theme.paddingSmall * 1.5 - left: btnAddImage.right + left: btnAddVideo.right right: btnSend.left } } diff --git a/qml/pages/components/MyList.qml b/qml/pages/components/MyList.qml index 9180729..3c7d486 100644 --- a/qml/pages/components/MyList.qml +++ b/qml/pages/components/MyList.qml @@ -343,11 +343,7 @@ SilicaListView { } } if (mode === "prepend" && model.count) { - if ( linknext === "" ) { - p.push({name:'since_id', data: model.get(0).id}) - } else { - p.push({name: 'min_id', data: linknext}) - } + p.push({name:'since_id', data: model.get(0).id}) } // to keep the number of params the same for all requests diff --git a/rpm/harbour-tooterb.spec b/rpm/harbour-tooterb.spec index 4e33f97..1d52eda 100644 --- a/rpm/harbour-tooterb.spec +++ b/rpm/harbour-tooterb.spec @@ -13,7 +13,7 @@ Name: harbour-tooterb %{!?qtc_make:%define qtc_make make} %{?qtc_builddir:%define _builddir %qtc_builddir} Summary: Tooter β -Version: 1.1.5 +Version: 1.1.6 Release: 1 Group: Qt/Qt License: GPLv3 diff --git a/src/imageuploader.cpp b/src/imageuploader.cpp index 4e66a65..422c3ae 100644 --- a/src/imageuploader.cpp +++ b/src/imageuploader.cpp @@ -25,6 +25,9 @@ ImageUploader::~ImageUploader() { void ImageUploader::setFile(const QString &fileName) { m_fileName = fileName; } +void ImageUploader::setMime(const QString &mimeType) { + m_mimeType = mimeType; +} void ImageUploader::setParameters(const QString &album, const QString &title, const QString &description) { //if (!album.isEmpty()) { @@ -92,7 +95,8 @@ void ImageUploader::upload() { }*/ //QByteArray fileData = file.readAll().toBase64(); - imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); + //imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); + imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(m_mimeType)); imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QString("form-data; name=\"file\"; filename=\"%1\"").arg(fileInfo.fileName()).toLatin1())); imagePart.setBodyDevice(file); file->setParent(multiPart); diff --git a/src/imageuploader.h b/src/imageuploader.h index 86eda07..e787e20 100644 --- a/src/imageuploader.h +++ b/src/imageuploader.h @@ -16,6 +16,7 @@ public: ~ImageUploader(); Q_INVOKABLE void setFile(const QString &fileName); + Q_INVOKABLE void setMime(const QString &mimeType); Q_INVOKABLE void setAuthorizationHeader(const QString &authorizationHeader); Q_INVOKABLE void setUploadUrl(const QString &userAgent); Q_INVOKABLE void setParameters(const QString &album, const QString &title, const QString &description); @@ -37,6 +38,7 @@ private: QNetworkAccessManager *m_networkAccessManager; QString m_fileName; + QString m_mimeType; QByteArray m_authorizationHeader; QString m_uploadUrl; QByteArray postdata;