Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 260 files). Show all
Unified · Split
| @@ -14,7 +14,7 @@ · 13 unmodified lines | ||
| 14 | 14 | #include <QClipboard> |
| 15 | 15 | #include <QtCore/QDir> |
| 16 | 16 | #include <QMessageBox> |
| 17 | −#include <QtScript/QScriptValue> | |
| 17 | +#include <ScriptValue.h> | |
| 18 | 18 | #include <QtGui/QDesktopServices> |
| 19 | 19 | #include <shared/QtHelpers.h> |
| 20 | 20 | #include <SettingHandle.h> |
| @@ -76,8 +76,8 @@ WindowScriptingInterface::~WindowScriptingInterface() { · 55 unmodified lines | ||
| 76 | 76 | _messageBoxes.clear(); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | −QScriptValue WindowScriptingInterface::hasFocus() { | |
| 80 | − return qApp->hasFocus(); | |
| 79 | +ScriptValuePointer WindowScriptingInterface::hasFocus() { | |
| 80 | + return engine()->newValue(qApp->hasFocus()); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | void WindowScriptingInterface::setFocus() { |
| @@ -96,28 +96,29 @@ void WindowScriptingInterface::raise() { · 12 unmodified lines | ||
| 96 | 96 | |
| 97 | 97 | /// Display an alert box |
| 98 | 98 | /// \param const QString& message message to display |
| 99 | −/// \return QScriptValue::UndefinedValue | |
| 99 | +/// \return ScriptValuePointer::UndefinedValue | |
| 100 | 100 | void WindowScriptingInterface::alert(const QString& message) { |
| 101 | 101 | OffscreenUi::asyncWarning("", message, QMessageBox::Ok, QMessageBox::Ok); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /// Display a confirmation box with the options 'Yes' and 'No' |
| 105 | 105 | /// \param const QString& message message to display |
| 106 | −/// \return QScriptValue `true` if 'Yes' was clicked, `false` otherwise | |
| 107 | −QScriptValue WindowScriptingInterface::confirm(const QString& message) { | |
| 108 | − return QScriptValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))); | |
| 106 | +/// \return ScriptValuePointer `true` if 'Yes' was clicked, `false` otherwise | |
| 107 | +ScriptValuePointer WindowScriptingInterface::confirm(const QString& message) { | |
| 108 | + return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes))); | |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | /// Display a prompt with a text box |
| 112 | 112 | /// \param const QString& message message to display |
| 113 | 113 | /// \param const QString& defaultText default text in the text box |
| 114 | −/// \return QScriptValue string text value in text box if the dialog was accepted, `null` otherwise. | |
| 115 | −QScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { | |
| 114 | +/// \return ScriptValuePointer string text value in text box if the dialog was accepted, `null` otherwise. | |
| 115 | +ScriptValuePointer WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) { | |
| 116 | 116 | QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText); |
| 117 | − if (QScriptValue(result).equals("")) { | |
| 118 | − return QScriptValue::NullValue; | |
| 117 | + auto sResult = engine()->newValue(result); | |
| 118 | + if (sResult->equals(engine()->newValue(""))) { | |
| 119 | + return engine()->nullValue(); | |
| 119 | 120 | } |
| 120 | − return QScriptValue(result); | |
| 121 | + return sResult; | |
| 121 | 122 | } |
| 122 | 123 | |
| 123 | 124 | /// Display a prompt with a text box |
| @@ -217,8 +218,8 @@ void WindowScriptingInterface::ensureReticleVisible() const { · 93 unmodified lines | ||
| 217 | 218 | /// working directory. |
| 218 | 219 | /// \param const QString& title title of the window |
| 219 | 220 | /// \param const QString& directory directory to start the directory browser at |
| 220 | −/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 221 | −QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) { | |
| 221 | +/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue` | |
| 222 | +ScriptValuePointer WindowScriptingInterface::browseDir(const QString& title, const QString& directory) { | |
| 222 | 223 | ensureReticleVisible(); |
| 223 | 224 | QString path = directory; |
| 224 | 225 | if (path.isEmpty()) { |
| @@ -231,7 +232,7 @@ QScriptValue WindowScriptingInterface::browseDir(const QString& title, const QSt · 6 unmodified lines | ||
| 231 | 232 | if (!result.isEmpty()) { |
| 232 | 233 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 233 | 234 | } |
| 234 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 235 | + return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | |
| 235 | 236 | } |
| 236 | 237 | |
| 237 | 238 | /// Display a "browse to directory" dialog. If `directory` is an invalid file or directory the browser will start at the current |
| @@ -261,8 +262,8 @@ void WindowScriptingInterface::browseDirAsync(const QString& title, const QStrin · 23 unmodified lines | ||
| 261 | 262 | /// \param const QString& title title of the window |
| 262 | 263 | /// \param const QString& directory directory to start the file browser at |
| 263 | 264 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` |
| 264 | −/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 265 | −QScriptValue WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 265 | +/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue` | |
| 266 | +ScriptValuePointer WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 266 | 267 | ensureReticleVisible(); |
| 267 | 268 | QString path = directory; |
| 268 | 269 | if (path.isEmpty()) { |
| @@ -275,7 +276,7 @@ QScriptValue WindowScriptingInterface::browse(const QString& title, const QStrin · 6 unmodified lines | ||
| 275 | 276 | if (!result.isEmpty()) { |
| 276 | 277 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 277 | 278 | } |
| 278 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 279 | + return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | |
| 279 | 280 | } |
| 280 | 281 | |
| 281 | 282 | /// Display an open file dialog. If `directory` is an invalid file or directory the browser will start at the current |
| @@ -308,8 +309,8 @@ void WindowScriptingInterface::browseAsync(const QString& title, const QString& · 26 unmodified lines | ||
| 308 | 309 | /// \param const QString& title title of the window |
| 309 | 310 | /// \param const QString& directory directory to start the file browser at |
| 310 | 311 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` |
| 311 | −/// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 312 | −QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 312 | +/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue` | |
| 313 | +ScriptValuePointer WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 313 | 314 | ensureReticleVisible(); |
| 314 | 315 | QString path = directory; |
| 315 | 316 | if (path.isEmpty()) { |
| @@ -322,7 +323,7 @@ QScriptValue WindowScriptingInterface::save(const QString& title, const QString& · 6 unmodified lines | ||
| 322 | 323 | if (!result.isEmpty()) { |
| 323 | 324 | setPreviousBrowseLocation(QFileInfo(result).absolutePath()); |
| 324 | 325 | } |
| 325 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 326 | + return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | |
| 326 | 327 | } |
| 327 | 328 | |
| 328 | 329 | /// Display a save file dialog. If `directory` is an invalid file or directory the browser will start at the current |
| @@ -355,8 +356,8 @@ void WindowScriptingInterface::saveAsync(const QString& title, const QString& di · 26 unmodified lines | ||
| 355 | 356 | /// \param const QString& title title of the window |
| 356 | 357 | /// \param const QString& directory directory to start the asset browser at |
| 357 | 358 | /// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog` |
| 358 | −/// \return QScriptValue asset path as a string if one was selected, otherwise `QScriptValue::NullValue` | |
| 359 | −QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 359 | +/// \return ScriptValuePointer asset path as a string if one was selected, otherwise `ScriptValuePointer::NullValue` | |
| 360 | +ScriptValuePointer WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) { | |
| 360 | 361 | ensureReticleVisible(); |
| 361 | 362 | QString path = directory; |
| 362 | 363 | if (path.isEmpty()) { |
| @@ -372,7 +373,7 @@ QScriptValue WindowScriptingInterface::browseAssets(const QString& title, const · 9 unmodified lines | ||
| 372 | 373 | if (!result.isEmpty()) { |
| 373 | 374 | setPreviousBrowseAssetLocation(QFileInfo(result).absolutePath()); |
| 374 | 375 | } |
| 375 | − return result.isEmpty() ? QScriptValue::NullValue : QScriptValue(result); | |
| 376 | + return result.isEmpty() ? engine()->nullValue() : engine()->newValue(result); | |
| 376 | 377 | } |
| 377 | 378 | |
| 378 | 379 | /// Display a select asset dialog that lets the user select an asset from the Asset Server. If `directory` is an invalid |