Remove the _qt_filedialog_xxx hooks

These internal and obsolete hooks are no longer used. The correct way
to provide platform dialogs in Qt 5.x is to implement a platform theme
plugin, as was done for GTK+ 2.x.

Change-Id: I3f1474fbf760130106b3c47173eaedd2f1a919bf
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
J-P Nurmi 2014-03-10 10:16:21 +01:00 committed by The Qt Project
parent 51e5378113
commit 49b14f7a8b
2 changed files with 4 additions and 138 deletions

View File

@ -79,35 +79,6 @@ QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QString, lastVisitedDir)
/*
\internal
Exported hooks that can be used to customize the static functions.
*/
typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook = 0;
typedef QUrl (*_qt_filedialog_existing_directory_url_hook)(QWidget *parent, const QString &caption, const QUrl &dir, QFileDialog::Options options, const QStringList &supportedSchemes);
Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_url_hook qt_filedialog_existing_directory_url_hook = 0;
typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
Q_WIDGETS_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook = 0;
typedef QUrl (*_qt_filedialog_open_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
Q_WIDGETS_EXPORT _qt_filedialog_open_file_url_hook qt_filedialog_open_file_url_hook = 0;
typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
Q_WIDGETS_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook = 0;
typedef QList<QUrl> (*_qt_filedialog_open_file_urls_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
Q_WIDGETS_EXPORT _qt_filedialog_open_file_urls_hook qt_filedialog_open_file_urls_hook = 0;
typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
Q_WIDGETS_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook = 0;
typedef QUrl (*_qt_filedialog_save_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_hook = 0;
/*!
\class QFileDialog
\brief The QFileDialog class provides a dialog that allow users to select files or directories.
@ -2099,8 +2070,6 @@ QString QFileDialog::getOpenFileName(QWidget *parent,
QString *selectedFilter,
Options options)
{
if (qt_filedialog_open_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filename_hook(parent, caption, dir, filter, selectedFilter, options);
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@ -2162,8 +2131,7 @@ QUrl QFileDialog::getOpenFileUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
if (qt_filedialog_open_file_url_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_file_url_hook(parent, caption, dir, filter, selectedFilter, options, supportedSchemes);
Q_UNUSED(supportedSchemes);
// Falls back to local file
return QUrl::fromLocalFile(getOpenFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options));
@ -2225,8 +2193,6 @@ QStringList QFileDialog::getOpenFileNames(QWidget *parent,
QString *selectedFilter,
Options options)
{
if (qt_filedialog_open_filenames_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_filenames_hook(parent, caption, dir, filter, selectedFilter, options);
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@ -2290,8 +2256,7 @@ QList<QUrl> QFileDialog::getOpenFileUrls(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
if (qt_filedialog_open_file_urls_hook && !(options & DontUseNativeDialog))
return qt_filedialog_open_file_urls_hook(parent, caption, dir, filter, selectedFilter, options, supportedSchemes);
Q_UNUSED(supportedSchemes);
// Falls back to local files
QList<QUrl> urls;
@ -2360,8 +2325,6 @@ QString QFileDialog::getSaveFileName(QWidget *parent,
QString *selectedFilter,
Options options)
{
if (qt_filedialog_save_filename_hook && !(options & DontUseNativeDialog))
return qt_filedialog_save_filename_hook(parent, caption, dir, filter, selectedFilter, options);
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@ -2426,8 +2389,7 @@ QUrl QFileDialog::getSaveFileUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
if (qt_filedialog_save_file_url_hook && !(options & DontUseNativeDialog))
return qt_filedialog_save_file_url_hook(parent, caption, dir, filter, selectedFilter, options, supportedSchemes);
Q_UNUSED(supportedSchemes);
// Falls back to local file
return QUrl::fromLocalFile(getSaveFileName(parent, caption, dir.toLocalFile(), filter, selectedFilter, options));
@ -2477,8 +2439,6 @@ QString QFileDialog::getExistingDirectory(QWidget *parent,
const QString &dir,
Options options)
{
if (qt_filedialog_existing_directory_hook && !(options & DontUseNativeDialog))
return qt_filedialog_existing_directory_hook(parent, caption, dir, options);
QFileDialogArgs args;
args.parent = parent;
args.caption = caption;
@ -2537,8 +2497,7 @@ QUrl QFileDialog::getExistingDirectoryUrl(QWidget *parent,
Options options,
const QStringList &supportedSchemes)
{
if (qt_filedialog_existing_directory_url_hook && !(options & DontUseNativeDialog))
return qt_filedialog_existing_directory_url_hook(parent, caption, dir, options, supportedSchemes);
Q_UNUSED(supportedSchemes);
// Falls back to local file
return QUrl::fromLocalFile(getExistingDirectory(parent, caption, dir.toLocalFile(), options));

View File

@ -146,7 +146,6 @@ private slots:
void saveButtonText();
void clearLineEdit();
void enableChooseButton();
void hooks();
void widgetlessNativeDialog();
void trailingDotsAndSpaces();
#ifdef Q_OS_UNIX
@ -1308,98 +1307,6 @@ void tst_QFiledialog::enableChooseButton()
QCOMPARE(button->isEnabled(), true);
}
QT_BEGIN_NAMESPACE
typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
QT_END_NAMESPACE
QString existing(QWidget *, const QString &, const QString &, QFileDialog::Options) {
return "dir";
}
QT_BEGIN_NAMESPACE
typedef QString (*_qt_filedialog_open_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
QT_END_NAMESPACE
QString openName(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
return "openName";
}
QT_BEGIN_NAMESPACE
typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
QT_END_NAMESPACE
QStringList openNames(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
return QStringList("openNames");
}
QT_BEGIN_NAMESPACE
typedef QString (*_qt_filedialog_save_filename_hook)(QWidget * parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options);
extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
QT_END_NAMESPACE
QString saveName(QWidget *, const QString &, const QString &, const QString &, QString *, QFileDialog::Options) {
return "saveName";
}
QT_BEGIN_NAMESPACE
typedef QUrl (*_qt_filedialog_existing_directory_url_hook)(QWidget *parent, const QString &caption, const QUrl &dir, QFileDialog::Options options, const QStringList &supportedSchemes);
extern Q_WIDGETS_EXPORT _qt_filedialog_existing_directory_url_hook qt_filedialog_existing_directory_url_hook;
QT_END_NAMESPACE
QUrl existingUrl(QWidget *, const QString &, const QUrl &, QFileDialog::Options, const QStringList &) {
return QUrl("http://dirUrl");
}
QT_BEGIN_NAMESPACE
typedef QUrl (*_qt_filedialog_open_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
extern Q_WIDGETS_EXPORT _qt_filedialog_open_file_url_hook qt_filedialog_open_file_url_hook;
QT_END_NAMESPACE
QUrl openUrl(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
return QUrl("http://openUrl");
}
QT_BEGIN_NAMESPACE
typedef QList<QUrl> (*_qt_filedialog_open_file_urls_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
extern Q_WIDGETS_EXPORT _qt_filedialog_open_file_urls_hook qt_filedialog_open_file_urls_hook;
QT_END_NAMESPACE
QList<QUrl> openUrls(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
return QList<QUrl>() << QUrl("http://openUrls");
}
QT_BEGIN_NAMESPACE
typedef QUrl (*_qt_filedialog_save_file_url_hook)(QWidget * parent, const QString &caption, const QUrl &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options, const QStringList &supportedSchemes);
extern Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_hook;
QT_END_NAMESPACE
QUrl saveUrl(QWidget *, const QString &, const QUrl &, const QString &, QString *, QFileDialog::Options, const QStringList &) {
return QUrl("http://saveUrl");
}
void tst_QFiledialog::hooks()
{
qt_filedialog_existing_directory_hook = &existing;
qt_filedialog_save_filename_hook = &saveName;
qt_filedialog_open_filename_hook = &openName;
qt_filedialog_open_filenames_hook = &openNames;
QCOMPARE(QFileDialog::getExistingDirectory(), QString("dir"));
QCOMPARE(QFileDialog::getOpenFileName(), QString("openName"));
QCOMPARE(QFileDialog::getOpenFileNames(), QStringList("openNames"));
QCOMPARE(QFileDialog::getSaveFileName(), QString("saveName"));
QCOMPARE(QFileDialog::getExistingDirectoryUrl(), QUrl::fromLocalFile("dir"));
QCOMPARE(QFileDialog::getOpenFileUrl(), QUrl::fromLocalFile("openName"));
QCOMPARE(QFileDialog::getOpenFileUrls(), QList<QUrl>() << QUrl::fromLocalFile("openNames"));
QCOMPARE(QFileDialog::getSaveFileUrl(), QUrl::fromLocalFile("saveName"));
qt_filedialog_existing_directory_url_hook = &existingUrl;
qt_filedialog_save_file_url_hook = &saveUrl;
qt_filedialog_open_file_url_hook = &openUrl;
qt_filedialog_open_file_urls_hook = &openUrls;
QCOMPARE(QFileDialog::getExistingDirectoryUrl(), QUrl("http://dirUrl"));
QCOMPARE(QFileDialog::getOpenFileUrl(), QUrl("http://openUrl"));
QCOMPARE(QFileDialog::getOpenFileUrls(), QList<QUrl>() << QUrl("http://openUrls"));
QCOMPARE(QFileDialog::getSaveFileUrl(), QUrl("http://saveUrl"));
}
void tst_QFiledialog::widgetlessNativeDialog()
{
if (!QGuiApplicationPrivate::platformTheme()->usePlatformNativeDialog(QPlatformTheme::FileDialog))