History

rework ScriptValue to act like a stack variable rather than a pointer

Heather Anderson committed 5 years ago

Commit 85810221 parent f209c51170 files · +2837 −2594Browse files

Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 170 files). Show all

Unified · Split

interface/src/scripting/WindowScriptingInterface.cpp+15−15
@@ -76,7 +76,7 @@ WindowScriptingInterface::~WindowScriptingInterface() { · 75 unmodified lines
76 _messageBoxes.clear();76 _messageBoxes.clear();
77}77}
78 78
79ScriptValuePointer WindowScriptingInterface::hasFocus() {79ScriptValue WindowScriptingInterface::hasFocus() {
80 return engine()->newValue(qApp->hasFocus());80 return engine()->newValue(qApp->hasFocus());
81}81}
82 82
@@ -96,26 +96,26 @@ void WindowScriptingInterface::raise() { · 13 unmodified lines
96 96
97/// Display an alert box97/// Display an alert box
98/// \param const QString& message message to display98/// \param const QString& message message to display
99/// \return ScriptValuePointer::UndefinedValue99/// \return ScriptValue::UndefinedValue
100void WindowScriptingInterface::alert(const QString& message) {100void WindowScriptingInterface::alert(const QString& message) {
101 OffscreenUi::asyncWarning("", message, QMessageBox::Ok, QMessageBox::Ok);101 OffscreenUi::asyncWarning("", message, QMessageBox::Ok, QMessageBox::Ok);
102}102}
103 103
104/// Display a confirmation box with the options 'Yes' and 'No'104/// Display a confirmation box with the options 'Yes' and 'No'
105/// \param const QString& message message to display105/// \param const QString& message message to display
106/// \return ScriptValuePointer `true` if 'Yes' was clicked, `false` otherwise106/// \return ScriptValue `true` if 'Yes' was clicked, `false` otherwise
107ScriptValuePointer WindowScriptingInterface::confirm(const QString& message) {107ScriptValue WindowScriptingInterface::confirm(const QString& message) {
108 return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)));108 return engine()->newValue((QMessageBox::Yes == OffscreenUi::question("", message, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)));
109}109}
110 110
111/// Display a prompt with a text box111/// Display a prompt with a text box
112/// \param const QString& message message to display112/// \param const QString& message message to display
113/// \param const QString& defaultText default text in the text box113/// \param const QString& defaultText default text in the text box
114/// \return ScriptValuePointer string text value in text box if the dialog was accepted, `null` otherwise.114/// \return ScriptValue string text value in text box if the dialog was accepted, `null` otherwise.
115ScriptValuePointer WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {115ScriptValue WindowScriptingInterface::prompt(const QString& message, const QString& defaultText) {
116 QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);116 QString result = OffscreenUi::getText(nullptr, "", message, QLineEdit::Normal, defaultText);
117 auto sResult = engine()->newValue(result);117 auto sResult = engine()->newValue(result);
118 if (sResult->equals(engine()->newValue(""))) {118 if (sResult.equals(engine()->newValue(""))) {
119 return engine()->nullValue();119 return engine()->nullValue();
120 }120 }
121 return sResult;121 return sResult;
@@ -218,8 +218,8 @@ void WindowScriptingInterface::ensureReticleVisible() const { · 96 unmodified lines
218/// working directory.218/// working directory.
219/// \param const QString& title title of the window219/// \param const QString& title title of the window
220/// \param const QString& directory directory to start the directory browser at220/// \param const QString& directory directory to start the directory browser at
221/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue`221/// \return ScriptValue file path as a string if one was selected, otherwise `ScriptValue::NullValue`
222ScriptValuePointer WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {222ScriptValue WindowScriptingInterface::browseDir(const QString& title, const QString& directory) {
223 ensureReticleVisible();223 ensureReticleVisible();
224 QString path = directory;224 QString path = directory;
225 if (path.isEmpty()) {225 if (path.isEmpty()) {
@@ -262,8 +262,8 @@ void WindowScriptingInterface::browseDirAsync(const QString& title, const QStrin · 36 unmodified lines
262/// \param const QString& title title of the window262/// \param const QString& title title of the window
263/// \param const QString& directory directory to start the file browser at263/// \param const QString& directory directory to start the file browser at
264/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`264/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
265/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue`265/// \return ScriptValue file path as a string if one was selected, otherwise `ScriptValue::NullValue`
266ScriptValuePointer WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {266ScriptValue WindowScriptingInterface::browse(const QString& title, const QString& directory, const QString& nameFilter) {
267 ensureReticleVisible();267 ensureReticleVisible();
268 QString path = directory;268 QString path = directory;
269 if (path.isEmpty()) {269 if (path.isEmpty()) {
@@ -309,8 +309,8 @@ void WindowScriptingInterface::browseAsync(const QString& title, const QString& · 39 unmodified lines
309/// \param const QString& title title of the window309/// \param const QString& title title of the window
310/// \param const QString& directory directory to start the file browser at310/// \param const QString& directory directory to start the file browser at
311/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`311/// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog`
312/// \return ScriptValuePointer file path as a string if one was selected, otherwise `ScriptValuePointer::NullValue`312/// \return ScriptValue file path as a string if one was selected, otherwise `ScriptValue::NullValue`
313ScriptValuePointer WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {313ScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) {
314 ensureReticleVisible();314 ensureReticleVisible();
315 QString path = directory;315 QString path = directory;
316 if (path.isEmpty()) {316 if (path.isEmpty()) {
@@ -356,8 +356,8 @@ void WindowScriptingInterface::saveAsync(const QString& title, const QString& di · 39 unmodified lines
356/// \param const QString& title title of the window356/// \param const QString& title title of the window
357/// \param const QString& directory directory to start the asset browser at357/// \param const QString& directory directory to start the asset browser at
358/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`358/// \param const QString& nameFilter filter to filter asset names by - see `QFileDialog`
359/// \return ScriptValuePointer asset path as a string if one was selected, otherwise `ScriptValuePointer::NullValue`359/// \return ScriptValue asset path as a string if one was selected, otherwise `ScriptValue::NullValue`
360ScriptValuePointer WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {360ScriptValue WindowScriptingInterface::browseAssets(const QString& title, const QString& directory, const QString& nameFilter) {
361 ensureReticleVisible();361 ensureReticleVisible();
362 QString path = directory;362 QString path = directory;
363 if (path.isEmpty()) {363 if (path.isEmpty()) {