Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -247,8 +247,7 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 246 unmodified lines | ||
| 247 | 247 | /// \param const QString& title title of the window |
| 248 | 248 | /// \param const QString& directory directory to start the asset browser at |
| 249 | 249 | /// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog` |
| 250 | −/// \return QScriptValue asset path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 251 | −QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 250 | +void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 252 | 251 | ensureReticleVisible(); |
| 253 | 252 | QString path = directory; |
| 254 | 253 | if (path.isEmpty()) { |
| @@ -260,11 +259,20 @@ QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const · 5 unmodified lines | ||
| 260 | 259 | if (path.right(1) != "/") { |
| 261 | 260 | path = path + "/"; |
| 262 | 261 | } |
| 263 | − QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter); | |
| 264 | − if (!result.isEmpty()) { | |
| 265 | − setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); | |
| 266 | − } | |
| 267 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 262 | + | |
| 263 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 264 | + connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | |
| 265 | + this, [=] (QString result) { | |
| 266 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 267 | + disconnect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | |
| 268 | + this, nullptr); | |
| 269 | + if (!result.isEmpty()) { | |
| 270 | + setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); | |
| 271 | + } | |
| 272 | + emit assetsDirChanged(result); | |
| 273 | + }); | |
| 274 | + | |
| 275 | + OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter); | |
| 268 | 276 | } |
| 269 | 277 | |
| 270 | 278 | void WindowScriptingInterface::showAssetServer(const QString& upload) { |