diff options
author | Shawn Rutledge <shawn.rutledge@digia.com> | 2013-10-30 15:14:16 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-08 16:45:26 +0100 |
commit | 7e5452a23f02c87f73f729cf6eab0ffe1ffa440c (patch) | |
tree | 232a0852eafa7d5b9560bc0737fd7855840c0a57 /src | |
parent | 706eeadf3aa226ea02496c352006b26abe791f07 (diff) |
Fix QFileDialog::getSaveFilename() with a given default name
The QFileDialogOptions::initiallySelectedFiles were overridden, and
the given filename was also not properly converted to a local file URL.
Task-number: QTBUG-34408
Task-number: QTBUG-34446
Change-Id: I51d05b954a5393d10db9232945ba05bda7068e73
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/dialogs/qfiledialog.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/widgets/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp index 22d467661e..cfdc303f21 100644 --- a/src/widgets/dialogs/qfiledialog.cpp +++ b/src/widgets/dialogs/qfiledialog.cpp @@ -628,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 *) @@ -1053,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; } @@ -1683,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); |