diff options
author | Liang Qi <liang.qi@qt.io> | 2017-04-07 10:18:50 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-04-07 10:24:33 +0200 |
commit | 5d6073be27cb951b692bbcc4dc0dd54cc09c9fd4 (patch) | |
tree | c87c236cd1b9c15eb5f40df3d86915687ab6c59a /src/plugins/platforms/cocoa | |
parent | 97d7d80e7355019bb23bb03c2a82908e4436deb0 (diff) | |
parent | bbb67ca32cebad312f02e916dff54e591b92af24 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
mkspecs/linux-icc/qmake.conf
mkspecs/macx-icc/qmake.conf
mkspecs/win32-icc/qmake.conf
src/gui/painting/qgrayraster.c
Change-Id: Ib08c45ea3215be05f986ecb3e1f4b37d209aa775
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm | 52 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 12 |
2 files changed, 39 insertions, 25 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index e39d5e4546..4ba3dcb9a6 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -101,7 +101,7 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions; } - (NSString *)strip:(const QString &)label; -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; +- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url; - (void)filterChanged:(id)sender; - (void)showModelessPanel; - (BOOL)runApplicationModalPanel; @@ -222,12 +222,12 @@ static QString strippedText(QString s) if (mOpenPanel){ QFileInfo info(*mCurrentSelection); NSString *filepath = info.filePath().toNSString(); + NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldShowFilename:filepath]; + || [self panel:nil shouldEnableURL:url]; [self updateProperties]; QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder(); - [mOpenPanel setAllowedFileTypes:nil]; [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""]; [mOpenPanel beginWithCompletionHandler:^(NSInteger result){ @@ -242,8 +242,9 @@ static QString strippedText(QString s) { QFileInfo info(*mCurrentSelection); NSString *filepath = info.filePath().toNSString(); + NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldShowFilename:filepath]; + || [self panel:nil shouldEnableURL:url]; [mSavePanel setDirectoryURL: [NSURL fileURLWithPath:mCurrentDir]]; [mSavePanel setNameFieldStringValue:selectable ? info.fileName().toNSString() : @""]; @@ -273,8 +274,9 @@ static QString strippedText(QString s) { QFileInfo info(*mCurrentSelection); NSString *filepath = info.filePath().toNSString(); + NSURL *url = [NSURL fileURLWithPath:filepath isDirectory:info.isDir()]; bool selectable = (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) - || [self panel:nil shouldShowFilename:filepath]; + || [self panel:nil shouldEnableURL:url]; [self updateProperties]; QCocoaMenuBar::redirectKnownMenuItemsToFirstResponder(); @@ -290,26 +292,24 @@ static QString strippedText(QString s) }]; } -- (BOOL)isHiddenFile:(NSString *)filename isDir:(BOOL)isDir +- (BOOL)isHiddenFileAtURL:(NSURL *)url { - CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)filename, kCFURLPOSIXPathStyle, isDir); - CFBooleanRef isHidden; - Boolean errorOrHidden = false; - if (!CFURLCopyResourcePropertyForKey(url, kCFURLIsHiddenKey, &isHidden, NULL)) { - errorOrHidden = true; - } else { - if (CFBooleanGetValue(isHidden)) - errorOrHidden = true; - CFRelease(isHidden); + BOOL hidden = NO; + if (url) { + CFBooleanRef isHiddenProperty; + if (CFURLCopyResourcePropertyForKey((__bridge CFURLRef)url, kCFURLIsHiddenKey, &isHiddenProperty, NULL)) { + hidden = CFBooleanGetValue(isHiddenProperty); + CFRelease(isHiddenProperty); + } } - CFRelease(url); - return errorOrHidden; + return hidden; } -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename +- (BOOL)panel:(id)sender shouldEnableURL:(NSURL *)url { Q_UNUSED(sender); + NSString *filename = [url path]; if ([filename length] == 0) return NO; @@ -353,7 +353,7 @@ static QString strippedText(QString s) return NO; } if (!(filter & QDir::Hidden) - && (qtFileName.startsWith(QLatin1Char('.')) || [self isHiddenFile:filename isDir:isDir])) + && (qtFileName.startsWith(QLatin1Char('.')) || [self isHiddenFileAtURL:url])) return NO; return YES; @@ -446,11 +446,15 @@ static QString strippedText(QString s) [mSavePanel setTitle:mOptions->windowTitle().toNSString()]; [mPopUpButton setHidden:chooseDirsOnly]; // TODO hide the whole sunken pane instead? - QStringList ext = [self acceptableExtensionsForSave]; - const QString defaultSuffix = mOptions->defaultSuffix(); - if (!ext.isEmpty() && !defaultSuffix.isEmpty()) - ext.prepend(defaultSuffix); - [mSavePanel setAllowedFileTypes:ext.isEmpty() ? nil : qt_mac_QStringListToNSMutableArray(ext)]; + if (mOptions->acceptMode() == QFileDialogOptions::AcceptSave) { + QStringList ext = [self acceptableExtensionsForSave]; + const QString defaultSuffix = mOptions->defaultSuffix(); + if (!ext.isEmpty() && !defaultSuffix.isEmpty()) + ext.prepend(defaultSuffix); + [mSavePanel setAllowedFileTypes:ext.isEmpty() ? nil : qt_mac_QStringListToNSMutableArray(ext)]; + } else { + [mOpenPanel setAllowedFileTypes:nil]; // delegate panel:shouldEnableURL: does the file filtering for NSOpenPanel + } if ([mSavePanel respondsToSelector:@selector(isVisible)] && [mSavePanel isVisible]) { if ([mSavePanel respondsToSelector:@selector(validateVisibleColumns)]) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 9dfcb82151..d48ec8c6f7 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -69,6 +69,9 @@ static void initResources() QT_BEGIN_NAMESPACE +class QCoreTextFontEngine; +class QFontEngineFT; + QCocoaScreen::QCocoaScreen(int screenIndex) : QPlatformScreen(), m_screenIndex(screenIndex), m_refreshRate(60.0) { @@ -302,7 +305,7 @@ QCocoaIntegration *QCocoaIntegration::mInstance = 0; QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) : mOptions(parseOptions(paramList)) - , mFontDb(new QCoreTextFontDatabase(mOptions.testFlag(UseFreeTypeFontEngine))) + , mFontDb(0) #ifndef QT_NO_ACCESSIBILITY , mAccessibility(new QCocoaAccessibility) #endif @@ -318,6 +321,13 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) qWarning("Creating multiple Cocoa platform integrations is not supported"); mInstance = this; +#ifndef QT_NO_FREETYPE + if (mOptions.testFlag(UseFreeTypeFontEngine)) + mFontDb.reset(new QCoreTextFontDatabaseEngineFactory<QFontEngineFT>); + else +#endif + mFontDb.reset(new QCoreTextFontDatabaseEngineFactory<QCoreTextFontEngine>); + QString icStr = QPlatformInputContextFactory::requested(); icStr.isNull() ? mInputContext.reset(new QCocoaInputContext) : mInputContext.reset(QPlatformInputContextFactory::create(icStr)); |