Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -116,11 +116,17 @@ QScriptValue WindowScriptingInterface::confirm(const QString& message) { · 115 unmodified lines | ||
| 116 | 116 | /// Display a prompt with a text box |
| 117 | 117 | /// \param const QString& message message to display |
| 118 | 118 | /// \param const QString& defaultText default text in the text box |
| 119 | −/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise. | |
| 120 | −QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { | |
| 121 | − bool ok = false; | |
| 122 | − QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText, &ok); | |
| 123 | − return ok ? QScriptValue(result) : QScriptValue::NullValue; | |
| 119 | +void WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { | |
| 120 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 121 | + connect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | |
| 122 | + this, [=] (QVariant result) { | |
| 123 | + auto offscreenUi = DependencyManager::get<OffscreenUi>(); | |
| 124 | + disconnect(offscreenUi.data(), &OffscreenUi::inputDialogResponse, | |
| 125 | + this, nullptr); | |
| 126 | + emit promptTextChanged(result.toString()); | |
| 127 | + }); | |
| 128 | + | |
| 129 | + OffscreenUi::getTextAsync(nullptr, "", message, QLineEdit::Normal, defaultText); | |
| 124 | 130 | } |
| 125 | 131 | |
| 126 | 132 | CustomPromptResult WindowScriptingInterface::customPrompt(const QVariant& config) { |