diff options
author | Liang Qi <liang.qi@qt.io> | 2018-02-14 11:27:58 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2018-02-14 12:51:24 +0100 |
commit | 305dd1b61f657474d751cc3b24f58249ec21b61b (patch) | |
tree | 5a90972ecf0f3e499625482d194903b474d9ece6 /src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | |
parent | 76010f4af8c9a59a20c489d70c7f99b802f9721f (diff) | |
parent | dfffb5299bf83b87607f28f55afaf3c404910f9f (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.11
Conflicts:
.qmake.conf
src/corelib/animation/qvariantanimation.cpp
src/corelib/global/qglobal.cpp
src/corelib/global/qlogging.cpp
src/corelib/io/qprocess_win.cpp
src/corelib/json/qjsonarray.cpp
src/corelib/tools/qsimd_p.h
src/corelib/tools/qtimezoneprivate_p.h
src/corelib/xml/qxmlstream_p.h
src/gui/kernel/qsimpledrag.cpp
src/gui/kernel/qsimpledrag_p.h
src/plugins/generic/generic.pro
src/plugins/platforms/cocoa/qcocoamenu.mm
src/widgets/styles/qmacstyle_mac.mm
tests/auto/concurrent/qtconcurrentmap/BLACKLIST
tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp
tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp
tests/auto/gui/kernel/qwindow/BLACKLIST
tests/auto/widgets/dialogs/qmessagebox/BLACKLIST
Change-Id: I508d686cf20f7f8cc6a7119b9bc7c3bbb505c58e
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm')
-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 00bfc8bef5..94f2125bad 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -415,6 +415,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; } @@ -442,10 +449,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 |