Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 14 files). Show all
Unified · Split
| @@ -77,6 +77,7 @@ WindowScriptingInterface::~WindowScriptingInterface() { · 76 unmodified lines | |||
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | ScriptValue WindowScriptingInterface::hasFocus() { | 79 | ScriptValue WindowScriptingInterface::hasFocus() { |
| 80 | Q_ASSERT(engine); | ||
| 80 | return engine()->newValue(qApp->hasFocus()); | 81 | return engine()->newValue(qApp->hasFocus()); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| @@ -105,6 +106,7 @@ void WindowScriptingInterface::alert(const QString& message) { · 22 unmodified lines | |||
| 105 | /// \param const QString& message message to display | 106 | /// \param const QString& message message to display |
| 106 | /// \return ScriptValue `true` if 'Yes' was clicked, `false` otherwise | 107 | /// \return ScriptValue `true` if 'Yes' was clicked, `false` otherwise |
| 107 | ScriptValue WindowScriptingInterface::confirm(const QString& message) { | 108 | ScriptValue WindowScriptingInterface::confirm(const QString& message) { |
| 109 | Q_ASSERT(engine); | ||
| 108 | return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))); | 110 | return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))); |
| 109 | } | 111 | } |
| 110 | 112 | ||
| @@ -114,6 +116,7 @@ ScriptValue WindowScriptingInterface::confirm(const QString& message) { · 3 unmodified lines | |||
| 114 | /// \return ScriptValue string text value in text box if the dialog was accepted, `null` otherwise. | 116 | /// \return ScriptValue string text value in text box if the dialog was accepted, `null` otherwise. |
| 115 | ScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { | 117 | ScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { |
| 116 | QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText); | 118 | QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText); |
| 119 | Q_ASSERT(engine); | ||
| 117 | auto sResult = engine()->newValue(result); | 120 | auto sResult = engine()->newValue(result); |
| 118 | if (sResult.equals(engine()->newValue(""))) { | 121 | if (sResult.equals(engine()->newValue(""))) { |
| 119 | return engine()->nullValue(); | 122 | return engine()->nullValue(); |
| @@ -232,6 +235,7 @@ ScriptValue WindowScriptingInterface::browseDir(const QString& title, const QStr · 112 unmodified lines | |||
| 232 | if (!result.isEmpty()) { | 235 | if (!result.isEmpty()) { |
| 233 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 236 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 234 | } | 237 | } |
| 238 | Q_ASSERT(engine); | ||
| 235 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | 239 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); |
| 236 | } | 240 | } |
| 237 | 241 | ||
| @@ -276,6 +280,7 @@ ScriptValue WindowScriptingInterface::browse(const QString& title, const QString · 38 unmodified lines | |||
| 276 | if (!result.isEmpty()) { | 280 | if (!result.isEmpty()) { |
| 277 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 281 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 278 | } | 282 | } |
| 283 | Q_ASSERT(engine); | ||
| 279 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | 284 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); |
| 280 | } | 285 | } |
| 281 | 286 | ||
| @@ -323,6 +328,7 @@ ScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 41 unmodified lines | |||
| 323 | if (!result.isEmpty()) { | 328 | if (!result.isEmpty()) { |
| 324 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); | 329 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 325 | } | 330 | } |
| 331 | Q_ASSERT(engine); | ||
| 326 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | 332 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); |
| 327 | } | 333 | } |
| 328 | 334 | ||
| @@ -373,6 +379,7 @@ ScriptValue WindowScriptingInterface::browseAssets(const QString& title, const Q · 44 unmodified lines | |||
| 373 | if (!result.isEmpty()) { | 379 | if (!result.isEmpty()) { |
| 374 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); | 380 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); |
| 375 | } | 381 | } |
| 382 | Q_ASSERT(engine); | ||
| 376 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | 383 | return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); |
| 377 | } | 384 | } |
| 378 | 385 | ||