diff options
Diffstat (limited to 'src/widgets/styles/qmacstyle_mac.mm')
-rw-r--r-- | src/widgets/styles/qmacstyle_mac.mm | 68 |
1 files changed, 23 insertions, 45 deletions
diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index d13754b36b..e8da137654 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -93,18 +93,6 @@ QT_USE_NAMESPACE -namespace { -class AutoReleasePool -{ -public: - AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {} - ~AutoReleasePool() { [pool release]; } - -private: - NSAutoreleasePool *pool; -}; -} - @interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject { QMacStylePrivate *mPrivate; } @@ -126,7 +114,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(NotificationReceiver); { Q_UNUSED(notification); QEvent event(QEvent::StyleChange); - QMutableSetIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars); + QMutableVectorIterator<QPointer<QObject> > it(QMacStylePrivate::scrollBars); while (it.hasNext()) { if (!it.next()) it.remove(); @@ -150,12 +138,7 @@ const int QMacStylePrivate::BevelButtonW = 50; const int QMacStylePrivate::BevelButtonH = 22; const int QMacStylePrivate::PushButtonContentPadding = 6; -QSet<QPointer<QObject> > QMacStylePrivate::scrollBars; - -static uint qHash(const QPointer<QObject> &ptr) -{ - return qHash(ptr.data()); -} +QVector<QPointer<QObject> > QMacStylePrivate::scrollBars; // Title bar gradient colors for Lion were determined by inspecting PSDs exported // using CoreUI's CoreThemeDocument; there is no public API to retrieve them @@ -1753,7 +1736,7 @@ QMacStylePrivate::QMacStylePrivate() QMacStylePrivate::~QMacStylePrivate() { - AutoReleasePool pool; + QMacAutoReleasePool pool; Q_FOREACH (NSView *b, cocoaControls) [b release]; } @@ -1884,7 +1867,7 @@ NSView *QMacStylePrivate::cocoaControl(QCocoaWidget widget) const if ([bv isKindOfClass:[NSButton class]]) { NSButton *bc = (NSButton *)bv; - bc.title = nil; + bc.title = @""; } if ([bv isKindOfClass:[NSControl class]]) { @@ -1977,7 +1960,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD const bool button = opt->type == QStyleOption::SO_Button; const bool viewItem = opt->type == QStyleOption::SO_ViewItem; const bool pressed = bdi->state == kThemeStatePressed; - const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; + const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10; if (button && pressed) { if (bdi->kind == kThemePushButton) { @@ -1989,7 +1972,7 @@ void QMacStylePrivate::drawColorlessButton(const HIRect &macRect, HIThemeButtonD } } - int devicePixelRatio = p->device()->devicePixelRatio(); + int devicePixelRatio = p->device()->devicePixelRatioF(); int width = devicePixelRatio * (int(macRect.size.width) + extraWidth); int height = devicePixelRatio * (int(macRect.size.height) + extraHeight); @@ -2135,7 +2118,7 @@ QMacStyle::QMacStyle() : QCommonStyle(*new QMacStylePrivate) { Q_D(QMacStyle); - AutoReleasePool pool; + QMacAutoReleasePool pool; d->receiver = [[NotificationReceiver alloc] initWithPrivate:d]; NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver); @@ -2152,7 +2135,7 @@ QMacStyle::QMacStyle() QMacStyle::~QMacStyle() { Q_D(QMacStyle); - AutoReleasePool pool; + QMacAutoReleasePool pool; [reinterpret_cast<NSScroller*>(d->nsscroller) release]; @@ -2169,7 +2152,7 @@ QMacStyle::~QMacStyle() */ QPixmap QMacStylePrivate::generateBackgroundPattern() const { - AutoReleasePool pool; + QMacAutoReleasePool pool; QPixmap px(4, 4); QMacCGContext cg(&px); HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal); @@ -2767,7 +2750,7 @@ QPalette QMacStyle::standardPalette() const int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *hret) const { - AutoReleasePool pool; + QMacAutoReleasePool pool; SInt32 ret = 0; switch (sh) { @@ -3618,6 +3601,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QWindow *window = w && w->window() ? w->window()->windowHandle() : QStyleHelper::styleObjectWindow(opt->styleObject); const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window); + const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10; switch (ce) { case CE_HeaderSection: if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { @@ -3829,13 +3813,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // No default button pulsating animation on Yosemite, // so we have to do few things differently. - const bool yosemiteOrLater = QSysInfo::QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; // a focused auto-default button within an active window // takes precedence over a normal default button if (btn->features & QStyleOptionButton::AutoDefaultButton && opt->state & State_Active && opt->state & State_HasFocus) { - if (yosemiteOrLater) + if (usingYosemiteOrLater) d->autoDefaultButton = opt->styleObject; else d->setAutoDefaultButton(opt->styleObject); @@ -3846,7 +3829,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (!d->autoDefaultButton) { if (btn->features & QStyleOptionButton::DefaultButton && opt->state & State_Active) { d->defaultButton = opt->styleObject; - if (!yosemiteOrLater && !d->animation(opt->styleObject)) + if (!usingYosemiteOrLater && !d->animation(opt->styleObject)) d->startAnimation(new QStyleAnimation(opt->styleObject)); } else if (d->defaultButton == opt->styleObject) { if (QStyleAnimation *animation = d->animation(opt->styleObject)) { @@ -3868,7 +3851,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter HIThemeButtonDrawInfo bdi; d->initHIThemePushButton(btn, w, tds, &bdi); - if (yosemiteOrLater) { + if (usingYosemiteOrLater) { if (!hasMenu) { // HITheme is not drawing a nice focus frame around buttons. // We'll do it ourselves further down. @@ -3921,7 +3904,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter newRect.size.width -= QMacStylePrivate::PushButtonRightOffset - 4; } - if (hasMenu && yosemiteOrLater && bdi.kind != kThemeBevelButton) { + if (hasMenu && usingYosemiteOrLater && bdi.kind != kThemeBevelButton) { QCocoaWidget cw = cocoaWidgetFromHIThemeButtonKind(bdi.kind); cw.first = QCocoaPullDownButton; NSPopUpButton *pdb = (NSPopUpButton *)d->cocoaControl(cw); @@ -3935,7 +3918,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter else HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); - if (yosemiteOrLater && btn->state & State_HasFocus) { + if (usingYosemiteOrLater && btn->state & State_HasFocus) { CGRect focusRect = newRect; if (bdi.kind == kThemePushButton) focusRect.size.height += 1; // Another thing HITheme and Cocoa seem to disagree about. @@ -3966,7 +3949,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter qt_drawFocusRingOnPath(cg, pushButtonFocusRingPath); } - if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) { + if (hasMenu && (!usingYosemiteOrLater || bdi.kind == kThemeBevelButton)) { int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; int arrowXOffset = bdi.kind == kThemePushButton ? 6 : @@ -4138,8 +4121,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } } - bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; - HIThemeTabDrawInfo tdi; tdi.version = 1; tdi.style = kThemeTabNonFront; @@ -4251,7 +4232,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter ThemeTabDirection ttd = getTabDirection(myTab.shape); bool verticalTabs = ttd == kThemeTabWest || ttd == kThemeTabEast; bool selected = (myTab.state & QStyle::State_Selected); - bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; if (selected && !myTab.documentMode && (!usingYosemiteOrLater || myTab.state & State_Active)) @@ -4283,7 +4263,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QPalette np = tab->palette; np.setColor(QPalette::WindowText, shadowColor); - QRect nr = subElementRect(SE_TabBarTabText, opt, w); + QRect nr = proxy()->subElementRect(SE_TabBarTabText, opt, w); nr.moveTop(-1); int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, @@ -4699,7 +4679,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.value = pb->progress; tdi.attributes = vertical ? 0 : kThemeTrackHorizontal; - const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; if (isIndeterminate || (tdi.value < tdi.max && !usingYosemiteOrLater)) { if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject))) tdi.trackInfo.progress.phase = animation->animationStep(); @@ -4782,8 +4761,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter HIThemeSplitterDrawInfo sdi; sdi.version = qt_mac_hitheme_version; sdi.state = tds; - sdi.adornment = qt_mac_is_metal(w) ? kHIThemeSplitterAdornmentMetal - : kHIThemeSplitterAdornmentNone; + sdi.adornment = qt_mac_is_metal(w) || usingYosemiteOrLater ? + kHIThemeSplitterAdornmentMetal : kHIThemeSplitterAdornmentNone; HIRect hirect = qt_hirectForQRect(opt->rect); HIThemeDrawPaneSplitter(&hirect, &sdi, cg, kHIThemeOrientationNormal); } else { @@ -5318,6 +5297,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex QWindow *window = widget && widget->window() ? widget->window()->windowHandle() : QStyleHelper::styleObjectWindow(opt->styleObject); const_cast<QMacStylePrivate *>(d)->resolveCurrentNSView(window); + const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_10; switch (cc) { case CC_Slider: case CC_ScrollBar: @@ -5380,7 +5360,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // there is not enough space for them. if (cc == CC_ScrollBar) { if (opt && opt->styleObject && !QMacStylePrivate::scrollBars.contains(opt->styleObject)) - QMacStylePrivate::scrollBars.insert(QPointer<QObject>(opt->styleObject)); + QMacStylePrivate::scrollBars.append(QPointer<QObject>(opt->styleObject)); const int scrollBarLength = (slider->orientation == Qt::Horizontal) ? slider->rect.width() : slider->rect.height(); const QMacStyle::WidgetSizePolicy sizePolicy = widgetSizePolicy(widget, opt); @@ -5395,7 +5375,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex tdi.attributes |= kThemeTrackHideTrack; } - const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; const bool isHorizontal = slider->orientation == Qt::Horizontal; if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient, opt, widget)) { @@ -5771,7 +5750,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex break; case CC_ComboBox: if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)){ - const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; HIThemeButtonDrawInfo bdi; d->initComboboxBdi(combo, &bdi, widget, tds); HIRect rect = qt_hirectForQRect(combo->rect); @@ -7217,7 +7195,7 @@ CGContextRef qt_mac_cg_context(const QPaintDevice *pdev) } CGContextTranslateCTM(ret, 0, pm->height()); - int devicePixelRatio = pdev->devicePixelRatio(); + qreal devicePixelRatio = pdev->devicePixelRatioF(); CGContextScaleCTM(ret, devicePixelRatio, devicePixelRatio); CGContextScaleCTM(ret, 1, -1); return ret; |