262 lines
9.6 KiB
Diff
262 lines
9.6 KiB
Diff
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
|
|
index 9219757..4464b94 100644
|
|
--- a/src/widgets/dialogs/qfiledialog.cpp
|
|
+++ b/src/widgets/dialogs/qfiledialog.cpp
|
|
@@ -2100,35 +2100,9 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
|
|
QString *selectedFilter,
|
|
Options options)
|
|
{
|
|
- QFileDialogArgs args;
|
|
- args.parent = parent;
|
|
- args.caption = caption;
|
|
- args.directory = QFileDialogPrivate::workingDirectory(dir);
|
|
- args.selection = QFileDialogPrivate::initialSelection(dir);
|
|
- args.filter = filter;
|
|
- args.mode = ExistingFile;
|
|
- args.options = options;
|
|
-#if defined(Q_WS_WIN)
|
|
- if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {
|
|
- return qt_win_get_open_file_name(args, &(args.directory), selectedFilter);
|
|
- }
|
|
-#endif
|
|
-
|
|
- // create a qt dialog
|
|
- QFileDialog dialog(args);
|
|
- if (selectedFilter && !selectedFilter->isEmpty())
|
|
- dialog.selectNameFilter(*selectedFilter);
|
|
- if (dialog.exec() == QDialog::Accepted) {
|
|
- if (selectedFilter)
|
|
- *selectedFilter = dialog.selectedNameFilter();
|
|
- return dialog.selectedFiles().value(0);
|
|
- }
|
|
- return QString();
|
|
-}
|
|
-
|
|
-static inline QUrl dialogResultToUrl(const QString &file)
|
|
-{
|
|
- return file.isEmpty() ? QUrl() : QUrl::fromLocalFile(file);
|
|
+ const QStringList schemes = QStringList(QStringLiteral("file"));
|
|
+ const QUrl selectedUrl = getOpenFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes);
|
|
+ return selectedUrl.toLocalFile();
|
|
}
|
|
|
|
/*!
|
|
@@ -2166,10 +2140,26 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
|
|
Options options,
|
|
const QStringList &supportedSchemes)
|
|
{
|
|
- Q_UNUSED(supportedSchemes);
|
|
+ Q_UNUSED(supportedSchemes); // TODO
|
|
+
|
|
+ QFileDialogArgs args;
|
|
+ args.parent = parent;
|
|
+ args.caption = caption;
|
|
+ args.directory = QFileDialogPrivate::workingDirectory(QUrl::fromLocalFile(dir));
|
|
+ args.selection = QFileDialogPrivate::initialSelection(QUrl::fromLocalFile(dir));
|
|
+ args.filter = filter;
|
|
+ args.mode = ExistingFile;
|
|
+ args.options = options;
|
|
|
|
- // Falls back to local file
|
|
- return dialogResultToUrl(getOpenFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options));
|
|
+ QFileDialog dialog(args);
|
|
+ if (selectedFilter && !selectedFilter->isEmpty())
|
|
+ dialog.selectNameFilter(*selectedFilter);
|
|
+ if (dialog.exec() == QDialog::Accepted) {
|
|
+ if (selectedFilter)
|
|
+ *selectedFilter = dialog.selectedNameFilter();
|
|
+ return dialog.selectedUrls().value(0);
|
|
+ }
|
|
+ return QUrl();
|
|
}
|
|
|
|
/*!
|
|
@@ -2228,31 +2218,12 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
|
|
QString *selectedFilter,
|
|
Options options)
|
|
{
|
|
- QFileDialogArgs args;
|
|
- args.parent = parent;
|
|
- args.caption = caption;
|
|
- args.directory = QFileDialogPrivate::workingDirectory(dir);
|
|
- args.selection = QFileDialogPrivate::initialSelection(dir);
|
|
- args.filter = filter;
|
|
- args.mode = ExistingFiles;
|
|
- args.options = options;
|
|
-
|
|
-#if defined(Q_WS_WIN)
|
|
- if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {
|
|
- return qt_win_get_open_file_names(args, &(args.directory), selectedFilter);
|
|
- }
|
|
-#endif
|
|
-
|
|
- // create a qt dialog
|
|
- QFileDialog dialog(args);
|
|
- if (selectedFilter && !selectedFilter->isEmpty())
|
|
- dialog.selectNameFilter(*selectedFilter);
|
|
- if (dialog.exec() == QDialog::Accepted) {
|
|
- if (selectedFilter)
|
|
- *selectedFilter = dialog.selectedNameFilter();
|
|
- return dialog.selectedFiles();
|
|
- }
|
|
- return QStringList();
|
|
+ const QStringList schemes = QStringList(QStringLiteral("file"));
|
|
+ const QList<QUrl> selectedUrls = getOpenFileUrls(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes);
|
|
+ QStringList fileNames;
|
|
+ foreach (const QUrl &url, selectedUrls)
|
|
+ fileNames << url.toLocalFile();
|
|
+ return fileNames;
|
|
}
|
|
|
|
/*!
|
|
@@ -2293,14 +2264,24 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
|
|
{
|
|
Q_UNUSED(supportedSchemes);
|
|
|
|
- // Falls back to local files
|
|
- QList<QUrl> urls;
|
|
-
|
|
- const QStringList fileNames = getOpenFileNames(parent, caption, dir.toLocalFile(), filter, selectedFilter, options);
|
|
- foreach (const QString &fileName, fileNames)
|
|
- urls << QUrl::fromLocalFile(fileName);
|
|
+ QFileDialogArgs args;
|
|
+ args.parent = parent;
|
|
+ args.caption = caption;
|
|
+ args.directory = QFileDialogPrivate::workingDirectory(QUrl::fromLocalFile(dir));
|
|
+ args.selection = QFileDialogPrivate::initialSelection(QUrl::fromLocalFile(dir));
|
|
+ args.filter = filter;
|
|
+ args.mode = ExistingFiles;
|
|
+ args.options = options;
|
|
|
|
- return urls;
|
|
+ QFileDialog dialog(args);
|
|
+ if (selectedFilter && !selectedFilter->isEmpty())
|
|
+ dialog.selectNameFilter(*selectedFilter);
|
|
+ if (dialog.exec() == QDialog::Accepted) {
|
|
+ if (selectedFilter)
|
|
+ *selectedFilter = dialog.selectedNameFilter();
|
|
+ return dialog.selectedUrls();
|
|
+ }
|
|
+ return QList<QUrl>();
|
|
}
|
|
|
|
/*!
|
|
@@ -2360,33 +2341,9 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
|
|
QString *selectedFilter,
|
|
Options options)
|
|
{
|
|
- QFileDialogArgs args;
|
|
- args.parent = parent;
|
|
- args.caption = caption;
|
|
- args.directory = QFileDialogPrivate::workingDirectory(dir);
|
|
- args.selection = QFileDialogPrivate::initialSelection(dir);
|
|
- args.filter = filter;
|
|
- args.mode = AnyFile;
|
|
- args.options = options;
|
|
-
|
|
-#if defined(Q_WS_WIN)
|
|
- if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog)) {
|
|
- return qt_win_get_save_file_name(args, &(args.directory), selectedFilter);
|
|
- }
|
|
-#endif
|
|
-
|
|
- // create a qt dialog
|
|
- QFileDialog dialog(args);
|
|
- dialog.setAcceptMode(AcceptSave);
|
|
- if (selectedFilter && !selectedFilter->isEmpty())
|
|
- dialog.selectNameFilter(*selectedFilter);
|
|
- if (dialog.exec() == QDialog::Accepted) {
|
|
- if (selectedFilter)
|
|
- *selectedFilter = dialog.selectedNameFilter();
|
|
- return dialog.selectedFiles().value(0);
|
|
- }
|
|
-
|
|
- return QString();
|
|
+ const QStringList schemes = QStringList(QStringLiteral("file"));
|
|
+ const QUrl selectedUrl = getSaveFileUrl(parent, caption, QUrl::fromLocalFile(dir), filter, selectedFilter, options, schemes);
|
|
+ return selectedUrl.toLocalFile();
|
|
}
|
|
|
|
/*!
|
|
@@ -2426,8 +2383,25 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
|
|
{
|
|
Q_UNUSED(supportedSchemes);
|
|
|
|
- // Falls back to local file
|
|
- return dialogResultToUrl(getSaveFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options));
|
|
+ QFileDialogArgs args;
|
|
+ args.parent = parent;
|
|
+ args.caption = caption;
|
|
+ args.directory = QFileDialogPrivate::workingDirectory(QUrl::fromLocalFile(dir));
|
|
+ args.selection = QFileDialogPrivate::initialSelection(QUrl::fromLocalFile(dir));
|
|
+ args.filter = filter;
|
|
+ args.mode = AnyFile;
|
|
+ args.options = options;
|
|
+
|
|
+ QFileDialog dialog(args);
|
|
+ dialog.setAcceptMode(AcceptSave);
|
|
+ if (selectedFilter && !selectedFilter->isEmpty())
|
|
+ dialog.selectNameFilter(*selectedFilter);
|
|
+ if (dialog.exec() == QDialog::Accepted) {
|
|
+ if (selectedFilter)
|
|
+ *selectedFilter = dialog.selectedNameFilter();
|
|
+ return dialog.selectedUrls().value(0);
|
|
+ }
|
|
+ return QUrl();
|
|
}
|
|
|
|
/*!
|
|
@@ -2474,29 +2448,9 @@ QString QFileDialog::getExistingDirectory(QWidget *parent,
|
|
const QString &dir,
|
|
Options options)
|
|
{
|
|
- QFileDialogArgs args;
|
|
- args.parent = parent;
|
|
- args.caption = caption;
|
|
- args.directory = QFileDialogPrivate::workingDirectory(dir);
|
|
- args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);
|
|
- args.options = options;
|
|
-
|
|
-#if defined(Q_WS_WIN)
|
|
- if (QGuiApplicationPrivate::platformIntegration()->usePlatformNativeDialog() && !(args.options & DontUseNativeDialog) && (options & ShowDirsOnly)
|
|
-#if defined(Q_OS_WINCE)
|
|
- && qt_priv_ptr_valid
|
|
-#endif
|
|
- ) {
|
|
- return qt_win_get_existing_directory(args);
|
|
- }
|
|
-#endif
|
|
-
|
|
- // create a qt dialog
|
|
- QFileDialog dialog(args);
|
|
- if (dialog.exec() == QDialog::Accepted) {
|
|
- return dialog.selectedFiles().value(0);
|
|
- }
|
|
- return QString();
|
|
+ const QStringList schemes = QStringList(QStringLiteral("file"));
|
|
+ const QUrl selectedUrl = getExistingDirectoryUrl(parent, caption, QUrl::fromLocalFile(dir), options, schemes);
|
|
+ return selectedUrl.toLocalFile();
|
|
}
|
|
|
|
/*!
|
|
@@ -2534,8 +2488,17 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
|
|
{
|
|
Q_UNUSED(supportedSchemes);
|
|
|
|
- // Falls back to local file
|
|
- return dialogResultToUrl(getExistingDirectory(parent, caption, dir.toLocalFile(), options));
|
|
+ QFileDialogArgs args;
|
|
+ args.parent = parent;
|
|
+ args.caption = caption;
|
|
+ args.directory = QFileDialogPrivate::workingDirectory(QUrl::fromLocalFile(dir));
|
|
+ args.mode = (options & ShowDirsOnly ? DirectoryOnly : Directory);
|
|
+ args.options = options;
|
|
+
|
|
+ QFileDialog dialog(args);
|
|
+ if (dialog.exec() == QDialog::Accepted)
|
|
+ return dialog.selectedUrls().value(0);
|
|
+ return QUrl();
|
|
}
|
|
|
|
inline static QString _qt_get_directory(const QString &path)
|