mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Merge pull request #2601 from Atlante45/error_or_success_model_upload_msg
Error or success model upload msg
This commit is contained in:
commit
a57002038b
3 changed files with 50 additions and 22 deletions
|
@ -63,7 +63,7 @@
|
|||
#include <UUID.h>
|
||||
#include <OctreeSceneStats.h>
|
||||
#include <LocalVoxelsList.h>
|
||||
#include <FstReader.h>
|
||||
#include <ModelUploader.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "InterfaceVersion.h"
|
||||
|
@ -3244,9 +3244,9 @@ void Application::toggleRunningScriptsWidget()
|
|||
}
|
||||
|
||||
void Application::uploadFST(bool isHead) {
|
||||
FstReader reader(isHead);
|
||||
if (reader.zip()) {
|
||||
reader.send();
|
||||
ModelUploader* uploader = new ModelUploader(isHead);
|
||||
if (uploader->zip()) {
|
||||
uploader->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// FstReader.cpp
|
||||
// ModelUploader.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 3/4/14.
|
||||
|
@ -18,7 +18,7 @@
|
|||
#include <QMessageBox>
|
||||
|
||||
#include "AccountManager.h"
|
||||
#include "FstReader.h"
|
||||
#include "ModelUploader.h"
|
||||
|
||||
|
||||
static const QString NAME_FIELD = "name";
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
FstReader::FstReader(bool isHead) :
|
||||
ModelUploader::ModelUploader(bool isHead) :
|
||||
_zipDir(new TemporaryDir()),
|
||||
_lodCount(-1),
|
||||
_texturesCount(-1),
|
||||
|
@ -51,11 +51,11 @@ FstReader::FstReader(bool isHead) :
|
|||
|
||||
}
|
||||
|
||||
FstReader::~FstReader() {
|
||||
ModelUploader::~ModelUploader() {
|
||||
delete _dataMultiPart;
|
||||
}
|
||||
|
||||
bool FstReader::zip() {
|
||||
bool ModelUploader::zip() {
|
||||
// File Dialog
|
||||
QString filename = QFileDialog::getOpenFileName(NULL,
|
||||
"Select your .fst file ...",
|
||||
|
@ -167,20 +167,41 @@ bool FstReader::zip() {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::send() {
|
||||
bool ModelUploader::send() {
|
||||
if (!_readyToSend) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, JSONCallbackParameters(), QByteArray(), _dataMultiPart);
|
||||
JSONCallbackParameters callbackParams;
|
||||
callbackParams.jsonCallbackReceiver = this;
|
||||
callbackParams.jsonCallbackMethod = "uploadSuccess";
|
||||
callbackParams.errorCallbackReceiver = this;
|
||||
callbackParams.errorCallbackMethod = "uploadFailed";
|
||||
|
||||
AccountManager::getInstance().authenticatedRequest(MODEL_URL, QNetworkAccessManager::PostOperation, callbackParams, QByteArray(), _dataMultiPart);
|
||||
_zipDir = NULL;
|
||||
_dataMultiPart = NULL;
|
||||
qDebug() << "Model sent.";
|
||||
qDebug() << "Sending model...";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::addTextures(const QFileInfo& texdir) {
|
||||
void ModelUploader::uploadSuccess(const QJsonObject& jsonResponse) {
|
||||
qDebug() << "Model sent with success to the data server.";
|
||||
qDebug() << "It might take a few minute for it to appear in your model browser.";
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
void ModelUploader::uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString) {
|
||||
QMessageBox::warning(NULL,
|
||||
QString("ModelUploader::uploadFailed()"),
|
||||
QString("Model could not be sent to the data server."),
|
||||
QMessageBox::Ok);
|
||||
qDebug() << "Model upload failed (" << errorCode << "): " << errorString;
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
bool ModelUploader::addTextures(const QFileInfo& texdir) {
|
||||
QStringList filter;
|
||||
filter << "*.png" << "*.tif" << "*.jpg" << "*.jpeg";
|
||||
|
||||
|
@ -209,7 +230,7 @@ bool FstReader::addTextures(const QFileInfo& texdir) {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool FstReader::compressFile(const QString &inFileName, const QString &outFileName) {
|
||||
bool ModelUploader::compressFile(const QString &inFileName, const QString &outFileName) {
|
||||
QFile inFile(inFileName);
|
||||
inFile.open(QIODevice::ReadOnly);
|
||||
QByteArray buffer = inFile.readAll();
|
||||
|
@ -233,7 +254,7 @@ bool FstReader::compressFile(const QString &inFileName, const QString &outFileNa
|
|||
}
|
||||
|
||||
|
||||
bool FstReader::addPart(const QString &path, const QString& name) {
|
||||
bool ModelUploader::addPart(const QString &path, const QString& name) {
|
||||
QFile* file = new QFile(path);
|
||||
if (!file->open(QIODevice::ReadOnly)) {
|
||||
QMessageBox::warning(NULL,
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// FstReader.h
|
||||
// ModelUploader.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Clément Brisset on 3/4/14.
|
||||
|
@ -7,20 +7,27 @@
|
|||
//
|
||||
//
|
||||
|
||||
#ifndef __hifi__FstReader__
|
||||
#define __hifi__FstReader__
|
||||
#ifndef __hifi__ModelUploader__
|
||||
#define __hifi__ModelUploader__
|
||||
|
||||
class TemporaryDir;
|
||||
class QHttpMultiPart;
|
||||
class QFileInfo;
|
||||
|
||||
class FstReader : public QObject {
|
||||
class ModelUploader : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FstReader(bool isHead);
|
||||
~FstReader();
|
||||
ModelUploader(bool isHead);
|
||||
~ModelUploader();
|
||||
|
||||
bool zip();
|
||||
bool send();
|
||||
|
||||
private slots:
|
||||
void uploadSuccess(const QJsonObject& jsonResponse);
|
||||
void uploadFailed(QNetworkReply::NetworkError errorCode, const QString& errorString);
|
||||
|
||||
private:
|
||||
TemporaryDir* _zipDir;
|
||||
int _lodCount;
|
||||
|
@ -37,4 +44,4 @@ private:
|
|||
bool addPart(const QString& path, const QString& name);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__FstReader__) */
|
||||
#endif /* defined(__hifi__ModelUploader__) */
|
Loading…
Reference in a new issue