Showing the changes to interface/src/scripting/AssetMappingsScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -80,11 +80,16 @@ void AssetMappingsScriptingInterface::getMapping(QString path, QJSValue callback · 79 unmodified lines | |||
| 80 | request->start(); | 80 | request->start(); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue callback) { | 83 | void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, QJSValue startedCallback, QJSValue completedCallback) { |
| 84 | static const QString helpText = | ||
| 85 | "Upload your asset to a specific folder by enter the full path. Specifying " | ||
| 86 | "a new folder name will automatically create that folder for you."; | ||
| 87 | |||
| 84 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 88 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 85 | auto result = offscreenUi->inputDialog(OffscreenUi::ICON_NONE, "Enter asset path:", "", mapping); | 89 | auto result = offscreenUi->inputDialog(OffscreenUi::ICON_INFORMATION, "Specify Asset Path", helpText, mapping); |
| 86 | 90 | ||
| 87 | if (!result.isValid()) { | 91 | if (!result.isValid()) { |
| 92 | completedCallback.call({ -1 }); | ||
| 88 | return; | 93 | return; |
| 89 | } | 94 | } |
| 90 | mapping = result.toString(); | 95 | mapping = result.toString(); |
| @@ -100,19 +105,22 @@ void AssetMappingsScriptingInterface::uploadFile(QString path, QString mapping, · 9 unmodified lines | |||
| 100 | auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "Overwrite File", message, | 105 | auto button = offscreenUi->messageBox(OffscreenUi::ICON_QUESTION, "Overwrite File", message, |
| 101 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); | 106 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
| 102 | if (button == QMessageBox::No) { | 107 | if (button == QMessageBox::No) { |
| 108 | completedCallback.call({ -1 }); | ||
| 103 | return; | 109 | return; |
| 104 | } | 110 | } |
| 105 | } | 111 | } |
| 106 | 112 | ||
| 113 | startedCallback.call(); | ||
| 114 | |||
| 107 | auto upload = DependencyManager::get<AssetClient>()->createUpload(path); | 115 | auto upload = DependencyManager::get<AssetClient>()->createUpload(path); |
| 108 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { | 116 | QObject::connect(upload, &AssetUpload::finished, this, [=](AssetUpload* upload, const QString& hash) mutable { |
| 109 | if (upload->getError() != AssetUpload::NoError) { | 117 | if (upload->getError() != AssetUpload::NoError) { |
| 110 | if (callback.isCallable()) { | 118 | if (completedCallback.isCallable()) { |
| 111 | QJSValueList args { uint8_t(upload->getError()) }; | 119 | QJSValueList args { uint8_t(upload->getError()) }; |
| 112 | callback.call(args); | 120 | completedCallback.call(args); |
| 113 | } | 121 | } |
| 114 | } else { | 122 | } else { |
| 115 | setMapping(mapping, hash, callback); | 123 | setMapping(mapping, hash, completedCallback); |
| 116 | } | 124 | } |
| 117 | 125 | ||
| 118 | upload->deleteLater(); | 126 | upload->deleteLater(); |
| @@ -198,6 +206,7 @@ AssetMappingItem::AssetMappingItem(const QString& name, const QString& fullPath, · 79 unmodified lines | |||
| 198 | 206 | ||
| 199 | } | 207 | } |
| 200 | 208 | ||
| 209 | |||
| 201 | static int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*"); | 210 | static int assetMappingModelMetatypeId = qRegisterMetaType<AssetMappingModel*>("AssetMappingModel*"); |
| 202 | 211 | ||
| 203 | void AssetMappingModel::refresh() { | 212 | void AssetMappingModel::refresh() { |