Fix deprecated API usage

Change-Id: I62448507f80daf6be72994ee99f0fb1aa107eb78
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Jake Petroules 2017-01-05 14:14:41 -08:00
parent ffc9d27d7e
commit c1cece8e54
12 changed files with 84 additions and 100 deletions

View File

@ -122,13 +122,10 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
if (CFBundleGetPackageInfoInDirectory(url, &type, &creator)) if (CFBundleGetPackageInfoInDirectory(url, &type, &creator))
return true; return true;
#ifdef Q_OS_OSX #ifdef Q_OS_MACOS
// Find if an application other than Finder claims to know how to handle the package // Find if an application other than Finder claims to know how to handle the package
QCFType<CFURLRef> application; QCFType<CFURLRef> application = LSCopyDefaultApplicationURLForURL(url,
LSGetApplicationForURL(url, kLSRolesEditor | kLSRolesViewer, nullptr);
kLSRolesEditor|kLSRolesViewer,
NULL,
&application);
if (application) { if (application) {
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application); QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);

View File

@ -43,9 +43,11 @@
#include "qvariant.h" #include "qvariant.h"
#include "qdatetime.h" #include "qdatetime.h"
#if !defined(QWS) && defined(Q_OS_MAC) #ifdef Q_OS_DARWIN
# include "private/qcore_mac_p.h" #include "qtimezone.h"
# include <CoreFoundation/CoreFoundation.h> #include "private/qcore_mac_p.h"
#include <CoreFoundation/CoreFoundation.h>
QT_REQUIRE_CONFIG(timezone);
#endif #endif
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
@ -121,16 +123,8 @@ static QString macDayName(int day, bool short_format)
static QString macDateToString(const QDate &date, bool short_format) static QString macDateToString(const QDate &date, bool short_format)
{ {
CFGregorianDate macGDate; const QTimeZone tz = QTimeZone::fromCFTimeZone(QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault()));
macGDate.year = date.year(); QCFType<CFDateRef> myDate = QDateTime(date, QTime(), tz).toCFDate();
macGDate.month = date.month();
macGDate.day = date.day();
macGDate.hour = 0;
macGDate.minute = 0;
macGDate.second = 0.0;
QCFType<CFDateRef> myDate
= CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault())));
QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent(); QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent();
CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
QCFType<CFDateFormatterRef> myFormatter QCFType<CFDateFormatterRef> myFormatter
@ -142,19 +136,8 @@ static QString macDateToString(const QDate &date, bool short_format)
static QString macTimeToString(const QTime &time, bool short_format) static QString macTimeToString(const QTime &time, bool short_format)
{ {
CFGregorianDate macGDate; const QTimeZone tz = QTimeZone::fromCFTimeZone(QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault()));
// Assume this is local time and the current date QCFType<CFDateRef> myDate = QDateTime(QDate::currentDate(), time, tz).toCFDate();
QDate dt = QDate::currentDate();
macGDate.year = dt.year();
macGDate.month = dt.month();
macGDate.day = dt.day();
macGDate.hour = time.hour();
macGDate.minute = time.minute();
macGDate.second = time.second();
QCFType<CFDateRef> myDate
= CFDateCreate(0, CFGregorianDateGetAbsoluteTime(macGDate,
QCFType<CFTimeZoneRef>(CFTimeZoneCopyDefault())));
QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent(); QCFType<CFLocaleRef> mylocale = CFLocaleCopyCurrent();
CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle; CFDateFormatterStyle style = short_format ? kCFDateFormatterShortStyle : kCFDateFormatterLongStyle;
QCFType<CFDateFormatterRef> myFormatter = CFDateFormatterCreate(kCFAllocatorDefault, QCFType<CFDateFormatterRef> myFormatter = CFDateFormatterCreate(kCFAllocatorDefault,

View File

@ -708,71 +708,71 @@ static CTFontUIFontType fontTypeFromTheme(QPlatformTheme::Font f)
{ {
switch (f) { switch (f) {
case QPlatformTheme::SystemFont: case QPlatformTheme::SystemFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::MenuFont: case QPlatformTheme::MenuFont:
case QPlatformTheme::MenuBarFont: case QPlatformTheme::MenuBarFont:
case QPlatformTheme::MenuItemFont: case QPlatformTheme::MenuItemFont:
return kCTFontMenuItemFontType; return kCTFontUIFontMenuItem;
case QPlatformTheme::MessageBoxFont: case QPlatformTheme::MessageBoxFont:
return kCTFontEmphasizedSystemFontType; return kCTFontUIFontEmphasizedSystem;
case QPlatformTheme::LabelFont: case QPlatformTheme::LabelFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::TipLabelFont: case QPlatformTheme::TipLabelFont:
return kCTFontToolTipFontType; return kCTFontToolTipFontType;
case QPlatformTheme::StatusBarFont: case QPlatformTheme::StatusBarFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::TitleBarFont: case QPlatformTheme::TitleBarFont:
return kCTFontWindowTitleFontType; return kCTFontUIFontWindowTitle;
case QPlatformTheme::MdiSubWindowTitleFont: case QPlatformTheme::MdiSubWindowTitleFont:
case QPlatformTheme::DockWidgetTitleFont: case QPlatformTheme::DockWidgetTitleFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::PushButtonFont: case QPlatformTheme::PushButtonFont:
return kCTFontPushButtonFontType; return kCTFontUIFontPushButton;
case QPlatformTheme::CheckBoxFont: case QPlatformTheme::CheckBoxFont:
case QPlatformTheme::RadioButtonFont: case QPlatformTheme::RadioButtonFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::ToolButtonFont: case QPlatformTheme::ToolButtonFont:
return kCTFontSmallToolbarFontType; return kCTFontUIFontSmallToolbar;
case QPlatformTheme::ItemViewFont: case QPlatformTheme::ItemViewFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::ListViewFont: case QPlatformTheme::ListViewFont:
return kCTFontViewsFontType; return kCTFontUIFontViews;
case QPlatformTheme::HeaderViewFont: case QPlatformTheme::HeaderViewFont:
return kCTFontSmallSystemFontType; return kCTFontUIFontSmallSystem;
case QPlatformTheme::ListBoxFont: case QPlatformTheme::ListBoxFont:
return kCTFontViewsFontType; return kCTFontUIFontViews;
case QPlatformTheme::ComboMenuItemFont: case QPlatformTheme::ComboMenuItemFont:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
case QPlatformTheme::ComboLineEditFont: case QPlatformTheme::ComboLineEditFont:
return kCTFontViewsFontType; return kCTFontUIFontViews;
case QPlatformTheme::SmallFont: case QPlatformTheme::SmallFont:
return kCTFontSmallSystemFontType; return kCTFontUIFontSmallSystem;
case QPlatformTheme::MiniFont: case QPlatformTheme::MiniFont:
return kCTFontMiniSystemFontType; return kCTFontUIFontMiniSystem;
case QPlatformTheme::FixedFont: case QPlatformTheme::FixedFont:
return kCTFontUserFixedPitchFontType; return kCTFontUIFontUserFixedPitch;
default: default:
return kCTFontSystemFontType; return kCTFontUIFontSystem;
} }
} }
@ -848,7 +848,7 @@ QFont *QCoreTextFontDatabase::themeFont(QPlatformTheme::Font f) const
QFont QCoreTextFontDatabase::defaultFont() const QFont QCoreTextFontDatabase::defaultFont() const
{ {
if (defaultFontName.isEmpty()) { if (defaultFontName.isEmpty()) {
QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontSystemFontType, 12.0, NULL); QCFType<CTFontRef> font = CTFontCreateUIFontForLanguage(kCTFontUIFontSystem, 12.0, NULL);
defaultFontName = (QString) QCFString(CTFontCopyFullName(font)); defaultFontName = (QString) QCFString(CTFontCopyFullName(font));
} }

View File

@ -141,7 +141,7 @@ static void loadAdvancesForGlyphs(CTFontRef ctfont,
{ {
Q_UNUSED(flags); Q_UNUSED(flags);
QVarLengthArray<CGSize> advances(len); QVarLengthArray<CGSize> advances(len);
CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), len); CTFontGetAdvancesForGlyphs(ctfont, kCTFontOrientationHorizontal, cgGlyphs.data(), advances.data(), len);
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
if (glyphs->glyphs[i] & 0xff000000) if (glyphs->glyphs[i] & 0xff000000)
@ -320,7 +320,7 @@ bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *
return true; return true;
QVarLengthArray<CGSize> advances(glyph_pos); QVarLengthArray<CGSize> advances(glyph_pos);
CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, cgGlyphs.data(), advances.data(), glyph_pos); CTFontGetAdvancesForGlyphs(ctfont, kCTFontOrientationHorizontal, cgGlyphs.data(), advances.data(), glyph_pos);
for (int i = 0; i < glyph_pos; ++i) { for (int i = 0; i < glyph_pos; ++i) {
if (glyphs->glyphs[i] & 0xff000000) if (glyphs->glyphs[i] & 0xff000000)
@ -351,7 +351,7 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
{ {
glyph_metrics_t ret; glyph_metrics_t ret;
CGGlyph g = glyph; CGGlyph g = glyph;
CGRect rect = CTFontGetBoundingRectsForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, 0, 1); CGRect rect = CTFontGetBoundingRectsForGlyphs(ctfont, kCTFontOrientationHorizontal, &g, 0, 1);
if (synthesisFlags & QFontEngine::SynthesizedItalic) { if (synthesisFlags & QFontEngine::SynthesizedItalic) {
rect.size.width += rect.size.height * SYNTHETIC_ITALIC_SKEW; rect.size.width += rect.size.height * SYNTHETIC_ITALIC_SKEW;
} }
@ -360,7 +360,7 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
ret.x = QFixed::fromReal(rect.origin.x); ret.x = QFixed::fromReal(rect.origin.x);
ret.y = -QFixed::fromReal(rect.origin.y) - ret.height; ret.y = -QFixed::fromReal(rect.origin.y) - ret.height;
CGSize advances[1]; CGSize advances[1];
CTFontGetAdvancesForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, advances, 1); CTFontGetAdvancesForGlyphs(ctfont, kCTFontOrientationHorizontal, &g, advances, 1);
ret.xoff = QFixed::fromReal(advances[0].width); ret.xoff = QFixed::fromReal(advances[0].width);
ret.yoff = QFixed::fromReal(advances[0].height); ret.yoff = QFixed::fromReal(advances[0].height);

View File

@ -61,14 +61,14 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
#include <net/if.h> #include <net/if.h>
#include <ifaddrs.h> #include <ifaddrs.h>
@interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject @interface QT_MANGLE_NAMESPACE(QNSListener) : NSObject <CWEventDelegate>
{ {
NSNotificationCenter *notificationCenter; NSNotificationCenter *notificationCenter;
CWInterface *currentInterface; CWWiFiClient *client;
QCoreWlanEngine *engine; QCoreWlanEngine *engine;
NSLock *locker; NSLock *locker;
} }
- (void)notificationHandler:(NSNotification *)notification; - (void)powerStateDidChangeForWiFiInterfaceWithName:(NSString *)interfaceName;
- (void)remove; - (void)remove;
- (void)setEngine:(QCoreWlanEngine *)coreEngine; - (void)setEngine:(QCoreWlanEngine *)coreEngine;
- (QCoreWlanEngine *)engine; - (QCoreWlanEngine *)engine;
@ -85,8 +85,9 @@ extern "C" { // Otherwise it won't find CWKeychain* symbols at link time
[locker lock]; [locker lock];
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
notificationCenter = [NSNotificationCenter defaultCenter]; notificationCenter = [NSNotificationCenter defaultCenter];
currentInterface = [CWInterface interface]; client = [CWWiFiClient sharedWiFiClient];
[notificationCenter addObserver:self selector:@selector(notificationHandler:) name:CWPowerDidChangeNotification object:nil]; client.delegate = self;
[client startMonitoringEventWithType:CWEventTypePowerDidChange error:nil];
[locker unlock]; [locker unlock];
return self; return self;
} }
@ -95,6 +96,7 @@ static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
-(void)dealloc -(void)dealloc
{ {
client.delegate = nil;
listener = nil; listener = nil;
[super dealloc]; [super dealloc];
} }
@ -115,13 +117,13 @@ static QT_MANGLE_NAMESPACE(QNSListener) *listener = 0;
-(void)remove -(void)remove
{ {
[locker lock]; [locker lock];
[notificationCenter removeObserver:self]; [client stopMonitoringAllEventsAndReturnError:nil];
[locker unlock]; [locker unlock];
} }
- (void)notificationHandler:(NSNotification *)notification - (void)powerStateDidChangeForWiFiInterfaceWithName:(NSString *)interfaceName
{ {
Q_UNUSED(notification); Q_UNUSED(interfaceName);
engine->requestUpdate(); engine->requestUpdate();
} }
@end @end
@ -162,7 +164,8 @@ void QScanThread::run()
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
QStringList found; QStringList found;
mutex.lock(); mutex.lock();
CWInterface *currentInterface = [CWInterface interfaceWithName:interfaceName.toNSString()]; CWInterface *currentInterface = [[CWWiFiClient sharedWiFiClient]
interfaceWithName:interfaceName.toNSString()];
mutex.unlock(); mutex.unlock();
const bool currentInterfaceServiceActive = currentInterface.serviceActive; const bool currentInterfaceServiceActive = currentInterface.serviceActive;
@ -284,10 +287,10 @@ void QScanThread::getUserConfigurations()
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
userProfiles.clear(); userProfiles.clear();
NSSet *wifiInterfaces = [CWInterface interfaceNames]; NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
for (NSString *ifName in wifiInterfaces) { for (NSString *ifName in wifiInterfaces) {
CWInterface *wifiInterface = [CWInterface interfaceWithName:ifName]; CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient] interfaceWithName:ifName];
NSString *nsInterfaceName = wifiInterface.ssid; NSString *nsInterfaceName = wifiInterface.ssid;
// add user configured system networks // add user configured system networks
@ -442,7 +445,7 @@ void QCoreWlanEngine::initialize()
QMutexLocker locker(&mutex); QMutexLocker locker(&mutex);
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if ([[CWInterface interfaceNames] count] > 0 && !listener) { if ([[CWWiFiClient interfaceNames] count] > 0 && !listener) {
listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init]; listener = [[QT_MANGLE_NAMESPACE(QNSListener) alloc] init];
listener.engine = this; listener.engine = this;
hasWifi = true; hasWifi = true;
@ -476,7 +479,7 @@ void QCoreWlanEngine::connectToId(const QString &id)
QString interfaceString = getInterfaceFromId(id); QString interfaceString = getInterfaceFromId(id);
CWInterface *wifiInterface = CWInterface *wifiInterface =
[CWInterface interfaceWithName:interfaceString.toNSString()]; [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
if (wifiInterface.powerOn) { if (wifiInterface.powerOn) {
NSError *err = nil; NSError *err = nil;
@ -559,7 +562,7 @@ void QCoreWlanEngine::disconnectFromId(const QString &id)
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
CWInterface *wifiInterface = CWInterface *wifiInterface =
[CWInterface interfaceWithName:interfaceString.toNSString()]; [[CWWiFiClient sharedWiFiClient] interfaceWithName:interfaceString.toNSString()];
disconnectedInterfaceString = interfaceString; disconnectedInterfaceString = interfaceString;
[wifiInterface disassociate]; [wifiInterface disassociate];
@ -573,8 +576,8 @@ void QCoreWlanEngine::checkDisconnect()
if (!disconnectedInterfaceString.isEmpty()) { if (!disconnectedInterfaceString.isEmpty()) {
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
CWInterface *wifiInterface = CWInterface *wifiInterface = [[CWWiFiClient sharedWiFiClient]
[CWInterface interfaceWithName:disconnectedInterfaceString.toNSString()]; interfaceWithName:disconnectedInterfaceString.toNSString()];
const QString networkSsid = QString::fromNSString([wifiInterface ssid]); const QString networkSsid = QString::fromNSString([wifiInterface ssid]);
if (!networkSsid.isEmpty()) { if (!networkSsid.isEmpty()) {
@ -599,7 +602,7 @@ void QCoreWlanEngine::doRequestUpdate()
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
NSSet *wifiInterfaces = [CWInterface interfaceNames]; NSArray<NSString *> *wifiInterfaces = [CWWiFiClient interfaceNames];
for (NSString *ifName in wifiInterfaces) { for (NSString *ifName in wifiInterfaces) {
scanThread->interfaceName = QString::fromNSString(ifName); scanThread->interfaceName = QString::fromNSString(ifName);
scanThread->start(); scanThread->start();
@ -615,7 +618,8 @@ bool QCoreWlanEngine::isWifiReady(const QString &wifiDeviceName)
bool haswifi = false; bool haswifi = false;
if(hasWifi) { if(hasWifi) {
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
CWInterface *defaultInterface = [CWInterface interfaceWithName:wifiDeviceName.toNSString()]; CWInterface *defaultInterface = [[CWWiFiClient sharedWiFiClient]
interfaceWithName:wifiDeviceName.toNSString()];
if (defaultInterface.powerOn) { if (defaultInterface.powerOn) {
haswifi = true; haswifi = true;
} }

View File

@ -80,7 +80,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mHelper = 0; mHelper = 0;
mStolenContentView = 0; mStolenContentView = 0;
mPanelButtons = nil; mPanelButtons = nil;
mResultCode = NSCancelButton; mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false; mDialogIsExecuting = false;
mResultSet = false; mResultSet = false;
mClosingDueToKnownButton = false; mClosingDueToKnownButton = false;
@ -168,7 +168,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mClosingDueToKnownButton = true; mClosingDueToKnownButton = true;
[mColorPanel close]; [mColorPanel close];
[self updateQtColor]; [self updateQtColor];
[self finishOffWithCode:NSOKButton]; [self finishOffWithCode:NSModalResponseOK];
} }
- (void)onCancelClicked - (void)onCancelClicked
@ -177,7 +177,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
mClosingDueToKnownButton = true; mClosingDueToKnownButton = true;
[mColorPanel close]; [mColorPanel close];
mQtColor = QColor(); mQtColor = QColor();
[self finishOffWithCode:NSCancelButton]; [self finishOffWithCode:NSModalResponseCancel];
} }
} }
@ -238,12 +238,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
[NSApp runModalForWindow:mColorPanel]; [NSApp runModalForWindow:mColorPanel];
mDialogIsExecuting = false; mDialogIsExecuting = false;
return (mResultCode == NSOKButton); return (mResultCode == NSModalResponseOK);
} }
- (QPlatformDialogHelper::DialogCode)dialogResultCode - (QPlatformDialogHelper::DialogCode)dialogResultCode
{ {
return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
} }
- (BOOL)windowShouldClose:(id)window - (BOOL)windowShouldClose:(id)window
@ -252,7 +252,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
if (!mPanelButtons) if (!mPanelButtons)
[self updateQtColor]; [self updateQtColor];
if (mDialogIsExecuting) { if (mDialogIsExecuting) {
[self finishOffWithCode:NSCancelButton]; [self finishOffWithCode:NSModalResponseCancel];
} else { } else {
mResultSet = true; mResultSet = true;
if (mHelper) if (mHelper)
@ -278,7 +278,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
// This check will prevent any such recursion. // This check will prevent any such recursion.
if (!mResultSet) { if (!mResultSet) {
mResultSet = true; mResultSet = true;
if (mResultCode == NSCancelButton) { if (mResultCode == NSModalResponseCancel) {
emit mHelper->reject(); emit mHelper->reject();
} else { } else {
emit mHelper->accept(); emit mHelper->accept();

View File

@ -401,7 +401,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
// [NSApp run], which is the normal code path for cocoa applications. // [NSApp run], which is the normal code path for cocoa applications.
if (NSModalSession session = d->currentModalSession()) { if (NSModalSession session = d->currentModalSession()) {
QBoolBlocker execGuard(d->currentExecIsNSAppRun, false); QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) while ([NSApp runModalSession:session] == NSModalResponseContinue && !d->interrupt)
qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode); qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
if (!d->interrupt && session == d->currentModalSessionCached) { if (!d->interrupt && session == d->currentModalSessionCached) {
@ -435,7 +435,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
if (flags & QEventLoop::WaitForMoreEvents) if (flags & QEventLoop::WaitForMoreEvents)
qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode); qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
NSInteger status = [NSApp runModalSession:session]; NSInteger status = [NSApp runModalSession:session];
if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) { if (status != NSModalResponseContinue && session == d->currentModalSessionCached) {
// INVARIANT: Someone called [NSApp stopModal:] from outside the event // INVARIANT: Someone called [NSApp stopModal:] from outside the event
// dispatcher (e.g to stop a native dialog). But that call wrongly stopped // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
// 'session' as well. As a result, we need to restart all internal sessions: // 'session' as well. As a result, we need to restart all internal sessions:

View File

@ -106,7 +106,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
mHelper = 0; mHelper = 0;
mStolenContentView = 0; mStolenContentView = 0;
mPanelButtons = 0; mPanelButtons = 0;
mResultCode = NSCancelButton; mResultCode = NSModalResponseCancel;
mDialogIsExecuting = false; mDialogIsExecuting = false;
mResultSet = false; mResultSet = false;
@ -171,7 +171,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
- (void)onOkClicked - (void)onOkClicked
{ {
[mFontPanel close]; [mFontPanel close];
[self finishOffWithCode:NSOKButton]; [self finishOffWithCode:NSModalResponseOK];
} }
- (void)onCancelClicked - (void)onCancelClicked
@ -179,7 +179,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
if (mPanelButtons) { if (mPanelButtons) {
[mFontPanel close]; [mFontPanel close];
mQtFont = QFont(); mQtFont = QFont();
[self finishOffWithCode:NSCancelButton]; [self finishOffWithCode:NSModalResponseCancel];
} }
} }
@ -224,12 +224,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
[NSApp runModalForWindow:mFontPanel]; [NSApp runModalForWindow:mFontPanel];
mDialogIsExecuting = false; mDialogIsExecuting = false;
return (mResultCode == NSOKButton); return (mResultCode == NSModalResponseOK);
} }
- (QPlatformDialogHelper::DialogCode)dialogResultCode - (QPlatformDialogHelper::DialogCode)dialogResultCode
{ {
return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected; return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
} }
- (BOOL)windowShouldClose:(id)window - (BOOL)windowShouldClose:(id)window
@ -238,7 +238,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
if (!mPanelButtons) if (!mPanelButtons)
[self updateQtFont]; [self updateQtFont];
if (mDialogIsExecuting) { if (mDialogIsExecuting) {
[self finishOffWithCode:NSCancelButton]; [self finishOffWithCode:NSModalResponseCancel];
} else { } else {
mResultSet = true; mResultSet = true;
if (mHelper) if (mHelper)
@ -264,7 +264,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
// This check will prevent any such recursion. // This check will prevent any such recursion.
if (!mResultSet) { if (!mResultSet) {
mResultSet = true; mResultSet = true;
if (mResultCode == NSCancelButton) { if (mResultCode == NSModalResponseCancel) {
emit mHelper->reject(); emit mHelper->reject();
} else { } else {
emit mHelper->accept(); emit mHelper->accept();

View File

@ -172,11 +172,12 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard() QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
{ {
QCFType<CFURLRef> url;
const int ExpectedImageWidth = 242; const int ExpectedImageWidth = 242;
const int ExpectedImageHeight = 414; const int ExpectedImageHeight = 414;
if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"), QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier(
0, 0, &url) == noErr) { CFSTR("com.apple.KeyboardSetupAssistant"), nullptr);
if (urls && CFArrayGetCount(urls) > 0) {
CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0);
QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url); QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
if (bundle) { if (bundle) {
url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0); url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0);

View File

@ -78,7 +78,7 @@ QT_USE_NAMESPACE
QPageSetupDialog *dialog = static_cast<QPageSetupDialog *>(contextInfo); QPageSetupDialog *dialog = static_cast<QPageSetupDialog *>(contextInfo);
QPrinter *printer = dialog->printer(); QPrinter *printer = dialog->printer();
if (returnCode == NSOKButton) { if (returnCode == NSModalResponseOK) {
PMPageFormat format = static_cast<PMPageFormat>([printInfo PMPageFormat]); PMPageFormat format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
PMRect paperRect; PMRect paperRect;
PMGetUnadjustedPaperRect(format, &paperRect); PMGetUnadjustedPaperRect(format, &paperRect);
@ -89,7 +89,7 @@ QT_USE_NAMESPACE
printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait); printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
} }
dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
} }
@end @end

View File

@ -103,7 +103,7 @@ QT_USE_NAMESPACE
QPrintDialog *dialog = static_cast<QPrintDialog *>(contextInfo); QPrintDialog *dialog = static_cast<QPrintDialog *>(contextInfo);
QPrinter *printer = dialog->printer(); QPrinter *printer = dialog->printer();
if (returnCode == NSOKButton) { if (returnCode == NSModalResponseOK) {
PMPrintSession session = static_cast<PMPrintSession>([printInfo PMPrintSession]); PMPrintSession session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
PMPrintSettings settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]); PMPrintSettings settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
@ -192,7 +192,7 @@ QT_USE_NAMESPACE
printer->setPageSize(pageSize); printer->setPageSize(pageSize);
printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait); printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected); dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
} }
@end @end

View File

@ -177,8 +177,7 @@ void QTabBarPrivate::initBasicStyleOption(QStyleOptionTab *option, int tabIndex)
if (tab.textColor.isValid()) if (tab.textColor.isValid())
option->palette.setColor(q->foregroundRole(), tab.textColor); option->palette.setColor(q->foregroundRole(), tab.textColor);
#ifdef Q_OS_MACOS #ifdef Q_OS_MACOS
else if (isCurrent && !documentMode else if (isCurrent && !documentMode && q->isActiveWindow()) {
&& (QSysInfo::MacintoshVersion < QSysInfo::MV_10_10 || q->isActiveWindow())) {
option->palette.setColor(QPalette::WindowText, Qt::white); option->palette.setColor(QPalette::WindowText, Qt::white);
} }
#endif #endif