Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -18,6 +18,7 @@ · 17 unmodified lines | |||
| 18 | 18 | ||
| 19 | #include "Application.h" | 19 | #include "Application.h" |
| 20 | #include "Menu.h" | 20 | #include "Menu.h" |
| 21 | #include "ui/ModelsBrowser.h" | ||
| 21 | 22 | ||
| 22 | #include "WindowScriptingInterface.h" | 23 | #include "WindowScriptingInterface.h" |
| 23 | 24 | ||
| @@ -66,6 +67,14 @@ QScriptValue WindowScriptingInterface::browse(const QString& title, const QStrin · 42 unmodified lines | |||
| 66 | return retVal; | 67 | return retVal; |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 70 | QScriptValue WindowScriptingInterface::s3Browse(const QString& nameFilter) { | ||
| 71 | QScriptValue retVal; | ||
| 72 | QMetaObject::invokeMethod(this, "showS3Browse", Qt::BlockingQueuedConnection, | ||
| 73 | Q_RETURN_ARG(QScriptValue, retVal), | ||
| 74 | Q_ARG(const QString&, nameFilter)); | ||
| 75 | return retVal; | ||
| 76 | } | ||
| 77 | |||
| 69 | /// Display an alert box | 78 | /// Display an alert box |
| 70 | /// \param const QString& message message to display | 79 | /// \param const QString& message message to display |
| 71 | /// \return QScriptValue::UndefinedValue | 80 | /// \return QScriptValue::UndefinedValue |
| @@ -182,7 +191,7 @@ QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QS · 110 unmodified lines | |||
| 182 | fileInfo.setFile(directory, "__HIFI_INVALID_FILE__"); | 191 | fileInfo.setFile(directory, "__HIFI_INVALID_FILE__"); |
| 183 | path = fileInfo.filePath(); | 192 | path = fileInfo.filePath(); |
| 184 | } | 193 | } |
| 185 | 194 | ||
| 186 | QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter); | 195 | QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter); |
| 187 | fileDialog.setFileMode(QFileDialog::ExistingFile); | 196 | fileDialog.setFileMode(QFileDialog::ExistingFile); |
| 188 | if (fileDialog.exec()) { | 197 | if (fileDialog.exec()) { |
| @@ -191,6 +200,20 @@ QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QS · 2 unmodified lines | |||
| 191 | return QScriptValue::NullValue; | 200 | return QScriptValue::NullValue; |
| 192 | } | 201 | } |
| 193 | 202 | ||
| 203 | /// Display a browse window for S3 models | ||
| 204 | /// \param const QString& nameFilter filter to filter filenames | ||
| 205 | /// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | ||
| 206 | QScriptValue WindowScriptingInterface::showS3Browse(const QString& nameFilter) { | ||
| 207 | ModelsBrowser browser(ENTITY_MODEL); | ||
| 208 | browser.setNameFilter(nameFilter); | ||
| 209 | QEventLoop loop; | ||
| 210 | connect(&browser, &ModelsBrowser::selected, &loop, &QEventLoop::quit); | ||
| 211 | QMetaObject::invokeMethod(&browser, "browse", Qt::QueuedConnection); | ||
| 212 | loop.exec(); | ||
| 213 | |||
| 214 | return browser.getSelectedFile(); | ||
| 215 | } | ||
| 216 | |||
| 194 | int WindowScriptingInterface::getInnerWidth() { | 217 | int WindowScriptingInterface::getInnerWidth() { |
| 195 | return Application::getInstance()->getWindow()->geometry().width(); | 218 | return Application::getInstance()->getWindow()->geometry().width(); |
| 196 | } | 219 | } |