mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 19:29:54 +02:00
Fix Clara download status message box not auto-closing
This commit is contained in:
parent
1e66bcae1b
commit
d933b3506f
2 changed files with 30 additions and 38 deletions
|
@ -5649,8 +5649,13 @@ void Application::addAssetToWorldFromURLRequestFinished() {
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString filenameFromPath(QString filePath) {
|
||||||
|
return filePath.right(filePath.length() - filePath.lastIndexOf("/") - 1);
|
||||||
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldUnzipFailure(QString filePath) {
|
void Application::addAssetToWorldUnzipFailure(QString filePath) {
|
||||||
QString filename = filePath.right(filePath.length() - filePath.lastIndexOf("/") - 1);
|
QString filename = filenameFromPath(QUrl(filePath).toLocalFile());
|
||||||
qWarning(interfaceapp) << "Couldn't unzip file" << filePath;
|
qWarning(interfaceapp) << "Couldn't unzip file" << filePath;
|
||||||
addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
|
addAssetToWorldError(filename, "Couldn't unzip file " + filename + ".");
|
||||||
}
|
}
|
||||||
|
@ -5659,13 +5664,11 @@ 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().
|
||||||
|
|
||||||
QString path = QUrl(filePath).toLocalFile();
|
QString path = QUrl(filePath).toLocalFile();
|
||||||
QString mapping = path.right(path.length() - path.lastIndexOf("/"));
|
QString filename = filenameFromPath(path);
|
||||||
|
QString mapping = "/" + filename;
|
||||||
QString filename = mapping.right(mapping.length() - 1);
|
|
||||||
|
|
||||||
// Test repeated because possibly different code paths.
|
// Test repeated because possibly different code paths.
|
||||||
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
if (!DependencyManager::get<NodeList>()->getThisNodeCanWriteAssets()) {
|
||||||
QString filename = mapping.right(mapping.length() - 1); // Remove leading "/".
|
|
||||||
QString errorInfo = "You do not have permissions to write to the Asset Server.";
|
QString errorInfo = "You do not have permissions to write to the Asset Server.";
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(filename, errorInfo);
|
addAssetToWorldError(filename, errorInfo);
|
||||||
|
@ -5677,42 +5680,31 @@ void Application::addAssetToWorld(QString filePath) {
|
||||||
addAssetToWorldWithNewMapping(path, mapping, 0);
|
addAssetToWorldWithNewMapping(path, mapping, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString filenameFromMapping(const QString mapping) {
|
void Application::addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy) {
|
||||||
QString result = mapping;
|
|
||||||
auto lastDash = result.lastIndexOf("-");
|
|
||||||
auto lastPeriod = result.lastIndexOf(".");
|
|
||||||
if (lastDash > 0 && lastPeriod > 0) {
|
|
||||||
result.remove(lastDash, lastPeriod - lastDash);
|
|
||||||
}
|
|
||||||
result.remove(0, 1); // Leading "/".
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, int copy) {
|
|
||||||
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.
|
||||||
auto result = request->getError();
|
auto result = request->getError();
|
||||||
if (result == GetMappingRequest::NotFound) {
|
if (result == GetMappingRequest::NotFound) {
|
||||||
addAssetToWorldUpload(path, mapping);
|
addAssetToWorldUpload(filePath, mapping);
|
||||||
} else if (result != GetMappingRequest::NoError) {
|
} else if (result != GetMappingRequest::NoError) {
|
||||||
QString errorInfo = "Could not map asset name: "
|
QString errorInfo = "Could not map asset name: "
|
||||||
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
+ mapping.left(mapping.length() - QString::number(copy).length() - 1);
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromMapping(mapping), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else if (copy < MAX_COPY_COUNT - 1) {
|
} else if (copy < MAX_COPY_COUNT - 1) {
|
||||||
if (copy > 0) {
|
if (copy > 0) {
|
||||||
mapping = mapping.remove(mapping.lastIndexOf("-"), QString::number(copy).length() + 1);
|
mapping = mapping.remove(mapping.lastIndexOf("-"), QString::number(copy).length() + 1);
|
||||||
}
|
}
|
||||||
copy++;
|
copy++;
|
||||||
mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
|
mapping = mapping.insert(mapping.lastIndexOf("."), "-" + QString::number(copy));
|
||||||
addAssetToWorldWithNewMapping(path, mapping, copy);
|
addAssetToWorldWithNewMapping(filePath, mapping, copy);
|
||||||
} else {
|
} else {
|
||||||
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);
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromMapping(mapping), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
}
|
}
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -5720,22 +5712,22 @@ void Application::addAssetToWorldWithNewMapping(QString path, QString mapping, i
|
||||||
request->start();
|
request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
void Application::addAssetToWorldUpload(QString filePath, QString mapping) {
|
||||||
qInfo(interfaceapp) << "Uploading" << path << "to Asset Server as" << mapping;
|
qInfo(interfaceapp) << "Uploading" << filePath << "to Asset Server as" << mapping;
|
||||||
auto upload = DependencyManager::get<AssetClient>()->createUpload(path);
|
auto upload = DependencyManager::get<AssetClient>()->createUpload(filePath);
|
||||||
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 the Asset Server.";
|
QString errorInfo = "Could not upload asset to the Asset Server.";
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromMapping(mapping), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else {
|
} else {
|
||||||
addAssetToWorldSetMapping(mapping, hash);
|
addAssetToWorldSetMapping(filePath, mapping, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove temporary directory created by Clara.io market place download.
|
// Remove temporary directory created by Clara.io market place download.
|
||||||
int index = path.lastIndexOf("/model_repo/");
|
int index = filePath.lastIndexOf("/model_repo/");
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
QString tempDir = path.left(index);
|
QString tempDir = filePath.left(index);
|
||||||
qCDebug(interfaceapp) << "Removing temporary directory at: " + tempDir;
|
qCDebug(interfaceapp) << "Removing temporary directory at: " + tempDir;
|
||||||
QDir(tempDir).removeRecursively();
|
QDir(tempDir).removeRecursively();
|
||||||
}
|
}
|
||||||
|
@ -5746,15 +5738,15 @@ void Application::addAssetToWorldUpload(QString path, QString mapping) {
|
||||||
upload->start();
|
upload->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
void Application::addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash) {
|
||||||
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.";
|
||||||
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
qWarning(interfaceapp) << "Error downloading asset: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromMapping(mapping), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else {
|
} else {
|
||||||
addAssetToWorldAddEntity(mapping);
|
addAssetToWorldAddEntity(filePath, mapping);
|
||||||
}
|
}
|
||||||
request->deleteLater();
|
request->deleteLater();
|
||||||
});
|
});
|
||||||
|
@ -5762,7 +5754,7 @@ void Application::addAssetToWorldSetMapping(QString mapping, QString hash) {
|
||||||
request->start();
|
request->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::addAssetToWorldAddEntity(QString mapping) {
|
void Application::addAssetToWorldAddEntity(QString filePath, QString mapping) {
|
||||||
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));
|
||||||
|
@ -5780,7 +5772,7 @@ void Application::addAssetToWorldAddEntity(QString mapping) {
|
||||||
if (entityID == QUuid()) {
|
if (entityID == QUuid()) {
|
||||||
QString errorInfo = "Could not add asset " + mapping + " to world.";
|
QString errorInfo = "Could not add asset " + mapping + " to world.";
|
||||||
qWarning(interfaceapp) << "Could not add asset to world: " + errorInfo;
|
qWarning(interfaceapp) << "Could not add asset to world: " + errorInfo;
|
||||||
addAssetToWorldError(filenameFromMapping(mapping), errorInfo);
|
addAssetToWorldError(filenameFromPath(filePath), errorInfo);
|
||||||
} else {
|
} else {
|
||||||
// Monitor when asset is rendered in world so that can resize if necessary.
|
// Monitor when asset is rendered in world so that can resize if necessary.
|
||||||
_addAssetToWorldResizeList.insert(entityID, 0); // List value is count of checks performed.
|
_addAssetToWorldResizeList.insert(entityID, 0); // List value is count of checks performed.
|
||||||
|
@ -5789,7 +5781,7 @@ void Application::addAssetToWorldAddEntity(QString mapping) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close progress message box.
|
// Close progress message box.
|
||||||
addAssetToWorldInfoDone(filenameFromMapping(mapping));
|
addAssetToWorldInfoDone(filenameFromPath(filePath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -317,10 +317,10 @@ public slots:
|
||||||
void addAssetToWorldFromURLRequestFinished();
|
void addAssetToWorldFromURLRequestFinished();
|
||||||
void addAssetToWorld(QString filePath);
|
void addAssetToWorld(QString filePath);
|
||||||
void addAssetToWorldUnzipFailure(QString filePath);
|
void addAssetToWorldUnzipFailure(QString filePath);
|
||||||
void addAssetToWorldWithNewMapping(QString path, QString mapping, int copy);
|
void addAssetToWorldWithNewMapping(QString filePath, QString mapping, int copy);
|
||||||
void addAssetToWorldUpload(QString path, QString mapping);
|
void addAssetToWorldUpload(QString filePath, QString mapping);
|
||||||
void addAssetToWorldSetMapping(QString mapping, QString hash);
|
void addAssetToWorldSetMapping(QString filePath, QString mapping, QString hash);
|
||||||
void addAssetToWorldAddEntity(QString mapping);
|
void addAssetToWorldAddEntity(QString filePath, QString mapping);
|
||||||
|
|
||||||
void handleUnzip(QString sourceFile, QString destinationFile, bool autoAdd);
|
void handleUnzip(QString sourceFile, QString destinationFile, bool autoAdd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue