mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 06:38:29 +02:00
Add user feedback on download process
This commit is contained in:
parent
b672b7e177
commit
bf2bcc0b80
3 changed files with 70 additions and 6 deletions
|
@ -97,6 +97,7 @@ Rectangle {
|
||||||
element.unbind("click");
|
element.unbind("click");
|
||||||
element.bind("click", function(event) {
|
element.bind("click", function(event) {
|
||||||
console.log("Initiate Clara.io FBX file download for {uuid}");
|
console.log("Initiate Clara.io FBX file download for {uuid}");
|
||||||
|
EventBridge.emitWebEvent("CLARA.IO DOWNLOAD");
|
||||||
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
window.open("https://clara.io/api/scenes/{uuid}/export/fbx?fbxVersion=7.4&fbxEmbedTextures=true¢erScene=true&alignSceneGound=true");
|
||||||
return false;
|
return false;
|
||||||
});'
|
});'
|
||||||
|
@ -154,6 +155,16 @@ Rectangle {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onWebEventReceived(event) {
|
||||||
|
if (event === "CLARA.IO DOWNLOAD") {
|
||||||
|
ApplicationInterface.addAssetToWorldInitiate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
eventBridge.webEventReceived.connect(onWebEventReceived);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
|
|
|
@ -5470,13 +5470,41 @@ void Application::showAssetServerWidget(QString filePath) {
|
||||||
startUpload(nullptr, nullptr);
|
startUpload(nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::addAssetToWorldInitiate() {
|
||||||
|
qCDebug(interfaceapp) << "Start downloading asset file";
|
||||||
|
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
_addAssetToWorldMessageBox = DependencyManager::get<OffscreenUi>()->createMessageBox(OffscreenUi::ICON_INFORMATION,
|
||||||
|
"Downloading Asset", "Preparing asset for download", QMessageBox::Cancel, QMessageBox::NoButton);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect(_addAssetToWorldMessageBox, SIGNAL(destroyed()), this, SLOT(onAssetToWorldMessageBoxClosed()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::onAssetToWorldMessageBoxClosed() {
|
||||||
|
disconnect(_addAssetToWorldMessageBox);
|
||||||
|
_addAssetToWorldMessageBox = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Application::addAssetToWorldError(QString errorText) {
|
||||||
|
_addAssetToWorldMessageBox->setProperty("title", "Error Downloading Asset");
|
||||||
|
_addAssetToWorldMessageBox->setProperty("icon", OffscreenUi::ICON_CRITICAL);
|
||||||
|
_addAssetToWorldMessageBox->setProperty("text", errorText);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorld(QString filePath) {
|
void Application::addAssetToWorld(QString filePath) {
|
||||||
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
|
// Automatically upload and add asset to world as an alternative manual process initiated by showAssetServerWidget().
|
||||||
|
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_addAssetToWorldMessageBox->setProperty("text", "Downloading asset file");
|
||||||
|
|
||||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||||
QString errorInfo = "Do not have permissions to write to asset server.";
|
QString errorInfo = "Do not have permissions to write to asset server.";
|
||||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5487,6 +5515,10 @@ void Application::addAssetToWorld(QString filePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
|
void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
auto request = DependencyManager::get<AssetClient>()->createGetMappingRequest(mapping);
|
||||||
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
QObject::connect(request, &GetMappingRequest::finished, this, [=](GetMappingRequest* request) mutable {
|
||||||
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
const int MAX_COPY_COUNT = 100; // Limit number of duplicate assets; recursion guard.
|
||||||
|
@ -5503,7 +5535,7 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i
|
||||||
QString errorInfo = "Too many copies of asset name: "
|
QString errorInfo = "Too many copies of asset name: "
|
||||||
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
}
|
}
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -5512,12 +5544,16 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
||||||
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable {
|
||||||
if (upload->getError() != AssetUpload::NoError) {
|
if (upload->getError() != AssetUpload::NoError) {
|
||||||
QString errorInfo = "Could not upload asset to asset server.";
|
QString errorInfo = "Could not upload asset to asset server.";
|
||||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
} else {
|
} else {
|
||||||
addAssetToWorldSetMapping(mapping, hash);
|
addAssetToWorldSetMapping(mapping, hash);
|
||||||
}
|
}
|
||||||
|
@ -5537,12 +5573,16 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
|
auto request = DependencyManager::get<AssetClient>()->createSetMappingRequest(mapping, hash);
|
||||||
connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
|
connect(request, &SetMappingRequest::finished, this, [=](SetMappingRequest* request) mutable {
|
||||||
if (request->getError() != SetMappingRequest::NoError) {
|
if (request->getError() != SetMappingRequest::NoError) {
|
||||||
QString errorInfo = "Could not set asset mapping.";
|
QString errorInfo = "Could not set asset mapping.";
|
||||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
} else {
|
} else {
|
||||||
addAssetToWorldAddEntity(mapping);
|
addAssetToWorldAddEntity(mapping);
|
||||||
}
|
}
|
||||||
|
@ -5553,6 +5593,10 @@ void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldAddEntity(QString mapping) {
|
void Application::addAssetToWorldAddEntity(QString mapping) {
|
||||||
|
if (!_addAssetToWorldMessageBox) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
EntityItemProperties properties;
|
EntityItemProperties properties;
|
||||||
properties.setType(EntityTypes::Model);
|
properties.setType(EntityTypes::Model);
|
||||||
properties.setName(mapping.right(mapping.length() - 1));
|
properties.setName(mapping.right(mapping.length() - 1));
|
||||||
|
@ -5566,11 +5610,13 @@ void Application::addAssetToWorldAddEntity(QString mapping) {
|
||||||
if (result == QUuid()) {
|
if (result == QUuid()) {
|
||||||
QString errorInfo = "Could not add downloaded asset " + mapping + " to world.";
|
QString errorInfo = "Could not add downloaded asset " + mapping + " to world.";
|
||||||
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qCDebug(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
OffscreenUi::warning("Error Downloading Asset", errorInfo);
|
addAssetToWorldError(errorInfo);
|
||||||
} else {
|
} else {
|
||||||
QString successInfo = "Downloaded asset " + mapping + " added to world";
|
QString successInfo = "Downloaded asset " + mapping + " added to world";
|
||||||
qCDebug(interfaceapp) << "Downloading asset completed: " + successInfo;
|
qCDebug(interfaceapp) << "Downloading asset completed: " + successInfo;
|
||||||
OffscreenUi::information("Downloading Asset Completed", successInfo);
|
_addAssetToWorldMessageBox->setProperty("text", "Downloading asset completed");
|
||||||
|
_addAssetToWorldMessageBox->setProperty("buttons", QMessageBox::Ok);
|
||||||
|
_addAssetToWorldMessageBox->setProperty("defaultButton", QMessageBox::Ok);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
|
#include <QtQuick/QQuickItem>
|
||||||
|
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
|
@ -309,6 +310,7 @@ public slots:
|
||||||
void toggleLogDialog();
|
void toggleLogDialog();
|
||||||
void toggleRunningScriptsWidget() const;
|
void toggleRunningScriptsWidget() const;
|
||||||
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
Q_INVOKABLE void showAssetServerWidget(QString filePath = "");
|
||||||
|
Q_INVOKABLE void addAssetToWorldInitiate();
|
||||||
void addAssetToWorld(QString filePath);
|
void addAssetToWorld(QString filePath);
|
||||||
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
||||||
void addAssetToWorldUpload(QString path, QString mapping);
|
void addAssetToWorldUpload(QString path, QString mapping);
|
||||||
|
@ -398,6 +400,8 @@ private slots:
|
||||||
void updateDisplayMode();
|
void updateDisplayMode();
|
||||||
void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo);
|
void domainConnectionRefused(const QString& reasonMessage, int reason, const QString& extraInfo);
|
||||||
|
|
||||||
|
void onAssetToWorldMessageBoxClosed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void initDisplay();
|
static void initDisplay();
|
||||||
void init();
|
void init();
|
||||||
|
@ -616,6 +620,9 @@ private:
|
||||||
model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() } ;
|
model::SkyboxPointer _defaultSkybox { new ProceduralSkybox() } ;
|
||||||
gpu::TexturePointer _defaultSkyboxTexture;
|
gpu::TexturePointer _defaultSkyboxTexture;
|
||||||
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
gpu::TexturePointer _defaultSkyboxAmbientTexture;
|
||||||
|
|
||||||
|
QQuickItem* _addAssetToWorldMessageBox{ nullptr };
|
||||||
|
void Application::addAssetToWorldError(QString errorText);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue