Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -225,8 +225,7 @@ QScriptValue WindowScriptingInterface::browse(const QString& title, const QStrin · 224 unmodified lines | ||
| 225 | 225 | /// \param const QString& title title of the window |
| 226 | 226 | /// \param const QString& directory directory to start the file browser at |
| 227 | 227 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` |
| 228 | −/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 229 | −QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 228 | +void WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 230 | 229 | ensureReticleVisible(); |
| 231 | 230 | QString path = directory; |
| 232 | 231 | if (path.isEmpty()) { |
| @@ -235,11 +234,19 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 2 unmodified lines | ||
| 235 | 234 | #ifndef Q_OS_WIN |
| 236 | 235 | path = fixupPathForMac(directory); |
| 237 | 236 | #endif |
| 238 | − QString result = OffscreenUi::getSaveFileName(nullptr, title, path, nameFilter); | |
| 239 | − if (!result.isEmpty()) { | |
| 240 | − setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | |
| 241 | − } | |
| 242 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 237 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 238 | + connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 239 | + this, [=] (QString result) { | |
| 240 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 241 | + disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 242 | + this, nullptr); | |
| 243 | + if (!result.isEmpty()) { | |
| 244 | + setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | |
| 245 | + } | |
| 246 | + emit saveFileChanged(result); | |
| 247 | + }); | |
| 248 | + | |
| 249 | + OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter); | |
| 243 | 250 | } |
| 244 | 251 | |
| 245 | 252 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid |