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 | /// \param const QString& title title of the window | 247 | /// \param const QString& title title of the window |
| 248 | /// \param const QString& directory directory to start the asset browser at | 248 | /// \param const QString& directory directory to start the asset browser at |
| 249 | /// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog` | 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` | 250 | void WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { |
| 251 | QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { | ||
| 252 | ensureReticleVisible(); | 251 | ensureReticleVisible(); |
| 253 | QString path = directory; | 252 | QString path = directory; |
| 254 | if (path.isEmpty()) { | 253 | if (path.isEmpty()) { |
| @@ -260,11 +259,20 @@ QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const · 5 unmodified lines | |||
| 260 | if (path.right(1) != "/") { | 259 | if (path.right(1) != "/") { |
| 261 | path = path + "/"; | 260 | path = path + "/"; |
| 262 | } | 261 | } |
| 263 | QString result = OffscreenUi::getOpenAssetName(nullptr, title, path, nameFilter); | 262 | |
| 264 | if (!result.isEmpty()) { | 263 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 265 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); | 264 | connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, |
| 266 | } | 265 | this, [=] (QString result) { |
| 267 | return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(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 | void WindowScriptingInterface::showAssetServer(const QString& upload) { | 278 | void WindowScriptingInterface::showAssetServer(const QString& upload) { |