Image upload and translations

- Image Upload added [#9]
- Fixed some translation strings
This commit is contained in:
Dusko Angirevic 2017-07-06 11:22:12 +02:00
parent a19d7503b0
commit 20f7ce524a
15 changed files with 266 additions and 175 deletions

View file

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.0.1, 2017-07-06T00:58:07. --> <!-- Written by QtCreator 4.0.1, 2017-07-06T09:02:09. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
<value type="QByteArray">{41ec03ca-9430-48f3-b421-990d428b2838}</value> <value type="QByteArray">{25497605-1bff-4134-a878-76c1475dd8e3}</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">1</value> <value type="int">0</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.EditorSettings</variable> <variable>ProjectExplorer.Project.EditorSettings</variable>
@ -61,12 +61,12 @@
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-i486</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-i486</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-i486</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-i486</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{fd18ca89-dfc9-4054-9c53-c67be7689951}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f49c1b5a-d715-401a-9a10-0e5fe9e5b72a}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -138,7 +138,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -210,7 +210,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_i486-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -396,21 +396,19 @@
<value type="int">13</value> <value type="int">13</value>
<value type="int">14</value> <value type="int">14</value>
</valuelist> </valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value> <value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value> <value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value> <value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value> <value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>
<value type="QString" key="MerRunConfiguration.QmlLiveTargetWorkspace"></value> <value type="QString" key="MerRunConfiguration.QmlLiveTargetWorkspace"></value>
<value type="int" key="PE.EnvironmentAspect.Base">1</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">harbour-tooter (on Remote Device)</value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QmakeProjectManager.MerRunConfiguration:harbour-tooter</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.Arguments"></value>
<value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.TargetName">harbour-tooter</value>
<value type="QString" key="RemoteLinux.RunConfig.AlternateRemoteExecutable"></value>
<value type="bool" key="RemoteLinux.RunConfig.UseAlternateRemoteExecutable">false</value>
<value type="QString" key="RemoteLinux.RunConfig.WorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
@ -426,12 +424,12 @@
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-armv7hl</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">MerSDK-SailfishOS-armv7hl</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-armv7hl</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">MerSDK-SailfishOS-armv7hl</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{f895389d-b51a-4d4f-8b03-5ec64bda6f66}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{588087e2-ecc1-41aa-b652-86f16cba9351}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">2</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -503,7 +501,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -575,7 +573,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2"> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/dysko/GIT/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">C:/Users/dysko/SF/build-harbour-tooter-MerSDK_SailfishOS_armv7hl-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -761,21 +759,19 @@
<value type="int">13</value> <value type="int">13</value>
<value type="int">14</value> <value type="int">14</value>
</valuelist> </valuelist>
<value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">/Users/dysko/GIT/harbour-tooter</value> <value type="QString" key="MerRunConfiguration.QmlLiveBenchWorkspace">C:/Users/dysko/SF/harbour-tooter</value>
<value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value> <value type="bool" key="MerRunConfiguration.QmlLiveEnabled">false</value>
<value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value> <value type="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value> <value type="int" key="MerRunConfiguration.QmlLiveOptions">3</value>
<value type="QString" key="MerRunConfiguration.QmlLiveTargetWorkspace"></value> <value type="QString" key="MerRunConfiguration.QmlLiveTargetWorkspace"></value>
<value type="int" key="PE.EnvironmentAspect.Base">1</value> <value type="int" key="PE.EnvironmentAspect.Base">-1</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">harbour-tooter (on Remote Device)</value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
<value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QmakeProjectManager.MerRunConfiguration:harbour-tooter</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.Arguments"></value>
<value type="QString" key="Qt4ProjectManager.MaemoRunConfiguration.TargetName">harbour-tooter</value>
<value type="QString" key="RemoteLinux.RunConfig.AlternateRemoteExecutable"></value>
<value type="bool" key="RemoteLinux.RunConfig.UseAlternateRemoteExecutable">false</value>
<value type="QString" key="RemoteLinux.RunConfig.WorkingDirectory"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>

View file

@ -52,8 +52,8 @@ ApplicationWindow
} }
if (Logic.conf['login']) { if (Logic.conf['login']) {
Logic.api.setConfig("api_user_token", Logic.conf['api_user_token']) Logic.api.setConfig("api_user_token", Logic.conf['api_user_token'])
//pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {}) pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {})
pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {}) //pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {})
} else { } else {
pageStack.push(Qt.resolvedUrl("./pages/LoginPage.qml"), {}) pageStack.push(Qt.resolvedUrl("./pages/LoginPage.qml"), {})
} }

View file

@ -12,6 +12,9 @@ Page {
property alias avatar: header.image property alias avatar: header.image
property int toot_id property int toot_id
property ListModel mdl; property ListModel mdl;
ListModel {
id: mediaModel
}
WorkerScript { WorkerScript {
id: worker id: worker
@ -131,29 +134,31 @@ Page {
? Theme.highlightColor ? Theme.highlightColor
: (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor)) : (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor))
onClicked: { onClicked: {
btnAddImage.enabled = false;
//receiver.receiveFromQml(42); //receiver.receiveFromQml(42);
//imageUploader.run() //imageUploader.run()
var once = true; var once = true;
var imagePicker = pageStack.push("Sailfish.Pickers.MultiImagePickerDialog", { "allowedOrientations" : Orientation.All }); // MultiImagePickerDialog
var imagePicker = pageStack.push("Sailfish.Pickers.ImagePickerPage", { "allowedOrientations" : Orientation.All });
imagePicker.selectedContentChanged.connect(function () { imagePicker.selectedContentChanged.connect(function () {
if (once) { 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();
/*if (once) {
for(var i = 0; i < imagePicker.selectedContent.count; i++){ for(var i = 0; i < imagePicker.selectedContent.count; i++){
var file = imagePicker.selectedContent.get(i); var file = imagePicker.selectedContent.get(i);
console.log(JSON.stringify(file)) console.log(JSON.stringify(file))
imageUploader.setUploadUrl("https://mastodon.social/api/v1/media")
//imageUploader.setUploadUrl("https://httpbin.org/post")
imageUploader.setFile(file.url); imageUploader.setFile(file.url);
imageUploader.setAuthorizationHeader(Logic.conf.api_user_token); imageUploader.setAuthorizationHeader(Logic.conf.api_user_token);
imageUploader.upload(); imageUploader.upload();
} }
once = false; once = false;
} }*/
/*var file = imagePicker.selectedContent + "";
//file = file.replace("file://", "");
console.log(file)
imageUploader.setFile(file);
imageUploader.setAuthorizationHeader(Logic.conf.api_user_token);
imageUploader.upload();*/
}); });
} }
} }
@ -166,15 +171,19 @@ Page {
onSuccess: { onSuccess: {
console.log(replyData); console.log(replyData);
mediaModel.append(JSON.parse(replyData))
btnAddImage.enabled = true;
} }
onFailure: { onFailure: {
btnAddImage.enabled = true;
console.log(status) console.log(status)
console.log(statusText) console.log(statusText)
} }
function run() { /*function run() {
imageUploader.setFile('file:///media/sdcard/686E-E026/Pictures/Camera/20170701_143819.jpg'); imageUploader.setFile('file:///media/sdcard/686E-E026/Pictures/Camera/20170701_143819.jpg');
imageUploader.setParameters("imageUploadData.imageAlbum", "imageUploadData.imageTitle", "imageUploadData.imageDesc"); imageUploader.setParameters("imageUploadData.imageAlbum", "imageUploadData.imageTitle", "imageUploadData.imageDesc");
@ -182,7 +191,7 @@ Page {
imageUploader.setUserAgent("constant.userAgent"); imageUploader.setUserAgent("constant.userAgent");
imageUploader.upload(); imageUploader.upload();
} }*/
} }
ComboBox { ComboBox {
id: privacy id: privacy
@ -212,6 +221,12 @@ Page {
enabled: toot.text !== "" enabled: toot.text !== ""
onClicked: { onClicked: {
var visibility = [ "public", "unlisted", "private", "direct"]; var visibility = [ "public", "unlisted", "private", "direct"];
var media_ids = [];
for(var k = 0; k < mediaModel.count; k++){
console.log(mediaModel.get(k).id)
media_ids.push(mediaModel.get(k).id)
}
var msg = { var msg = {
'action' : 'statuses', 'action' : 'statuses',
'method' : 'POST', 'method' : 'POST',
@ -219,7 +234,8 @@ Page {
'mode' : "append", 'mode' : "append",
'params' : { 'params' : {
"status": toot.text, "status": toot.text,
"visibility": visibility[privacy.currentIndex] "visibility": visibility[privacy.currentIndex],
"media_ids": media_ids
}, },
'conf' : Logic.conf 'conf' : Logic.conf
}; };

View file

@ -53,7 +53,7 @@ Page {
id: column id: column
width: parent.width width: parent.width
PageHeader { title: "Login" } PageHeader { title: qsTr("Login") }
SectionHeader { SectionHeader {
text: "Instance" text: "Instance"

View file

@ -58,7 +58,7 @@ SilicaListView {
PullDownMenu { PullDownMenu {
MenuItem { MenuItem {
text: Logic.conf['login'] ? qsTrId("Logout"): qsTrId("Login") text: Logic.conf['login'] ? qsTr("Logout"): qsTr("Login")
onClicked: { onClicked: {
if (Logic.conf['login']) { if (Logic.conf['login']) {
Logic.conf['login'] = false Logic.conf['login'] = false

View file

@ -29,3 +29,6 @@
* Tue July 4 2017 Dusko Angirevic <dysko@me.com> 0.1.8-0 * Tue July 4 2017 Dusko Angirevic <dysko@me.com> 0.1.8-0
- Added notifications - Added notifications
- App Cover redesigned - App Cover redesigned
* Thu July 7 2017 Dusko Angirevic <dysko@me.com> 0.1.9-0
- Image Upload added [#9]

View file

@ -13,7 +13,7 @@ Name: harbour-tooter
%{!?qtc_make:%define qtc_make make} %{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir} %{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: Tooter Summary: Tooter
Version: 0.1.8 Version: 0.1.9
Release: 1 Release: 1
Group: Qt/Qt Group: Qt/Qt
License: LICENSE License: LICENSE

View file

@ -1,6 +1,6 @@
Name: harbour-tooter Name: harbour-tooter
Summary: Tooter Summary: Tooter
Version: 0.1.8 Version: 0.1.9
Release: Release:
# The contents of the Group field should be one of the groups listed here: # The contents of the Group field should be one of the groups listed here:
# http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS # http://gitorious.org/meego-developer-tools/spectacle/blobs/master/data/GROUPS

View file

@ -3,12 +3,13 @@
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkRequest> #include <QtNetwork/QNetworkRequest>
#include <QtNetwork/QNetworkReply> #include <QtNetwork/QNetworkReply>
#include <QHttpMultiPart> #include <QtNetwork/QHttpMultiPart>
#include <QtCore/QFile> #include <QtCore/QFile>
#include <QtCore/QFileInfo> #include <QtCore/QFileInfo>
//static const QUrl IMGUR_UPLOAD_URL("https://httpbin.org/post"); //static const QUrl IMGUR_UPLOAD_URL("https://httpbin.org/post");
static const QUrl IMGUR_UPLOAD_URL("https://mastodon.social/api/v1/media"); //static const QUrl IMGUR_UPLOAD_URL();
ImageUploader::ImageUploader(QObject *parent) : QObject(parent), m_networkAccessManager(0), m_reply(0) { ImageUploader::ImageUploader(QObject *parent) : QObject(parent), m_networkAccessManager(0), m_reply(0) {
m_networkAccessManager = new QNetworkAccessManager(this); m_networkAccessManager = new QNetworkAccessManager(this);
@ -45,8 +46,9 @@ void ImageUploader::setAuthorizationHeader(const QString &authorizationHeader) {
m_authorizationHeader = "Bearer "+authorizationHeader.toUtf8(); m_authorizationHeader = "Bearer "+authorizationHeader.toUtf8();
} }
void ImageUploader::setUserAgent(const QString &userAgent) { void ImageUploader::setUploadUrl(const QString &UrlString) {
m_userAgent = userAgent.toUtf8(); qDebug() << "Set Upload URL " + UrlString;
m_uploadUrl = UrlString.toUtf8();
} }
void ImageUploader::upload() { void ImageUploader::upload() {
@ -62,41 +64,60 @@ void ImageUploader::upload() {
m_reply = 0; m_reply = 0;
} }
qDebug() << "TwitterApi::uploadImage"; /*QFileInfo fileInfo(QUrl(m_fileName).toLocalFile());
QUrl url = IMGUR_UPLOAD_URL; qDebug("fileName: %s", qPrintable(m_fileName));
QNetworkRequest request(url); if (!fileInfo.exists()) {
QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); emit failure(-1, tr("The file %1 does not exists").arg(m_fileName));
QHttpPart imagePart; postdata.clear();
//imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); return;
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"file\"")); }*/
QFile *file = new QFile(m_fileName);
file->open(QIODevice::ReadOnly);
QByteArray rawImage = file->readAll();
imagePart.setBody(rawImage);
file->setParent(multiPart);
QHttpMultiPart* multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
QHttpPart imagePart;
//QFile file(fileInfo.absoluteFilePath());
QFileInfo fileInfo(QUrl(m_fileName).toLocalFile());
QFile* file = new QFile(QUrl(m_fileName).toLocalFile());
if (!file->open(QIODevice::ReadWrite)) {
emit failure(-1, tr("The file %1 does not exists").arg(m_fileName));
return;
}
/*bool opened = file.open(QIODevice::ReadOnly);
if (!opened) {
qDebug("can't read file: %s", qPrintable(m_fileName));
emit failure(-1, tr("Unable to open the file %1").arg(file.fileName()));
postdata.clear();
return;
}*/
//QByteArray fileData = file.readAll().toBase64();
imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QString("form-data; name=\"file\"; filename=\"%1\"").arg(fileInfo.fileName()).toLatin1()));
imagePart.setBodyDevice(file);
file->setParent(multiPart);
multiPart->append(imagePart); multiPart->append(imagePart);
//imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(fileInfo));
//POST data
//request.setUrl(IMGUR_UPLOAD_URL);
QNetworkRequest request(m_uploadUrl);
request.setRawHeader("Authorization", m_authorizationHeader); request.setRawHeader("Authorization", m_authorizationHeader);
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
// request.setRawHeader("User-Agent", m_userAgent);
m_reply = m_networkAccessManager->post(request, multiPart); m_reply = m_networkAccessManager->post(request, multiPart);
multiPart->setParent(m_reply); multiPart->setParent(m_reply);
m_reply->setObjectName("file");
connect(m_reply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64))); connect(m_reply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));
//connect(m_reply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
//connect(m_reply, SIGNAL(finished()), this, SLOT(replyFinished()));*/
} }
qreal ImageUploader::progress() const { qreal ImageUploader::progress() const {

View file

@ -17,7 +17,7 @@ public:
Q_INVOKABLE void setFile(const QString &fileName); Q_INVOKABLE void setFile(const QString &fileName);
Q_INVOKABLE void setAuthorizationHeader(const QString &authorizationHeader); Q_INVOKABLE void setAuthorizationHeader(const QString &authorizationHeader);
Q_INVOKABLE void setUserAgent(const QString &userAgent); Q_INVOKABLE void setUploadUrl(const QString &userAgent);
Q_INVOKABLE void setParameters(const QString &album, const QString &title, const QString &description); Q_INVOKABLE void setParameters(const QString &album, const QString &title, const QString &description);
Q_INVOKABLE void upload(); Q_INVOKABLE void upload();
@ -38,7 +38,7 @@ private:
QString m_fileName; QString m_fileName;
QByteArray m_authorizationHeader; QByteArray m_authorizationHeader;
QByteArray m_userAgent; QString m_uploadUrl;
QByteArray postdata; QByteArray postdata;
QNetworkReply *m_reply; QNetworkReply *m_reply;
}; };

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name></name>
<message id="Logout">
<source></source>
<translation>Cerrar sesión</translation>
</message>
<message id="Login">
<source></source>
<translation>Iniciar sesión</translation>
</message>
</context>
<context> <context>
<name>API</name> <name>API</name>
<message> <message>
@ -24,11 +13,11 @@
</message> </message>
<message> <message>
<source>boosted</source> <source>boosted</source>
<translation>Aumentado</translation> <translation>aumentado</translation>
</message> </message>
<message> <message>
<source>said</source> <source>said</source>
<translation>Dijo</translation> <translation>dijo</translation>
</message> </message>
</context> </context>
<context> <context>
@ -50,27 +39,41 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<source>Conversation</source> <source>Conversation</source>
<translation>Conversación</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Content warning!</source> <source>Content warning!</source>
<translation>Advertencia de contenido!</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>public</source> <source>public</source>
<translation>Público</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>unlisted</source> <source>unlisted</source>
<translation>Deslistado</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>followers only</source> <source>followers only</source>
<translation>Sólo seguidores</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>direct</source> <source>direct</source>
<translation>Directo</translation> <translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished">Iniciar sesión</translation>
</message> </message>
</context> </context>
<context> <context>
@ -117,6 +120,14 @@
<source>Load more</source> <source>Load more</source>
<translation>Cargar más</translation> <translation>Cargar más</translation>
</message> </message>
<message>
<source>Logout</source>
<translation type="finished">Cerrar sesión</translation>
</message>
<message>
<source>Login</source>
<translation type="finished">Iniciar sesión</translation>
</message>
</context> </context>
<context> <context>
<name>Profile</name> <name>Profile</name>

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name></name>
<message id="Logout">
<source></source>
<translation>Déconnexion</translation>
</message>
<message id="Login">
<source></source>
<translation>Connexion</translation>
</message>
</context>
<context> <context>
<name>API</name> <name>API</name>
<message> <message>
@ -50,27 +39,41 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<source>Conversation</source> <source>Conversation</source>
<translation>Conversation</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Content warning!</source> <source>Content warning!</source>
<translation>Contenu sensible !</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>public</source> <source>public</source>
<translation>public</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>unlisted</source> <source>unlisted</source>
<translation>non-listé</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>followers only</source> <source>followers only</source>
<translation>abonnés uniquement</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>direct</source> <source>direct</source>
<translation>direct</translation> <translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -117,6 +120,14 @@
<source>Load more</source> <source>Load more</source>
<translation>Charger plus</translation> <translation>Charger plus</translation>
</message> </message>
<message>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Profile</name> <name>Profile</name>

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1" language="nl"> <TS version="2.1" language="nl">
<context>
<name></name>
<message id="Logout">
<source></source>
<translation type="unfinished"></translation>
</message>
<message id="Login">
<source></source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>API</name> <name>API</name>
<message> <message>
@ -50,27 +39,41 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<source>Conversation</source> <source>Conversation</source>
<translation>Gesprek</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Content warning!</source> <source>Content warning!</source>
<translation>Gevoelige inhoud!</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>public</source> <source>public</source>
<translation>openbaar</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>unlisted</source> <source>unlisted</source>
<translation>niet op lijst</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>followers only</source> <source>followers only</source>
<translation>alleen volgers</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>direct</source> <source>direct</source>
<translation>direct</translation> <translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -117,6 +120,14 @@
<source>Load more</source> <source>Load more</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Profile</name> <name>Profile</name>

View file

@ -1,17 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name></name>
<message id="Logout">
<source></source>
<translation>Se desconnectar</translation>
</message>
<message id="Login">
<source></source>
<translation>Connexion</translation>
</message>
</context>
<context> <context>
<name>API</name> <name>API</name>
<message> <message>
@ -50,27 +39,41 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<source>Conversation</source> <source>Conversation</source>
<translation>Conversacion</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>Content warning!</source> <source>Content warning!</source>
<translation>Contengut sensible !</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>public</source> <source>public</source>
<translation>public</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>unlisted</source> <source>unlisted</source>
<translation>pas listat</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>followers only</source> <source>followers only</source>
<translation>seguidors solament</translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<source>direct</source> <source>direct</source>
<translation>dirècte</translation> <translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message> </message>
</context> </context>
<context> <context>
@ -117,6 +120,14 @@
<source>Load more</source> <source>Load more</source>
<translation>Cargar mai</translation> <translation>Cargar mai</translation>
</message> </message>
<message>
<source>Logout</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Login</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>Profile</name> <name>Profile</name>

View file

@ -1,34 +1,23 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name></name>
<message id="Logout">
<source></source>
<translation type="unfinished"></translation>
</message>
<message id="Login">
<source></source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>API</name> <name>API</name>
<message> <message>
<source>favourited</source> <source>favourited</source>
<translation type="unfinished">favourited</translation> <translation>favourited</translation>
</message> </message>
<message> <message>
<source>followed you</source> <source>followed you</source>
<translation type="unfinished">followed you</translation> <translation>followed you</translation>
</message> </message>
<message> <message>
<source>boosted</source> <source>boosted</source>
<translation type="unfinished">boosted</translation> <translation>boosted</translation>
</message> </message>
<message> <message>
<source>said</source> <source>said</source>
<translation type="unfinished"></translation> <translation>said</translation>
</message> </message>
</context> </context>
<context> <context>
@ -50,7 +39,7 @@
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<source>Conversation</source> <source>Conversation</source>
<translation type="unfinished"></translation> <translation>Conversation</translation>
</message> </message>
<message> <message>
<source>Content warning!</source> <source>Content warning!</source>
@ -58,19 +47,33 @@
</message> </message>
<message> <message>
<source>public</source> <source>public</source>
<translation type="unfinished"></translation> <translation>Content warning!</translation>
</message> </message>
<message> <message>
<source>unlisted</source> <source>unlisted</source>
<translation type="unfinished"></translation> <translation>unlisted</translation>
</message> </message>
<message> <message>
<source>followers only</source> <source>followers only</source>
<translation type="unfinished"></translation> <translation>followers only</translation>
</message> </message>
<message> <message>
<source>direct</source> <source>direct</source>
<translation type="unfinished"></translation> <translation>direct</translation>
</message>
</context>
<context>
<name>ImageUploader</name>
<message>
<source>The file %1 does not exists</source>
<translation>The file %1 does not exists</translation>
</message>
</context>
<context>
<name>LoginPage</name>
<message>
<source>Login</source>
<translation>Login</translation>
</message> </message>
</context> </context>
<context> <context>
@ -115,7 +118,15 @@
<name>MyList</name> <name>MyList</name>
<message> <message>
<source>Load more</source> <source>Load more</source>
<translation type="unfinished"></translation> <translation>Load more</translation>
</message>
<message>
<source>Logout</source>
<translation>Logout</translation>
</message>
<message>
<source>Login</source>
<translation>Login</translation>
</message> </message>
</context> </context>
<context> <context>
@ -188,19 +199,19 @@
<name>VisualContainer</name> <name>VisualContainer</name>
<message> <message>
<source>Unboost</source> <source>Unboost</source>
<translation type="unfinished"></translation> <translation>Unboost</translation>
</message> </message>
<message> <message>
<source>Boost</source> <source>Boost</source>
<translation type="unfinished"></translation> <translation>Boost</translation>
</message> </message>
<message> <message>
<source>Unfavorite</source> <source>Unfavorite</source>
<translation type="unfinished"></translation> <translation>Unfavorite</translation>
</message> </message>
<message> <message>
<source>Favorite</source> <source>Favorite</source>
<translation type="unfinished"></translation> <translation>Favorite</translation>
</message> </message>
</context> </context>
</TS> </TS>