diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-02 11:57:48 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-02-02 11:57:48 +0100 |
commit | f115ae7001d65477a615bb5f78b08bc0b0004181 (patch) | |
tree | 83a6fdbee3d8d557584ae708fbdbad4e1c85335b /src/plugins/platforms/cocoa | |
parent | 15ae7949661c6d7f401c83af5bdbb63a2ec46a2a (diff) | |
parent | b44df9937e4b15596b994f8e20822b83ac4bed29 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts:
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
Change-Id: Ia28ea4f29d308ba3aa16c2a86ffc57049c6ea590
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index fa123550ef..b02e3bc052 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -418,6 +418,13 @@ static QString strippedText(QString s) } else { QList<QUrl> result; QString filename = QString::fromNSString([[mSavePanel URL] path]).normalized(QString::NormalizationForm_C); + const QString defaultSuffix = mOptions->defaultSuffix(); + const QFileInfo fileInfo(filename); + // If neither the user or the NSSavePanel have provided a suffix, use + // the default suffix (if it exists). + if (fileInfo.suffix().isEmpty() && !defaultSuffix.isEmpty()) { + filename.append('.').append(defaultSuffix); + } result << QUrl::fromLocalFile(filename.remove(QLatin1String("___qt_very_unlikely_prefix_"))); return result; } @@ -445,10 +452,7 @@ static QString strippedText(QString s) [mPopUpButton setHidden:chooseDirsOnly]; // TODO hide the whole sunken pane instead? if (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) { - QStringList ext = [self acceptableExtensionsForSave]; - const QString defaultSuffix = mOptions->defaultSuffix(); - if (!ext.isEmpty() && !defaultSuffix.isEmpty()) - ext.prepend(defaultSuffix); + const QStringList ext = [self acceptableExtensionsForSave]; [mSavePanel setAllowedFileTypes:ext.isEmpty() ? nil : qt_mac_QStringListToNSMutableArray(ext)]; } else { [mOpenPanel setAllowedFileTypes:nil]; // delegate panel:shouldEnableURL: does the file filtering for NSOpenPanel |