diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:30:27 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-11-26 22:35:48 +0100 |
commit | 4a8273a6fc2e741e811cf5dabc9a3c240306cf7f (patch) | |
tree | 2148abc88f8543eecdc0b97b2dd92594836af9b2 /src/widgets/dialogs/qfiledialog.cpp | |
parent | 036c5db468164297d213764c59a4b59daa76d90a (diff) | |
parent | 1c2be58fecaff1de5f2849192eb712984ebd59bd (diff) |
Merge remote-tracking branch 'origin/stable' into dev
For the conflicts in msvc_nmake.cpp the ifdefs are extended since we
need to support windows phone in the target branch while it is not there
in the current stable branch (as of Qt 5.2).
Conflicts:
configure
qmake/generators/win32/msvc_nmake.cpp
src/3rdparty/angle/src/libEGL/Surface.cpp
src/angle/src/common/common.pri
src/corelib/global/qglobal.h
src/corelib/io/qstandardpaths.cpp
src/plugins/platforms/qnx/qqnxintegration.cpp
src/plugins/platforms/qnx/qqnxscreeneventhandler.h
src/plugins/platforms/xcb/qglxintegration.h
src/widgets/kernel/win.pri
tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
tools/configure/configureapp.cpp
Change-Id: I00b579eefebaf61d26ab9b00046d2b5bd5958812
Diffstat (limited to 'src/widgets/dialogs/qfiledialog.cpp')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 11ad7c7a5d..1c3a793234 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -184,6 +184,13 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_h The \l{dialogs/standarddialogs}{Standard Dialogs} example shows how to use QFileDialog as well as other built-in Qt dialogs. + By default, a platform-native file dialog will be used if the platform has + one. In that case, the widgets which would otherwise be used to construct the + dialog will not be instantiated, so related accessors such as layout() and + itemDelegate() will return null. You can set the \l DontUseNativeDialog option to + ensure that the widget-based implementation will be used instead of the + native dialog. + \sa QDir, QFileInfo, QFile, QColorDialog, QFontDialog, {Standard Dialogs Example}, {Application Example} */ @@ -243,7 +250,8 @@ Q_WIDGETS_EXPORT _qt_filedialog_save_file_url_hook qt_filedialog_save_file_url_h \value DontUseNativeDialog Don't use the native file dialog. By default, the native file dialog is used unless you use a subclass - of QFileDialog that contains the Q_OBJECT macro. + of QFileDialog that contains the Q_OBJECT macro, or the platform + does not have a native dialog of the type that you require. \value ReadOnly Indicates that the model is readonly. @@ -620,7 +628,8 @@ void QFileDialogPrivate::helperPrepareShow(QPlatformDialogHelper *) QUrl::fromLocalFile(directory.absolutePath()) : QUrl()); options->setInitiallySelectedNameFilter(q->selectedNameFilter()); - options->setInitiallySelectedFiles(userSelectedFiles()); + if (options->initiallySelectedFiles().isEmpty()) + options->setInitiallySelectedFiles(userSelectedFiles()); } void QFileDialogPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper *) @@ -755,9 +764,9 @@ void QFileDialogPrivate::emitFilesSelected(const QStringList &files) emit q->fileSelected(files.first()); } -bool QFileDialogPrivate::canBeNativeDialog() +bool QFileDialogPrivate::canBeNativeDialog() const { - Q_Q(QFileDialog); + Q_Q(const QFileDialog); if (nativeDialogInUse) return true; if (q->testAttribute(Qt::WA_DontShowOnScreen)) @@ -1045,10 +1054,13 @@ void QFileDialog::selectFile(const QString &filename) return; if (!d->usingWidgets()) { - d->selectFile_sys(QUrl::fromLocalFile(filename)); - QList<QUrl> i; - i << QUrl(filename); - d->options->setInitiallySelectedFiles(i); + QUrl url = QUrl::fromLocalFile(filename); + if (QFileInfo(filename).isRelative()) { + QDir dir(d->options->initialDirectory().toLocalFile()); + url = QUrl::fromLocalFile(dir.absoluteFilePath(filename)); + } + d->selectFile_sys(url); + d->options->setInitiallySelectedFiles(QList<QUrl>() << url); return; } @@ -1675,11 +1687,8 @@ void QFileDialog::setAcceptMode(QFileDialog::AcceptMode mode) d->options->setAcceptMode(static_cast<QFileDialogOptions::AcceptMode>(mode)); // clear WA_DontShowOnScreen so that d->canBeNativeDialog() doesn't return false incorrectly setAttribute(Qt::WA_DontShowOnScreen, false); - if (!d->usingWidgets()) { - // we need to recreate the native dialog when changing the AcceptMode - d->deletePlatformHelper(); + if (!d->usingWidgets()) return; - } QDialogButtonBox::StandardButton button = (mode == AcceptOpen ? QDialogButtonBox::Open : QDialogButtonBox::Save); d->qFileDialogUi->buttonBox->setStandardButtons(button | QDialogButtonBox::Cancel); d->qFileDialogUi->buttonBox->button(button)->setEnabled(false); |