Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 7 files). Show all
Unified · Split
| @@ -127,16 +127,13 @@ QScriptValue WindowScriptingInterface::prompt(const QString& message, const QStr · 126 unmodified lines | |||
| 127 | /// \param const QString& message message to display | 127 | /// \param const QString& message message to display |
| 128 | /// \param const QString& defaultText default text in the text box | 128 | /// \param const QString& defaultText default text in the text box |
| 129 | void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) { | 129 | void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) { |
| 130 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 130 | ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText); |
| 131 | connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | 131 | connect(dlg, &ModalDialogListener::response, this, [=] (QVariant result) { |
| 132 | this, [=] (QVariant result) { | 132 | disconnect(dlg, &ModalDialogListener::response, this, nullptr); |
| 133 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | ||
| 134 | disconnect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | ||
| 135 | this, nullptr); | ||
| 136 | emit promptTextChanged(result.toString()); | 133 | emit promptTextChanged(result.toString()); |
| 137 | }); | 134 | }); |
| 138 | 135 | ||
| 139 | OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText); | 136 | |
| 140 | } | 137 | } |
| 141 | 138 | ||
| 142 | CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) { | 139 | CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) { |
| @@ -221,19 +218,15 @@ void WindowScriptingInterface::browseDirAsync(const QString& title, const QStrin · 78 unmodified lines | |||
| 221 | #ifndef Q_OS_WIN | 218 | #ifndef Q_OS_WIN |
| 222 | path = fixupPathForMac(directory); | 219 | path = fixupPathForMac(directory); |
| 223 | #endif | 220 | #endif |
| 224 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 221 | ModalDialogListener* dlg = OffscreenUi::getExistingDirectoryAsync(nullptr, title, path); |
| 225 | connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | 222 | connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { |
| 226 | this, [=] (QString result) { | 223 | const QString& result = response.toString(); |
| 227 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 224 | disconnect(dlg, &ModalDialogListener::response, this, nullptr); |
| 228 | disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | ||
| 229 | this, nullptr); | ||
| 230 | if (!result.isEmpty()) { | 225 | if (!result.isEmpty()) { |
| 231 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 226 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 232 | } | 227 | } |
| 233 | emit browseDirChanged(result); | 228 | emit browseDirChanged(result); |
| 234 | }); | 229 | }); |
| 235 | |||
| 236 | OffscreenUi::getExistingDirectoryAsync(nullptr, title, path); | ||
| 237 | } | 230 | } |
| 238 | 231 | ||
| 239 | /// \param const QString& title title of the window | 232 | /// \param const QString& title title of the window |
| @@ -270,19 +263,17 @@ void WindowScriptingInterface::browseAsync(const QString& title, const QString& · 30 unmodified lines | |||
| 270 | #ifndef Q_OS_WIN | 263 | #ifndef Q_OS_WIN |
| 271 | path = fixupPathForMac(directory); | 264 | path = fixupPathForMac(directory); |
| 272 | #endif | 265 | #endif |
| 273 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 266 | ModalDialogListener* dlg = OffscreenUi::getOpenFileNameAsync(nullptr, title, path, nameFilter); |
| 274 | connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | 267 | connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { |
| 275 | this, [=] (QString result) { | 268 | const QString& result = response.toString(); |
| 276 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 269 | disconnect(dlg, &ModalDialogListener::response, this, nullptr); |
| 277 | disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | ||
| 278 | this, nullptr); | ||
| 279 | if (!result.isEmpty()) { | 270 | if (!result.isEmpty()) { |
| 280 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 271 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 281 | } | 272 | } |
| 282 | emit openFileChanged(result); | 273 | emit openFileChanged(result); |
| 283 | }); | 274 | }); |
| 284 | 275 | ||
| 285 | OffscreenUi::getOpenFileNameAsync(nullptr, title, path, nameFilter); | 276 | |
| 286 | } | 277 | } |
| 287 | 278 | ||
| 288 | /// Display a save file dialog. If `directory` is an invalid file or directory the browser will start at the current | 279 | /// Display a save file dialog. If `directory` is an invalid file or directory the browser will start at the current |
| @@ -321,19 +312,17 @@ void WindowScriptingInterface::saveAsync(const QString& title, const QString& di · 32 unmodified lines | |||
| 321 | #ifndef Q_OS_WIN | 312 | #ifndef Q_OS_WIN |
| 322 | path = fixupPathForMac(directory); | 313 | path = fixupPathForMac(directory); |
| 323 | #endif | 314 | #endif |
| 324 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 315 | ModalDialogListener* dlg = OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter); |
| 325 | connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | 316 | connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { |
| 326 | this, [=] (QString result) { | 317 | const QString& result = response.toString(); |
| 327 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 318 | disconnect(dlg, &ModalDialogListener::response, this, nullptr); |
| 328 | disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | ||
| 329 | this, nullptr); | ||
| 330 | if (!result.isEmpty()) { | 319 | if (!result.isEmpty()) { |
| 331 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 320 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 332 | } | 321 | } |
| 333 | emit saveFileChanged(result); | 322 | emit saveFileChanged(result); |
| 334 | }); | 323 | }); |
| 335 | 324 | ||
| 336 | OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter); | 325 | |
| 337 | } | 326 | } |
| 338 | 327 | ||
| 339 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid | 328 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid |
| @@ -379,19 +368,15 @@ void WindowScriptingInterface::browseAssetsAsync(const QString& title, const QSt · 39 unmodified lines | |||
| 379 | path = path + "/"; | 368 | path = path + "/"; |
| 380 | } | 369 | } |
| 381 | 370 | ||
| 382 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 371 | ModalDialogListener* dlg = OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter); |
| 383 | connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | 372 | connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { |
| 384 | this, [=] (QString result) { | 373 | const QString& result = response.toString(); |
| 385 | auto offscreenUi = DependencyManager::get<OffscreenUi>(); | 374 | disconnect(dlg, &ModalDialogListener::response, this, nullptr); |
| 386 | disconnect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | ||
| 387 | this, nullptr); | ||
| 388 | if (!result.isEmpty()) { | 375 | if (!result.isEmpty()) { |
| 389 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); | 376 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); |
| 390 | } | 377 | } |
| 391 | emit assetsDirChanged(result); | 378 | emit assetsDirChanged(result); |
| 392 | }); | 379 | }); |
| 393 | |||
| 394 | OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter); | ||
| 395 | } | 380 | } |
| 396 | 381 | ||
| 397 | void WindowScriptingInterface::showAssetServer(const QString& upload) { | 382 | void WindowScriptingInterface::showAssetServer(const QString& upload) { |