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 | /// \param const QString& title title of the window | 225 | /// \param const QString& title title of the window |
| 226 | /// \param const QString& directory directory to start the file browser at | 226 | /// \param const QString& directory directory to start the file browser at |
| 227 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` | 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` | 228 | void WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { |
| 229 | QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | ||
| 230 | ensureReticleVisible(); | 229 | ensureReticleVisible(); |
| 231 | QString path = directory; | 230 | QString path = directory; |
| 232 | if (path.isEmpty()) { | 231 | if (path.isEmpty()) { |
| @@ -235,11 +234,19 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 2 unmodified lines | |||
| 235 | #ifndef Q_OS_WIN | 234 | #ifndef Q_OS_WIN |
| 236 | path = fixupPathForMac(directory); | 235 | path = fixupPathForMac(directory); |
| 237 | #endif | 236 | #endif |
| 238 | QString result = OffscreenUi::getSaveFileName(nullptr, title, path, nameFilter); | 237 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 239 | if (!result.isEmpty()) { | 238 | connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, |
| 240 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 239 | this, [=] (QString result) { |
| 241 | } | 240 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); |
| 242 | return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | 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 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid | 252 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid |