QFileDialog: implement getOpenFileUrl and friends for real
This commit is contained in:
parent
c6628dbc04
commit
ab7b18b9ea
@ -29,7 +29,7 @@
|
|||||||
Summary: Qt5 - QtBase components
|
Summary: Qt5 - QtBase components
|
||||||
Name: qt5-qtbase
|
Name: qt5-qtbase
|
||||||
Version: 5.3.2
|
Version: 5.3.2
|
||||||
Release: 2%{?dist}
|
Release: 3%{?dist}
|
||||||
|
|
||||||
# See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details
|
# See LGPL_EXCEPTIONS.txt, LICENSE.GPL3, respectively, for exception details
|
||||||
License: LGPLv2 with exceptions or GPLv3 with exceptions
|
License: LGPLv2 with exceptions or GPLv3 with exceptions
|
||||||
@ -78,6 +78,7 @@ Patch12: qtbase-opensource-src-5.2.0-enable_ft_lcdfilter.patch
|
|||||||
Patch50: qt5-poll.patch
|
Patch50: qt5-poll.patch
|
||||||
|
|
||||||
##upstream patches
|
##upstream patches
|
||||||
|
Patch100: qtbase-qfiledialog-implement-getopenfileurl-and-friends.patch
|
||||||
|
|
||||||
# macros
|
# macros
|
||||||
%define _qt5 %{name}
|
%define _qt5 %{name}
|
||||||
@ -308,6 +309,8 @@ rm -fv mkspecs/linux-g++*/qmake.conf.multilib-optflags
|
|||||||
|
|
||||||
#patch50 -p1 -b .poll
|
#patch50 -p1 -b .poll
|
||||||
|
|
||||||
|
%patch100 -p1 -b .qfiledialog-implement-getopenfileurl-and-friends
|
||||||
|
|
||||||
# drop -fexceptions from $RPM_OPT_FLAGS
|
# drop -fexceptions from $RPM_OPT_FLAGS
|
||||||
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's|-fexceptions||g'`
|
RPM_OPT_FLAGS=`echo $RPM_OPT_FLAGS | sed 's|-fexceptions||g'`
|
||||||
|
|
||||||
@ -758,6 +761,9 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Oct 13 2014 Jan Grulich <jgrulich@redhat.com> 5.3.2-3
|
||||||
|
- QFileDialog: implement getOpenFileUrl and friends for real
|
||||||
|
|
||||||
* Thu Oct 09 2014 Rex Dieter <rdieter@fedoraproject.org> 5.3.2-2
|
* Thu Oct 09 2014 Rex Dieter <rdieter@fedoraproject.org> 5.3.2-2
|
||||||
- use linux-g++ platform unconditionally
|
- use linux-g++ platform unconditionally
|
||||||
|
|
||||||
|
261
qtbase-qfiledialog-implement-getopenfileurl-and-friends.patch
Normal file
261
qtbase-qfiledialog-implement-getopenfileurl-and-friends.patch
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
|
||||||
|
index 9219757..9c2956a 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(dir);
|
||||||
|
+ args.selection = QFileDialogPrivate::initialSelection(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(dir);
|
||||||
|
+ args.selection = QFileDialogPrivate::initialSelection(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(dir);
|
||||||
|
+ args.selection = QFileDialogPrivate::initialSelection(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(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)
|
Loading…
Reference in New Issue
Block a user