From fc11798e8f5997dd350a9baf39e9a3124b04fdd1 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 17 Oct 2014 14:50:24 +0200 Subject: QMacStyle: Remove code depending depending on OS X 10.6 and older MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Snow Leopard is unsupported from 5.4.0. Change-Id: I0c49a8353d5dc38169ab9679a986c35ab2df8d2f Reviewed-by: Morten Johan Sørvig --- src/widgets/styles/qmacstyle_mac.mm | 155 ++++++++------------------------- src/widgets/styles/qmacstyle_mac_p_p.h | 2 - 2 files changed, 36 insertions(+), 121 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 366de2ff9f..1d4aab7686 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the QtWidgets module of the Qt Toolkit. @@ -296,14 +296,12 @@ void drawTabShape(QPainter *p, const QStyleOptionTabV3 *tabOpt, bool isUnified) p->fillRect(rect, QColor(Qt::transparent)); p->restore(); } else if (active) { - int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 16 : 0; - p->fillRect(rect, QColor(151 + d, 151 + d, 151 + d)); + p->fillRect(rect, QColor(167, 167, 167)); } else { - int d = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) ? 9 : 0; QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); - gradient.setColorAt(0, QColor(207 + d, 207 + d, 207 + d)); - gradient.setColorAt(0.5, QColor(206 + d, 206 + d, 206 + d)); - gradient.setColorAt(1, QColor(201 + d, 201 + d, 201 + d)); + gradient.setColorAt(0, QColor(216, 216, 216)); + gradient.setColorAt(0.5, QColor(215, 215, 215)); + gradient.setColorAt(1, QColor(210, 210, 210)); p->fillRect(rect, gradient); } @@ -881,13 +879,6 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg gbi.size = sz == QAquaSizeSmall ? kHIThemeGrowBoxSizeSmall : kHIThemeGrowBoxSizeNormal; if (HIThemeGetGrowBoxBounds(&p, &gbi, &r) == noErr) { int width = 0; - // Snow Leopard and older get a size grip, as well as QMdiSubWindows. - if (QSysInfo::MacintoshVersion <= QSysInfo::MV_10_6 -#ifndef QT_NO_MDIAREA - || (widg && widg->parentWidget() && qobject_cast(widg->parentWidget())) -#endif - ) - width = r.size.width; ret = QSize(width, r.size.height); } } @@ -2132,34 +2123,26 @@ QMacStyle::QMacStyle() : QCommonStyle(*new QMacStylePrivate) { Q_D(QMacStyle); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - d->receiver = [[NotificationReceiver alloc] initWithPrivate:d]; - NotificationReceiver *receiver = static_cast(d->receiver); + d->receiver = [[NotificationReceiver alloc] initWithPrivate:d]; + NotificationReceiver *receiver = static_cast(d->receiver); - [[NSNotificationCenter defaultCenter] addObserver:receiver - selector:@selector(scrollBarStyleDidChange:) - name:NSPreferredScrollerStyleDidChangeNotification - object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:receiver + selector:@selector(scrollBarStyleDidChange:) + name:NSPreferredScrollerStyleDidChangeNotification + object:nil]; - d->nsscroller = [[NSScroller alloc] init]; - } -#endif + d->nsscroller = [[NSScroller alloc] init]; d->indicatorBranchButtonCell = nil; } QMacStyle::~QMacStyle() { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 Q_D(QMacStyle); - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) { - [reinterpret_cast(d->nsscroller) release]; + [reinterpret_cast(d->nsscroller) release]; - NotificationReceiver *receiver = static_cast(d->receiver); - [[NSNotificationCenter defaultCenter] removeObserver:receiver]; - [receiver release]; - } -#endif + NotificationReceiver *receiver = static_cast(d->receiver); + [[NSNotificationCenter defaultCenter] removeObserver:receiver]; + [receiver release]; delete qt_mac_backgroundPattern; qt_mac_backgroundPattern = 0; @@ -2257,7 +2240,7 @@ void QMacStyle::polish(QWidget* w) } if (qobject_cast(w) || qobject_cast(w)) { - w->setWindowOpacity(QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 ? 0.985 : 0.94); + w->setWindowOpacity(0.985); if (!w->testAttribute(Qt::WA_SetPalette)) { QPixmap px(64, 64); px.fill(Qt::white); @@ -2542,9 +2525,7 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW } break; case PM_ScrollBarExtent: { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 && - [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) { + if ([NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) { switch (d->aquaSizeConstrain(opt, widget)) { case QAquaSizeUnknown: case QAquaSizeLarge: @@ -2557,7 +2538,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW } break; } -#endif switch (d->aquaSizeConstrain(opt, widget)) { case QAquaSizeUnknown: case QAquaSizeLarge: @@ -2748,13 +2728,8 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = 1; break; case PM_ScrollView_ScrollBarOverlap: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - ret = (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7 && - [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay) ? + ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay ? pixelMetric(PM_ScrollBarExtent, opt, widget) : 0; -#else - ret = 0; -#endif break; default: ret = QCommonStyle::pixelMetric(metric, opt, widget); @@ -3068,11 +3043,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w if ((qobject_cast(w) && w->parent() && qobject_cast(w->parent()->parent())) || (opt && QStyleHelper::hasAncestor(opt->styleObject, QAccessible::ScrollBar))) { - ret = QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if (ret) - ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay; -#endif + ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay; } break; default: @@ -3779,9 +3750,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter alignment |= Qt::TextHideMnemonic; if (down) cr.translate(shiftX, shiftY); - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5 - && (tbstyle == Qt::ToolButtonTextOnly - || (tbstyle != Qt::ToolButtonTextOnly && !down))) { + if (tbstyle == Qt::ToolButtonTextOnly + || (tbstyle != Qt::ToolButtonTextOnly && !down)) { QPen pen = p->pen(); QColor light = down ? Qt::black : Qt::white; light.setAlphaF(0.375f); @@ -3796,12 +3766,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } proxy()->drawItemText(p, cr, alignment, pal, tb->state & State_Enabled, tb->text, role); - if (QSysInfo::MacintoshVersion < QSysInfo::MV_10_5 && - (tb->state & State_Sunken)) { - // Draw a "drop shadow" in earlier versions. - proxy()->drawItemText(p, cr.adjusted(0, 1, 0, 1), alignment, - tb->palette, tb->state & State_Enabled, tb->text); - } } } else { QCommonStyle::drawControl(ce, &myTb, p, w); @@ -3928,7 +3892,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QRect rect = opt->rect; rect.adjust(0, 0, w.second == QAquaSizeSmall ? -4 : w.second == QAquaSizeMini ? -9 : -6, 0); d->drawNSViewInRect(w, pdb, rect, p); - } else if (hasMenu && bdi.state == kThemeStatePressed && QSysInfo::macVersion() > QSysInfo::MV_10_6) + } else if (hasMenu && bdi.state == kThemeStatePressed) d->drawColorlessButton(newRect, &bdi, p, opt); else HIThemeDrawButton(&newRect, &bdi, cg, kHIThemeOrientationNormal, 0); @@ -3967,16 +3931,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (hasMenu && (!yosemiteOrLater || bdi.kind == kThemeBevelButton)) { int mbi = proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, btn, w); QRect ir = btn->rect; - int arrowXOffset = 0; - if (QSysInfo::macVersion() > QSysInfo::MV_10_6) - arrowXOffset = bdi.kind == kThemePushButton ? 6 : + int arrowXOffset = bdi.kind == kThemePushButton ? 6 : bdi.kind == kThemePushButtonSmall ? 7 : 8; - int arrowYOffset; - if (QSysInfo::macVersion() > QSysInfo::MV_10_6) - arrowYOffset = bdi.kind == kThemePushButton ? 3 : + int arrowYOffset = bdi.kind == kThemePushButton ? 3 : bdi.kind == kThemePushButtonSmall ? 1 : 2; - else - arrowYOffset = bdi.kind == kThemePushButton ? 4 : 2; if (!w) { // adjustment for Qt Quick Controls arrowYOffset -= ir.top(); @@ -3992,17 +3950,10 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter pdi.version = qt_mac_hitheme_version; pdi.state = tds == kThemeStateInactive ? kThemeStateActive : tds; pdi.orientation = kThemeArrowDown; - if (QSysInfo::macVersion() > QSysInfo::MV_10_6) { - if (bdi.kind == kThemePushButtonMini) - pdi.size = kThemeArrow5pt; - else if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) - pdi.size = kThemeArrow7pt; - } else { - if (arrowRect.size.width < 8.) - pdi.size = kThemeArrow5pt; - else - pdi.size = kThemeArrow9pt; - } + if (bdi.kind == kThemePushButtonMini) + pdi.size = kThemeArrow5pt; + else if (bdi.kind == kThemePushButton || bdi.kind == kThemePushButtonSmall) + pdi.size = kThemeArrow7pt; HIThemeDrawPopupArrow(&arrowRect, &pdi, cg, kHIThemeOrientationNormal); } } @@ -4081,10 +4032,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter QRect textRect = itemTextRect( btn.fontMetrics, freeContentRect, Qt::AlignCenter, btn.state & State_Enabled, btn.text); if (hasMenu) { - if (QSysInfo::macVersion() > QSysInfo::MV_10_6) - textRect.moveTo(w ? 15 : 11, textRect.top()); // Supports Qt Quick Controls - else - textRect.adjust(-1, 0, -1, 0); + textRect.moveTo(w ? 15 : 11, textRect.top()); // Supports Qt Quick Controls } // Draw the icon: if (hasIcon) { @@ -4125,7 +4073,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter if (const QStyleOptionComboBox *cb = qstyleoption_cast(opt)) { QStyleOptionComboBox comboCopy = *cb; comboCopy.direction = Qt::LeftToRight; - if ((opt->state & QStyle::State_Small) && QSysInfo::macVersion() > QSysInfo::MV_10_6) + if (opt->state & QStyle::State_Small) comboCopy.rect.translate(0, w ? (QSysInfo::macVersion() > QSysInfo::MV_10_8 ? 0 : -1) : -2); // Supports Qt Quick Controls else if (QSysInfo::macVersion() > QSysInfo::MV_10_8) comboCopy.rect.translate(0, 1); @@ -4264,10 +4212,9 @@ 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 usingLionOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_6; bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; - if (usingLionOrLater && selected && !myTab.documentMode + if (selected && !myTab.documentMode && (!usingYosemiteOrLater || myTab.state & State_Active)) myTab.palette.setColor(QPalette::WindowText, Qt::white); @@ -4276,7 +4223,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // outside world, unless they read the source, in which case, it's // their own fault). bool nonDefaultFont = p->font() != qt_app_fonts_hash()->value("QComboMenuItem"); - bool isSelectedAndNeedsShadow = selected && usingLionOrLater && !usingYosemiteOrLater; + bool isSelectedAndNeedsShadow = selected && !usingYosemiteOrLater; if (isSelectedAndNeedsShadow || verticalTabs || nonDefaultFont || !tab->icon.isNull() || !myTab.leftButtonSize.isEmpty() || !myTab.rightButtonSize.isEmpty()) { int heightOffset = 0; @@ -4748,14 +4695,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter case CE_ProgressBarGroove: break; case CE_SizeGrip: { - // We do not draw size grips on versions > 10.6 unless it's a QMdiSubWindow - if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_6 -#ifndef QT_NO_MDIAREA - && !(w && w->parentWidget() && qobject_cast(w->parentWidget())) -#endif - ) - break; - if (w && w->testAttribute(Qt::WA_MacOpaqueSizeGrip)) { HIThemeGrowBoxDrawInfo gdi; gdi.version = qt_mac_hitheme_version; @@ -5424,7 +5363,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex const bool usingYosemiteOrLater = QSysInfo::MacintoshVersion > QSysInfo::MV_10_9; const bool isHorizontal = slider->orientation == Qt::Horizontal; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 if (cc == CC_ScrollBar && proxy()->styleHint(SH_ScrollBar_Transient, opt, widget)) { bool wasActive = false; CGFloat opacity = 0.0; @@ -5587,9 +5525,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [NSGraphicsContext restoreGraphicsState]; CGContextRestoreGState(cg); - } else -#endif - { + } else { d->stopAnimation(opt->styleObject); if (usingYosemiteOrLater && cc == CC_Slider) { @@ -5861,11 +5797,6 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex uint sc = SC_TitleBarMinButton; ThemeTitleBarWidget tbw = kThemeWidgetCollapseBox; bool active = titlebar->state & State_Active; - if (QSysInfo::macVersion() < QSysInfo::MV_10_6) { - int border = 2; - titleBarRect.origin.x += border; - titleBarRect.origin.y -= border; - } while (sc <= SC_TitleBarCloseButton) { if (sc & titlebar->subControls) { @@ -6004,23 +5935,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex path.addRoundedRect(QRectF(tb->rect.x(), tb->rect.y(), tb->rect.width(), tb->rect.height() + 4), 4, 4); p->setRenderHint(QPainter::Antialiasing); p->fillPath(path, brush); - } else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { + } else { static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png")); p->save(); p->setRenderHint(QPainter::SmoothPixmapTransform); QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2); p->restore(); - } else { - QPen oldPen = p->pen(); - p->setPen(QColor(0, 0, 0, 0x3a)); - p->fillRect(tb->rect.adjusted(1, 1, -1, -1), QColor(0, 0, 0, 0x12)); - p->drawLine(tb->rect.left() + 1, tb->rect.top(), - tb->rect.right() - 1, tb->rect.top()); - p->drawLine(tb->rect.left() + 1, tb->rect.bottom(), - tb->rect.right() - 1, tb->rect.bottom()); - p->drawLine(tb->rect.topLeft(), tb->rect.bottomLeft()); - p->drawLine(tb->rect.topRight(), tb->rect.bottomRight()); - p->setPen(oldPen); } } proxy()->drawControl(CE_ToolButtonLabel, opt, p, widget); @@ -6172,10 +6092,7 @@ QStyle::SubControl QMacStyle::hitTestComplexControl(ComplexControl cc, HIRect macSBRect = qt_hirectForQRect(sb->rect); ControlPartCode part; bool reverseHorizontal = (sb->direction == Qt::RightToLeft - && sb->orientation == Qt::Horizontal - && (!sb->upsideDown || - (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4 - && sb->upsideDown))); + && sb->orientation == Qt::Horizontal); if (HIThemeHitTestScrollBarArrows(&macSBRect, &sbi, sb->orientation == Qt::Horizontal, &pos, 0, &part)) { if (part == kControlUpButtonPart) diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 8c53dad73e..80b0afe4a4 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -222,10 +222,8 @@ public: mutable QPointer focusWidget; CFAbsoluteTime defaultButtonStart; bool mouseDown; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 void* receiver; void *nsscroller; -#endif void *indicatorBranchButtonCell; NSView *backingStoreNSView; QHash cocoaControls; -- cgit v1.2.3