Resolved conflicts in editModels.js
Showing the changes to interface/src/scripting/WindowScriptingInterface.cpp (1 of 304 files). Show all
Unified · Split
| @@ -67,6 +67,15 @@ QScriptValue WindowScriptingInterface::browse(const QString& title, const QStrin · 66 unmodified lines | |||
| 67 | return retVal; | 67 | return retVal; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | QScriptValue WindowScriptingInterface::save(const QString& title, const QString& directory, const QString& nameFilter) { | ||
| 71 | QScriptValue retVal; | ||
| 72 | QMetaObject::invokeMethod(this, "showBrowse", Qt::BlockingQueuedConnection, | ||
| 73 | Q_RETURN_ARG(QScriptValue, retVal), | ||
| 74 | Q_ARG(const QString&, title), Q_ARG(const QString&, directory), Q_ARG(const QString&, nameFilter), | ||
| 75 | Q_ARG(QFileDialog::AcceptMode, QFileDialog::AcceptSave)); | ||
| 76 | return retVal; | ||
| 77 | } | ||
| 78 | |||
| 70 | QScriptValue WindowScriptingInterface::s3Browse(const QString& nameFilter) { | 79 | QScriptValue WindowScriptingInterface::s3Browse(const QString& nameFilter) { |
| 71 | QScriptValue retVal; | 80 | QScriptValue retVal; |
| 72 | QMetaObject::invokeMethod(this, "showS3Browse", Qt::BlockingQueuedConnection, | 81 | QMetaObject::invokeMethod(this, "showS3Browse", Qt::BlockingQueuedConnection, |
| @@ -280,18 +289,26 @@ QScriptValue WindowScriptingInterface::showPrompt(const QString& message, const · 207 unmodified lines | |||
| 280 | /// \param const QString& directory directory to start the file browser at | 289 | /// \param const QString& directory directory to start the file browser at |
| 281 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` | 290 | /// \param const QString& nameFilter filter to filter filenames by - see `QFileDialog` |
| 282 | /// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` | 291 | /// \return QScriptValue file path as a string if one was selected, otherwise `QScriptValue::NullValue` |
| 283 | QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QString& directory, const QString& nameFilter) { | 292 | QScriptValue WindowScriptingInterface::showBrowse(const QString& title, const QString& directory, const QString& nameFilter, |
| 293 | QFileDialog::AcceptMode acceptMode) { | ||
| 284 | // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus | 294 | // On OS X `directory` does not work as expected unless a file is included in the path, so we append a bogus |
| 285 | // filename if the directory is valid. | 295 | // filename if the directory is valid. |
| 286 | QString path = ""; | 296 | QString path = ""; |
| 287 | QFileInfo fileInfo = QFileInfo(directory); | 297 | QFileInfo fileInfo = QFileInfo(directory); |
| 298 | qDebug() << "File: " << directory << fileInfo.isFile(); | ||
| 288 | if (fileInfo.isDir()) { | 299 | if (fileInfo.isDir()) { |
| 289 | fileInfo.setFile(directory, "__HIFI_INVALID_FILE__"); | 300 | fileInfo.setFile(directory, "__HIFI_INVALID_FILE__"); |
| 290 | path = fileInfo.filePath(); | 301 | path = fileInfo.filePath(); |
| 291 | } | 302 | } |
| 292 | 303 | ||
| 293 | QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter); | 304 | QFileDialog fileDialog(Application::getInstance()->getWindow(), title, path, nameFilter); |
| 294 | fileDialog.setFileMode(QFileDialog::ExistingFile); | 305 | fileDialog.setAcceptMode(acceptMode); |
| 306 | qDebug() << "Opening!"; | ||
| 307 | QUrl fileUrl(directory); | ||
| 308 | if (acceptMode == QFileDialog::AcceptSave) { | ||
| 309 | fileDialog.setFileMode(QFileDialog::Directory); | ||
| 310 | fileDialog.selectFile(fileUrl.fileName()); | ||
| 311 | } | ||
| 295 | if (fileDialog.exec()) { | 312 | if (fileDialog.exec()) { |
| 296 | return QScriptValue(fileDialog.selectedFiles().first()); | 313 | return QScriptValue(fileDialog.selectedFiles().first()); |
| 297 | } | 314 | } |