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 | 127 | /// \param const QString& message message to display |
| 128 | 128 | /// \param const QString& defaultText default text in the text box |
| 129 | 129 | void WindowScriptingInterface::promptAsync(const QString& message, const QString& defaultText) { |
| 130 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 131 | − connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | |
| 132 | − this, [=] (QVariant result) { | |
| 133 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 134 | − disconnect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | |
| 135 | − this, nullptr); | |
| 130 | + ModalDialogListener* dlg = OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText); | |
| 131 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant result) { | |
| 132 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 136 | 133 | emit promptTextChanged(result.toString()); |
| 137 | 134 | }); |
| 138 | 135 | |
| 139 | − OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText); | |
| 136 | + | |
| 140 | 137 | } |
| 141 | 138 | |
| 142 | 139 | CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) { |
| @@ -221,19 +218,15 @@ void WindowScriptingInterface::browseDirAsync(const QString& title, const QStrin · 78 unmodified lines | ||
| 221 | 218 | #ifndef Q_OS_WIN |
| 222 | 219 | path = fixupPathForMac(directory); |
| 223 | 220 | #endif |
| 224 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 225 | − connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 226 | − this, [=] (QString result) { | |
| 227 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 228 | − disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 229 | − this, nullptr); | |
| 221 | + ModalDialogListener* dlg = OffscreenUi::getExistingDirectoryAsync(nullptr, title, path); | |
| 222 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { | |
| 223 | + const QString& result = response.toString(); | |
| 224 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 230 | 225 | if (!result.isEmpty()) { |
| 231 | 226 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 232 | 227 | } |
| 233 | 228 | emit browseDirChanged(result); |
| 234 | 229 | }); |
| 235 | − | |
| 236 | − OffscreenUi::getExistingDirectoryAsync(nullptr, title, path); | |
| 237 | 230 | } |
| 238 | 231 | |
| 239 | 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 | 263 | #ifndef Q_OS_WIN |
| 271 | 264 | path = fixupPathForMac(directory); |
| 272 | 265 | #endif |
| 273 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 274 | − connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 275 | − this, [=] (QString result) { | |
| 276 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 277 | − disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 278 | − this, nullptr); | |
| 266 | + ModalDialogListener* dlg = OffscreenUi::getOpenFileNameAsync(nullptr, title, path, nameFilter); | |
| 267 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { | |
| 268 | + const QString& result = response.toString(); | |
| 269 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 279 | 270 | if (!result.isEmpty()) { |
| 280 | 271 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 281 | 272 | } |
| 282 | 273 | emit openFileChanged(result); |
| 283 | 274 | }); |
| 284 | 275 | |
| 285 | − OffscreenUi::getOpenFileNameAsync(nullptr, title, path, nameFilter); | |
| 276 | + | |
| 286 | 277 | } |
| 287 | 278 | |
| 288 | 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 | 312 | #ifndef Q_OS_WIN |
| 322 | 313 | path = fixupPathForMac(directory); |
| 323 | 314 | #endif |
| 324 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 325 | − connect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 326 | − this, [=] (QString result) { | |
| 327 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 328 | − disconnect(offscreenUi.data(), &OffscreenUi::fileDialogResponse, | |
| 329 | − this, nullptr); | |
| 315 | + ModalDialogListener* dlg = OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter); | |
| 316 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { | |
| 317 | + const QString& result = response.toString(); | |
| 318 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 330 | 319 | if (!result.isEmpty()) { |
| 331 | 320 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 332 | 321 | } |
| 333 | 322 | emit saveFileChanged(result); |
| 334 | 323 | }); |
| 335 | 324 | |
| 336 | − OffscreenUi::getSaveFileNameAsync(nullptr, title, path, nameFilter); | |
| 325 | + | |
| 337 | 326 | } |
| 338 | 327 | |
| 339 | 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 | 368 | path = path + "/"; |
| 380 | 369 | } |
| 381 | 370 | |
| 382 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 383 | − connect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | |
| 384 | − this, [=] (QString result) { | |
| 385 | − auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 386 | − disconnect(offscreenUi.data(), &OffscreenUi::assetDialogResponse, | |
| 387 | − this, nullptr); | |
| 371 | + ModalDialogListener* dlg = OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter); | |
| 372 | + connect(dlg, &ModalDialogListener::response, this, [=] (QVariant response) { | |
| 373 | + const QString& result = response.toString(); | |
| 374 | + disconnect(dlg, &ModalDialogListener::response, this, nullptr); | |
| 388 | 375 | if (!result.isEmpty()) { |
| 389 | 376 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); |
| 390 | 377 | } |
| 391 | 378 | emit assetsDirChanged(result); |
| 392 | 379 | }); |
| 393 | − | |
| 394 | − OffscreenUi::getOpenAssetNameAsync(nullptr, title, path, nameFilter); | |
| 395 | 380 | } |
| 396 | 381 | |
| 397 | 382 | void WindowScriptingInterface::showAssetServer(const QString& upload) { |