Merge remote-tracking branch 'origin/feature_paste_66994990' into integration_butchery
This commit is contained in:
commit
b77f4eb144
@ -25,7 +25,7 @@ void PasteUpload::executeTask()
|
|||||||
|
|
||||||
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
m_reply = std::shared_ptr<QNetworkReply>(rep);
|
||||||
connect(rep, &QNetworkReply::downloadProgress, [&](qint64 value, qint64 max)
|
connect(rep, &QNetworkReply::downloadProgress, [&](qint64 value, qint64 max)
|
||||||
{ setProgress(value / max * 100); });
|
{ setProgress(value / qMax((qint64)1, max) * 100); });
|
||||||
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this,
|
connect(rep, SIGNAL(error(QNetworkReply::NetworkError)), this,
|
||||||
SLOT(downloadError(QNetworkReply::NetworkError)));
|
SLOT(downloadError(QNetworkReply::NetworkError)));
|
||||||
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
connect(rep, SIGNAL(finished()), this, SLOT(downloadFinished()));
|
||||||
@ -52,10 +52,9 @@ void PasteUpload::downloadFinished()
|
|||||||
emitFailed(jsonError.errorString());
|
emitFailed(jsonError.errorString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QString error;
|
if (!parseResult(doc))
|
||||||
if (!parseResult(doc, &error))
|
|
||||||
{
|
{
|
||||||
emitFailed(error);
|
emitFailed(tr("paste.ee returned an error. Please consult the logs for more information"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,13 +68,13 @@ void PasteUpload::downloadFinished()
|
|||||||
emitSucceeded();
|
emitSucceeded();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PasteUpload::parseResult(QJsonDocument doc, QString *parseError)
|
bool PasteUpload::parseResult(QJsonDocument doc)
|
||||||
{
|
{
|
||||||
auto object = doc.object();
|
auto object = doc.object();
|
||||||
auto status = object.value("status").toString("error");
|
auto status = object.value("status").toString("error");
|
||||||
if (status == "error")
|
if (status == "error")
|
||||||
{
|
{
|
||||||
parseError = new QString(object.value("error").toString());
|
QLOG_ERROR() << "paste.ee reported error:" << QString(object.value("error").toString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// FIXME: not the place for GUI things.
|
// FIXME: not the place for GUI things.
|
||||||
|
@ -14,7 +14,7 @@ protected:
|
|||||||
virtual void executeTask();
|
virtual void executeTask();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool parseResult(QJsonDocument doc, QString *parseError);
|
bool parseResult(QJsonDocument doc);
|
||||||
QString m_text;
|
QString m_text;
|
||||||
QString m_error;
|
QString m_error;
|
||||||
QWidget *m_window;
|
QWidget *m_window;
|
||||||
|
Loading…
Reference in New Issue
Block a user