Image upload and translations
- Image Upload added [#9] - Fixed some translation strings
This commit is contained in:
parent
a19d7503b0
commit
20f7ce524a
15 changed files with 266 additions and 175 deletions
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!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>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
<value type="QByteArray">{41ec03ca-9430-48f3-b421-990d428b2838}</value>
|
||||
<value type="QByteArray">{25497605-1bff-4134-a878-76c1475dd8e3}</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
<value type="int">1</value>
|
||||
<value type="int">0</value>
|
||||
</data>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.EditorSettings</variable>
|
||||
|
@ -61,12 +61,12 @@
|
|||
<valuemap type="QVariantMap">
|
||||
<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.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.ActiveDeployConfiguration">2</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -138,7 +138,7 @@
|
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -210,7 +210,7 @@
|
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -396,21 +396,19 @@
|
|||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</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="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
|
||||
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</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"/>
|
||||
<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.Id">QmakeProjectManager.MerRunConfiguration:harbour-tooter</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="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
@ -426,12 +424,12 @@
|
|||
<valuemap type="QVariantMap">
|
||||
<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.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.ActiveDeployConfiguration">2</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
|
||||
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -503,7 +501,7 @@
|
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -575,7 +573,7 @@
|
|||
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
|
||||
</valuemap>
|
||||
<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.BuildStepList.Step.0">
|
||||
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
|
||||
|
@ -761,21 +759,19 @@
|
|||
<value type="int">13</value>
|
||||
<value type="int">14</value>
|
||||
</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="int" key="MerRunConfiguration.QmlLiveIpcPort">10234</value>
|
||||
<value type="int" key="MerRunConfiguration.QmlLiveOptions">3</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"/>
|
||||
<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.Id">QmakeProjectManager.MerRunConfiguration:harbour-tooter</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="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
|
||||
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
|
||||
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
|
||||
|
|
|
@ -52,8 +52,8 @@ ApplicationWindow
|
|||
}
|
||||
if (Logic.conf['login']) {
|
||||
Logic.api.setConfig("api_user_token", Logic.conf['api_user_token'])
|
||||
//pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {})
|
||||
pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {})
|
||||
pageStack.push(Qt.resolvedUrl("./pages/MainPage.qml"), {})
|
||||
//pageStack.push(Qt.resolvedUrl("./pages/Conversation.qml"), {})
|
||||
} else {
|
||||
pageStack.push(Qt.resolvedUrl("./pages/LoginPage.qml"), {})
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@ Page {
|
|||
property alias avatar: header.image
|
||||
property int toot_id
|
||||
property ListModel mdl;
|
||||
ListModel {
|
||||
id: mediaModel
|
||||
}
|
||||
|
||||
WorkerScript {
|
||||
id: worker
|
||||
|
@ -131,29 +134,31 @@ Page {
|
|||
? Theme.highlightColor
|
||||
: (warningContent.visible ? Theme.secondaryHighlightColor : Theme.primaryColor))
|
||||
onClicked: {
|
||||
btnAddImage.enabled = false;
|
||||
//receiver.receiveFromQml(42);
|
||||
//imageUploader.run()
|
||||
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 () {
|
||||
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++){
|
||||
var file = imagePicker.selectedContent.get(i);
|
||||
console.log(JSON.stringify(file))
|
||||
imageUploader.setUploadUrl("https://mastodon.social/api/v1/media")
|
||||
//imageUploader.setUploadUrl("https://httpbin.org/post")
|
||||
imageUploader.setFile(file.url);
|
||||
imageUploader.setAuthorizationHeader(Logic.conf.api_user_token);
|
||||
imageUploader.upload();
|
||||
}
|
||||
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: {
|
||||
console.log(replyData);
|
||||
mediaModel.append(JSON.parse(replyData))
|
||||
btnAddImage.enabled = true;
|
||||
|
||||
}
|
||||
|
||||
onFailure: {
|
||||
btnAddImage.enabled = true;
|
||||
console.log(status)
|
||||
console.log(statusText)
|
||||
|
||||
}
|
||||
|
||||
function run() {
|
||||
/*function run() {
|
||||
imageUploader.setFile('file:///media/sdcard/686E-E026/Pictures/Camera/20170701_143819.jpg');
|
||||
imageUploader.setParameters("imageUploadData.imageAlbum", "imageUploadData.imageTitle", "imageUploadData.imageDesc");
|
||||
|
||||
|
@ -182,7 +191,7 @@ Page {
|
|||
imageUploader.setUserAgent("constant.userAgent");
|
||||
|
||||
imageUploader.upload();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
ComboBox {
|
||||
id: privacy
|
||||
|
@ -212,6 +221,12 @@ Page {
|
|||
enabled: toot.text !== ""
|
||||
onClicked: {
|
||||
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 = {
|
||||
'action' : 'statuses',
|
||||
'method' : 'POST',
|
||||
|
@ -219,7 +234,8 @@ Page {
|
|||
'mode' : "append",
|
||||
'params' : {
|
||||
"status": toot.text,
|
||||
"visibility": visibility[privacy.currentIndex]
|
||||
"visibility": visibility[privacy.currentIndex],
|
||||
"media_ids": media_ids
|
||||
},
|
||||
'conf' : Logic.conf
|
||||
};
|
||||
|
|
|
@ -53,7 +53,7 @@ Page {
|
|||
id: column
|
||||
width: parent.width
|
||||
|
||||
PageHeader { title: "Login" }
|
||||
PageHeader { title: qsTr("Login") }
|
||||
|
||||
SectionHeader {
|
||||
text: "Instance"
|
||||
|
|
|
@ -58,7 +58,7 @@ SilicaListView {
|
|||
|
||||
PullDownMenu {
|
||||
MenuItem {
|
||||
text: Logic.conf['login'] ? qsTrId("Logout"): qsTrId("Login")
|
||||
text: Logic.conf['login'] ? qsTr("Logout"): qsTr("Login")
|
||||
onClicked: {
|
||||
if (Logic.conf['login']) {
|
||||
Logic.conf['login'] = false
|
||||
|
|
|
@ -29,3 +29,6 @@
|
|||
* Tue July 4 2017 Dusko Angirevic <dysko@me.com> 0.1.8-0
|
||||
- Added notifications
|
||||
- App Cover redesigned
|
||||
|
||||
* Thu July 7 2017 Dusko Angirevic <dysko@me.com> 0.1.9-0
|
||||
- Image Upload added [#9]
|
||||
|
|
|
@ -13,7 +13,7 @@ Name: harbour-tooter
|
|||
%{!?qtc_make:%define qtc_make make}
|
||||
%{?qtc_builddir:%define _builddir %qtc_builddir}
|
||||
Summary: Tooter
|
||||
Version: 0.1.8
|
||||
Version: 0.1.9
|
||||
Release: 1
|
||||
Group: Qt/Qt
|
||||
License: LICENSE
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Name: harbour-tooter
|
||||
Summary: Tooter
|
||||
Version: 0.1.8
|
||||
Version: 0.1.9
|
||||
Release:
|
||||
# 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
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
#include <QtNetwork/QNetworkAccessManager>
|
||||
#include <QtNetwork/QNetworkRequest>
|
||||
#include <QtNetwork/QNetworkReply>
|
||||
#include <QHttpMultiPart>
|
||||
#include <QtNetwork/QHttpMultiPart>
|
||||
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
//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) {
|
||||
m_networkAccessManager = new QNetworkAccessManager(this);
|
||||
|
@ -45,8 +46,9 @@ void ImageUploader::setAuthorizationHeader(const QString &authorizationHeader) {
|
|||
m_authorizationHeader = "Bearer "+authorizationHeader.toUtf8();
|
||||
}
|
||||
|
||||
void ImageUploader::setUserAgent(const QString &userAgent) {
|
||||
m_userAgent = userAgent.toUtf8();
|
||||
void ImageUploader::setUploadUrl(const QString &UrlString) {
|
||||
qDebug() << "Set Upload URL " + UrlString;
|
||||
m_uploadUrl = UrlString.toUtf8();
|
||||
}
|
||||
|
||||
void ImageUploader::upload() {
|
||||
|
@ -62,41 +64,60 @@ void ImageUploader::upload() {
|
|||
m_reply = 0;
|
||||
}
|
||||
|
||||
qDebug() << "TwitterApi::uploadImage";
|
||||
QUrl url = IMGUR_UPLOAD_URL;
|
||||
QNetworkRequest request(url);
|
||||
/*QFileInfo fileInfo(QUrl(m_fileName).toLocalFile());
|
||||
qDebug("fileName: %s", qPrintable(m_fileName));
|
||||
if (!fileInfo.exists()) {
|
||||
emit failure(-1, tr("The file %1 does not exists").arg(m_fileName));
|
||||
postdata.clear();
|
||||
return;
|
||||
}*/
|
||||
|
||||
QHttpMultiPart* multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
|
||||
QHttpPart imagePart;
|
||||
//imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg"));
|
||||
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);
|
||||
|
||||
|
||||
//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);
|
||||
|
||||
//imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant(fileInfo));
|
||||
|
||||
|
||||
|
||||
//POST data
|
||||
|
||||
//request.setUrl(IMGUR_UPLOAD_URL);
|
||||
|
||||
|
||||
QNetworkRequest request(m_uploadUrl);
|
||||
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);
|
||||
multiPart->setParent(m_reply);
|
||||
m_reply->setObjectName("file");
|
||||
|
||||
|
||||
|
||||
connect(m_reply, SIGNAL(uploadProgress(qint64,qint64)), this, SLOT(uploadProgress(qint64,qint64)));
|
||||
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 {
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
Q_INVOKABLE void setFile(const QString &fileName);
|
||||
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 upload();
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
|||
|
||||
QString m_fileName;
|
||||
QByteArray m_authorizationHeader;
|
||||
QByteArray m_userAgent;
|
||||
QString m_uploadUrl;
|
||||
QByteArray postdata;
|
||||
QNetworkReply *m_reply;
|
||||
};
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<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>
|
||||
<name>API</name>
|
||||
<message>
|
||||
|
@ -24,11 +13,11 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>boosted</source>
|
||||
<translation>Aumentado</translation>
|
||||
<translation>aumentado</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>said</source>
|
||||
<translation>Dijo</translation>
|
||||
<translation>dijo</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -50,27 +39,41 @@
|
|||
<name>Conversation</name>
|
||||
<message>
|
||||
<source>Conversation</source>
|
||||
<translation>Conversación</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Content warning!</source>
|
||||
<translation>Advertencia de contenido!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>public</source>
|
||||
<translation>Público</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>unlisted</source>
|
||||
<translation>Deslistado</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followers only</source>
|
||||
<translation>Sólo seguidores</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -117,6 +120,14 @@
|
|||
<source>Load more</source>
|
||||
<translation>Cargar más</translation>
|
||||
</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>
|
||||
<name>Profile</name>
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<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>
|
||||
<name>API</name>
|
||||
<message>
|
||||
|
@ -50,27 +39,41 @@
|
|||
<name>Conversation</name>
|
||||
<message>
|
||||
<source>Conversation</source>
|
||||
<translation>Conversation</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Content warning!</source>
|
||||
<translation>Contenu sensible !</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>public</source>
|
||||
<translation>public</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>unlisted</source>
|
||||
<translation>non-listé</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followers only</source>
|
||||
<translation>abonnés uniquement</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -117,6 +120,14 @@
|
|||
<source>Load more</source>
|
||||
<translation>Charger plus</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Logout</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Profile</name>
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<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>
|
||||
<name>API</name>
|
||||
<message>
|
||||
|
@ -50,27 +39,41 @@
|
|||
<name>Conversation</name>
|
||||
<message>
|
||||
<source>Conversation</source>
|
||||
<translation>Gesprek</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Content warning!</source>
|
||||
<translation>Gevoelige inhoud!</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>public</source>
|
||||
<translation>openbaar</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>unlisted</source>
|
||||
<translation>niet op lijst</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followers only</source>
|
||||
<translation>alleen volgers</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -117,6 +120,14 @@
|
|||
<source>Load more</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Logout</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Profile</name>
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<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>
|
||||
<name>API</name>
|
||||
<message>
|
||||
|
@ -50,27 +39,41 @@
|
|||
<name>Conversation</name>
|
||||
<message>
|
||||
<source>Conversation</source>
|
||||
<translation>Conversacion</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Content warning!</source>
|
||||
<translation>Contengut sensible !</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>public</source>
|
||||
<translation>public</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>unlisted</source>
|
||||
<translation>pas listat</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followers only</source>
|
||||
<translation>seguidors solament</translation>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -117,6 +120,14 @@
|
|||
<source>Load more</source>
|
||||
<translation>Cargar mai</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Logout</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Login</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Profile</name>
|
||||
|
|
|
@ -1,34 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE TS>
|
||||
<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>
|
||||
<name>API</name>
|
||||
<message>
|
||||
<source>favourited</source>
|
||||
<translation type="unfinished">favourited</translation>
|
||||
<translation>favourited</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followed you</source>
|
||||
<translation type="unfinished">followed you</translation>
|
||||
<translation>followed you</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>boosted</source>
|
||||
<translation type="unfinished">boosted</translation>
|
||||
<translation>boosted</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>said</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>said</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -50,7 +39,7 @@
|
|||
<name>Conversation</name>
|
||||
<message>
|
||||
<source>Conversation</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Conversation</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Content warning!</source>
|
||||
|
@ -58,19 +47,33 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>public</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Content warning!</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>unlisted</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>unlisted</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>followers only</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>followers only</translation>
|
||||
</message>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -115,7 +118,15 @@
|
|||
<name>MyList</name>
|
||||
<message>
|
||||
<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>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -188,19 +199,19 @@
|
|||
<name>VisualContainer</name>
|
||||
<message>
|
||||
<source>Unboost</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Unboost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Boost</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Boost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Unfavorite</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Unfavorite</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Favorite</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation>Favorite</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
Loading…
Reference in a new issue