From e0e1c7ec2da121fa2b3acc8e76eb96e959954608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 16 Apr 2018 15:32:30 +0200 Subject: iOS: Trigger manual layout of root view controller when coming out of background When rotating the device when the application is in the background iOS will ask the root view controller to layout its views when then foregrounding the application, but at that point the application state is still in the suspended state, meaning we block any view resizing or rendering. To ensure the views are resized correctly, we trigger a manual layout after the application comes out of the suspended state. Task-number: QTBUG-67719 Change-Id: I1ef0a4133d4b94edaac7b0f3cb4e49e367eb76d4 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/qiosapplicationstate.h | 4 +- src/plugins/platforms/ios/qiosapplicationstate.mm | 16 ++++---- src/plugins/platforms/ios/qioscontext.mm | 47 +++++++++++++---------- src/plugins/platforms/ios/qiosintegration.h | 2 + src/plugins/platforms/ios/qiosintegration.mm | 3 ++ src/plugins/platforms/ios/qiosviewcontroller.mm | 14 +++++++ 6 files changed, 55 insertions(+), 31 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosapplicationstate.h b/src/plugins/platforms/ios/qiosapplicationstate.h index a68147a72a..8a15a4a51b 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.h +++ b/src/plugins/platforms/ios/qiosapplicationstate.h @@ -56,8 +56,8 @@ public: static Qt::ApplicationState toQtApplicationState(UIApplicationState state); Q_SIGNALS: - void applicationStateWillChange(Qt::ApplicationState); - void applicationStateDidChange(Qt::ApplicationState); + void applicationStateWillChange(Qt::ApplicationState oldState, Qt::ApplicationState newState); + void applicationStateDidChange(Qt::ApplicationState oldState, Qt::ApplicationState newState); }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosapplicationstate.mm b/src/plugins/platforms/ios/qiosapplicationstate.mm index 3407aebf8f..6d9bcdacbf 100644 --- a/src/plugins/platforms/ios/qiosapplicationstate.mm +++ b/src/plugins/platforms/ios/qiosapplicationstate.mm @@ -87,18 +87,18 @@ QIOSApplicationState::QIOSApplicationState() void QIOSApplicationState::handleApplicationStateChanged(UIApplicationState uiState, const QString &reason) { - Qt::ApplicationState state = toQtApplicationState(uiState); - qCDebug(lcQpaApplication) << qPrintable(reason) - << "- moving from" << QGuiApplication::applicationState() << "to" << state; + Qt::ApplicationState oldState = QGuiApplication::applicationState(); + Qt::ApplicationState newState = toQtApplicationState(uiState); + qCDebug(lcQpaApplication) << qPrintable(reason) << "- moving from" << oldState << "to" << newState; if (QIOSIntegration *integration = QIOSIntegration::instance()) { - emit integration->applicationState.applicationStateWillChange(state); - QWindowSystemInterface::handleApplicationStateChanged(state); - emit integration->applicationState.applicationStateDidChange(state); - qCDebug(lcQpaApplication) << "done moving to" << state; + emit integration->applicationState.applicationStateWillChange(oldState, newState); + QWindowSystemInterface::handleApplicationStateChanged(newState); + emit integration->applicationState.applicationStateDidChange(oldState, newState); + qCDebug(lcQpaApplication) << "done moving to" << newState; } else { qCDebug(lcQpaApplication) << "no platform integration yet, setting state directly"; - QGuiApplicationPrivate::applicationState = state; + QGuiApplicationPrivate::applicationState = newState; } } diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 03643c19a9..fff66049ff 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -301,29 +301,34 @@ bool QIOSContext::verifyGraphicsHardwareAvailability() static dispatch_once_t onceToken = 0; dispatch_once(&onceToken, ^{ QIOSApplicationState *applicationState = &QIOSIntegration::instance()->applicationState; - connect(applicationState, &QIOSApplicationState::applicationStateWillChange, [](Qt::ApplicationState state) { - if (applicationBackgrounded && state != Qt::ApplicationSuspended) { - qCDebug(lcQpaGLContext) << "app no longer backgrounded, rendering enabled"; - applicationBackgrounded = false; + connect(applicationState, &QIOSApplicationState::applicationStateWillChange, + [](Qt::ApplicationState oldState, Qt::ApplicationState newState) { + Q_UNUSED(oldState); + if (applicationBackgrounded && newState != Qt::ApplicationSuspended) { + qCDebug(lcQpaGLContext) << "app no longer backgrounded, rendering enabled"; + applicationBackgrounded = true; + } } - }); - connect(applicationState, &QIOSApplicationState::applicationStateDidChange, [](Qt::ApplicationState state) { - if (state != Qt::ApplicationSuspended) - return; - - qCDebug(lcQpaGLContext) << "app backgrounded, rendering disabled"; - applicationBackgrounded = true; - - // By the time we receive this signal the application has moved into - // Qt::ApplactionStateSuspended, and all windows have been obscured, - // which should stop all rendering. If there's still an active GL context, - // we follow Apple's advice and call glFinish before making it inactive. - if (QOpenGLContext *currentContext = QOpenGLContext::currentContext()) { - qCWarning(lcQpaGLContext) << "explicitly glFinishing and deactivating" << currentContext; - glFinish(); - currentContext->doneCurrent(); + ); + connect(applicationState, &QIOSApplicationState::applicationStateDidChange, + [](Qt::ApplicationState oldState, Qt::ApplicationState newState) { + Q_UNUSED(oldState); + if (newState != Qt::ApplicationSuspended) + return; + + qCDebug(lcQpaGLContext) << "app backgrounded, rendering disabled"; + + // By the time we receive this signal the application has moved into + // Qt::ApplactionStateSuspended, and all windows have been obscured, + // which should stop all rendering. If there's still an active GL context, + // we follow Apple's advice and call glFinish before making it inactive. + if (QOpenGLContext *currentContext = QOpenGLContext::currentContext()) { + qCWarning(lcQpaGLContext) << "explicitly glFinishing and deactivating" << currentContext; + glFinish(); + currentContext->doneCurrent(); + } } - }); + ); }); if (applicationBackgrounded) { diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index 6be8855020..818250fcee 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -62,6 +62,8 @@ public: QIOSIntegration(); ~QIOSIntegration(); + void initialize() override; + bool hasCapability(Capability cap) const override; QPlatformWindow *createPlatformWindow(QWindow *window) const override; diff --git a/src/plugins/platforms/ios/qiosintegration.mm b/src/plugins/platforms/ios/qiosintegration.mm index 92c1e39d72..2e657b3798 100644 --- a/src/plugins/platforms/ios/qiosintegration.mm +++ b/src/plugins/platforms/ios/qiosintegration.mm @@ -95,7 +95,10 @@ QIOSIntegration::QIOSIntegration() // Set current directory to app bundle folder QDir::setCurrent(QString::fromUtf8([[[NSBundle mainBundle] bundlePath] UTF8String])); +} +void QIOSIntegration::initialize() +{ UIScreen *mainScreen = [UIScreen mainScreen]; NSMutableArray *screens = [[[UIScreen screens] mutableCopy] autorelease]; if (![screens containsObject:mainScreen]) { diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index a7663b9e94..d7db6ba856 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -273,6 +273,20 @@ m_focusWindowChangeConnection = QObject::connect(qApp, &QGuiApplication::focusWindowChanged, [self]() { [self updateProperties]; }); + + QIOSApplicationState *applicationState = &QIOSIntegration::instance()->applicationState; + QObject::connect(applicationState, &QIOSApplicationState::applicationStateDidChange, + [self](Qt::ApplicationState oldState, Qt::ApplicationState newState) { + if (oldState == Qt::ApplicationSuspended && newState != Qt::ApplicationSuspended) { + // We may have ignored an earlier layout because the application was suspended, + // and we didn't want to render anything at that moment in fear of being killed + // due to rendering in the background, so we trigger an explicit layout when + // coming out of the suspended state. + qCDebug(lcQpaWindow) << "triggering root VC layout when coming out of suspended state"; + [self.view setNeedsLayout]; + } + } + ); } return self; -- cgit v1.2.3 From be4eaca053eba747c0458e37ce68ae3db1e6a288 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Mon, 16 Apr 2018 15:20:40 +0200 Subject: Do not ignore MenuItem on macOS The idea was probably to ignore it since macOS already provides accessibility for a menu item in its native system menu. However, a Qt Quick Controls2 Menu will instead show a non-native menu, which should not be ignored. Task-number: QTBUG-63522 Change-Id: Ib5ae16ad991ebd7a18fa73b8f576f20b1c14d4c8 Reviewed-by: Frederik Gladhorn --- src/plugins/platforms/cocoa/qcocoaaccessibility.mm | 1 - 1 file changed, 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index 8b6dcb35a6..654e6210c8 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -226,7 +226,6 @@ bool shouldBeIgnored(QAccessibleInterface *interface) const QAccessible::Role role = interface->role(); if (role == QAccessible::Border || // QFrame role == QAccessible::Application || // We use the system-provided application element. - role == QAccessible::MenuItem || // The system also provides the menu items. role == QAccessible::ToolBar || // Access the tool buttons directly. role == QAccessible::Pane || // Scroll areas. role == QAccessible::Client) // The default for QWidget. -- cgit v1.2.3 From 48900145a4e62db95dee812a1d9ac6331e19bc4b Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 4 Apr 2018 10:15:24 -0700 Subject: QMacStyle: Clean up code, remove dead bits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change QMacStylePrivate::drawNSViewInRect() signature to remove all the unused parameters. Reuse recent tab direction functions where appropriate. Includes the infamous outter -> outer fix. Change-Id: I8f92d79d8a6c3b5903bfbb13293afb6f72a5340b Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 233 +++++++++-------------------- src/plugins/styles/mac/qmacstyle_mac_p_p.h | 9 +- 2 files changed, 72 insertions(+), 170 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 225bd77239..81abbc6caf 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -43,7 +43,6 @@ */ #include -#include #include "qmacstyle_mac_p.h" #include "qmacstyle_mac_p_p.h" @@ -273,13 +272,7 @@ QT_BEGIN_NAMESPACE // The following constants are used for adjusting the size // of push buttons so that they are drawn inside their bounds. const int QMacStylePrivate::PushButtonLeftOffset = 6; -const int QMacStylePrivate::PushButtonTopOffset = 4; const int QMacStylePrivate::PushButtonRightOffset = 12; -const int QMacStylePrivate::PushButtonBottomOffset = 12; -const int QMacStylePrivate::MiniButtonH = 26; -const int QMacStylePrivate::SmallButtonH = 30; -const int QMacStylePrivate::BevelButtonW = 50; -const int QMacStylePrivate::BevelButtonH = 22; const int QMacStylePrivate::PushButtonContentPadding = 6; QVector > QMacStylePrivate::scrollBars; @@ -389,15 +382,6 @@ static const int toolButtonArrowMargin = 2; static const qreal focusRingWidth = 3.5; -#if QT_CONFIG(tabbar) -static bool isVerticalTabs(const QTabBar::Shape shape) { - return (shape == QTabBar::RoundedEast - || shape == QTabBar::TriangularEast - || shape == QTabBar::RoundedWest - || shape == QTabBar::TriangularWest); -} -#endif - static bool setupScroller(NSScroller *scroller, const QStyleOptionSlider *sb) { const qreal length = sb->maximum - sb->minimum + sb->pageStep; @@ -502,10 +486,10 @@ static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pres #if QT_CONFIG(tabbar) QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) { - if (isVerticalTabs(shape)) { + const auto tabDirection = QMacStylePrivate::tabDirection(shape); + if (QMacStylePrivate::verticalTabs(tabDirection)) { int newX, newY, newRot; - if (shape == QTabBar::RoundedEast - || shape == QTabBar::TriangularEast) { + if (tabDirection == QMacStylePrivate::East) { newX = tabRect.width(); newY = tabRect.y(); newRot = 90; @@ -526,23 +510,10 @@ QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, int tabOverlap) { QRect rect = tabOpt->rect; - - switch (tabOpt->shape) { - case QTabBar::RoundedNorth: - case QTabBar::TriangularNorth: - case QTabBar::RoundedSouth: - case QTabBar::TriangularSouth: - rect.adjust(-tabOverlap, 0, 0, 0); - break; - case QTabBar::RoundedEast: - case QTabBar::TriangularEast: - case QTabBar::RoundedWest: - case QTabBar::TriangularWest: - rect.adjust(0, -tabOverlap, 0, 0); - break; - default: - break; - } + if (QMacStylePrivate::verticalTabs(QMacStylePrivate::tabDirection(tabOpt->shape))) + rect = rect.adjusted(-tabOverlap, 0, 0, 0); + else + rect = rect.adjusted(0, -tabOverlap, 0, 0); p->translate(rect.x(), rect.y()); rect.moveLeft(0); @@ -593,11 +564,11 @@ void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, in void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget *w) { QRect r = tbb->rect; - if (isVerticalTabs(tbb->shape)) { + if (QMacStylePrivate::verticalTabs(QMacStylePrivate::tabDirection(tbb->shape))) r.setWidth(w->width()); - } else { + else r.setHeight(w->height()); - } + const QRect tabRect = rotateTabPainter(p, tbb->shape, r); const int width = tabRect.width(); const int height = tabRect.height(); @@ -633,8 +604,7 @@ static QStyleHelper::WidgetSizePolicy getControlSize(const QStyleOption *option, static inline bool isTreeView(const QWidget *widget) { return (widget && widget->parentWidget() && - (qobject_cast(widget->parentWidget()) - )); + qobject_cast(widget->parentWidget())); } #endif @@ -672,15 +642,6 @@ static QString qt_mac_removeMnemonics(const QString &original) return returnText; } -bool qt_macWindowIsTextured(const QWidget *window) -{ - if (QWindow *w = window->windowHandle()) - if (w->handle()) - if (NSWindow *nswindow = static_cast(QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("NSWindow"), w))) - return ([nswindow styleMask] & NSTexturedBackgroundWindowMask) ? true : false; - return false; -} - static bool qt_macWindowMainWindow(const QWidget *window) { if (QWindow *w = window->windowHandle()) { @@ -1118,51 +1079,11 @@ static QStyleHelper::WidgetSizePolicy qt_aqua_guess_size(const QWidget *widg, QS return QStyleHelper::SizeLarge; } -#if QT_CONFIG(mainwindow) - if (qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) { - //if (small.width() != -1 || small.height() != -1) + if (qEnvironmentVariableIsSet("QWIDGET_ALL_SMALL")) return QStyleHelper::SizeSmall; - } else if (qEnvironmentVariableIsSet("QWIDGET_ALL_MINI")) { + else if (qEnvironmentVariableIsSet("QWIDGET_ALL_MINI")) return QStyleHelper::SizeMini; - } -#endif -#if 0 - /* Figure out which size we're closer to, I just hacked this in, I haven't - tested it as it would probably look pretty strange to have some widgets - big and some widgets small in the same window?? -Sam */ - int large_delta=0; - if (large.width() != -1) { - int delta = large.width() - widg->width(); - large_delta += delta * delta; - } - if (large.height() != -1) { - int delta = large.height() - widg->height(); - large_delta += delta * delta; - } - int small_delta=0; - if (small.width() != -1) { - int delta = small.width() - widg->width(); - small_delta += delta * delta; - } - if (small.height() != -1) { - int delta = small.height() - widg->height(); - small_delta += delta * delta; - } - int mini_delta=0; - if (mini.width() != -1) { - int delta = mini.width() - widg->width(); - mini_delta += delta * delta; - } - if (mini.height() != -1) { - int delta = mini.height() - widg->height(); - mini_delta += delta * delta; - } - if (mini_delta < small_delta && mini_delta < large_delta) - return QStyleHelper::SizeMini; - else if (small_delta < large_delta) - return QStyleHelper::SizeSmall; -#endif return QStyleHelper::SizeLarge; } #endif @@ -1182,10 +1103,10 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int auto innerRect = targetRect; if (cw.type == TextField) innerRect = innerRect.adjusted(hMargin, vMargin, -hMargin, -vMargin).adjusted(0.5, 0.5, -0.5, -0.5); - const auto outterRect = innerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); - const auto outterRadius = focusRingWidth; + const auto outerRect = innerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); + const auto outerRadius = focusRingWidth; focusRingPath.addRect(innerRect); - focusRingPath.addRoundedRect(outterRect, outterRadius, outterRadius); + focusRingPath.addRoundedRect(outerRect, outerRadius, outerRadius); break; } case Button_CheckBox: { @@ -1196,9 +1117,9 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int cw.size == QStyleHelper::SizeSmall ? 2.0 : 1.0); // As measured vOffset = 0.5 * qreal(targetRect.height() - cbSize); const auto cbInnerRect = QRectF(0, 0, cbSize, cbSize); - const auto cbOutterRadius = cbInnerRadius + focusRingWidth; - const auto cbOutterRect = cbInnerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); - focusRingPath.addRoundedRect(cbOutterRect, cbOutterRadius, cbOutterRadius); + const auto cbOuterRadius = cbInnerRadius + focusRingWidth; + const auto cbOuterRect = cbInnerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); + focusRingPath.addRoundedRect(cbOuterRect, cbOuterRadius, cbOuterRadius); focusRingPath.addRoundedRect(cbInnerRect, cbInnerRadius, cbInnerRadius); break; } @@ -1209,9 +1130,9 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int cw.size == QStyleHelper::SizeSmall ? 1.0 : 1.0); // As measured vOffset = 0.5 * qreal(targetRect.height() - rbSize); const auto rbInnerRect = QRectF(0, 0, rbSize, rbSize); - const auto rbOutterRect = rbInnerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); + const auto rbOuterRect = rbInnerRect.adjusted(-focusRingWidth, -focusRingWidth, focusRingWidth, focusRingWidth); focusRingPath.addEllipse(rbInnerRect); - focusRingPath.addEllipse(rbOutterRect); + focusRingPath.addEllipse(rbOuterRect); break; } case Button_PopupButton: @@ -1219,13 +1140,13 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int case Button_PushButton: case SegmentedControl_Single: { const qreal innerRadius = cw.type == Button_PushButton ? 3 : 4; - const qreal outterRadius = innerRadius + focusRingWidth; + const qreal outerRadius = innerRadius + focusRingWidth; hOffset = targetRect.left(); vOffset = targetRect.top(); const auto innerRect = targetRect.translated(-targetRect.topLeft()); - const auto outterRect = innerRect.adjusted(-hMargin, -vMargin, hMargin, vMargin); + const auto outerRect = innerRect.adjusted(-hMargin, -vMargin, hMargin, vMargin); focusRingPath.addRoundedRect(innerRect, innerRadius, innerRadius); - focusRingPath.addRoundedRect(outterRect, outterRadius, outterRadius); + focusRingPath.addRoundedRect(outerRect, outerRadius, outerRadius); break; } case ComboBox: @@ -1234,9 +1155,9 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int hOffset = targetRect.left(); vOffset = targetRect.top(); const qreal innerRadius = 8; - const qreal outterRadius = innerRadius + focusRingWidth; + const qreal outerRadius = innerRadius + focusRingWidth; const auto innerRect = targetRect.translated(-targetRect.topLeft()); - const auto outterRect = innerRect.adjusted(-hMargin, -vMargin, hMargin, vMargin); + const auto outerRect = innerRect.adjusted(-hMargin, -vMargin, hMargin, vMargin); const auto cbFocusFramePath = [](const QRectF &rect, qreal tRadius, qreal bRadius) { QPainterPath path; @@ -1262,8 +1183,8 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRectF &targetRect, int const auto innerPath = cbFocusFramePath(innerRect, 0, innerRadius); focusRingPath.addPath(innerPath); - const auto outterPath = cbFocusFramePath(outterRect, 2 * focusRingWidth, outterRadius); - focusRingPath.addPath(outterPath); + const auto outerPath = cbFocusFramePath(outerRect, 2 * focusRingWidth, outerRadius); + focusRingPath.addPath(outerPath); break; } default: @@ -1422,6 +1343,12 @@ QMacStylePrivate::Direction QMacStylePrivate::tabDirection(QTabBar::Shape shape) } } +bool QMacStylePrivate::verticalTabs(QMacStylePrivate::Direction direction) +{ + return (direction == QMacStylePrivate::East + || direction == QMacStylePrivate::West); +} + #endif // QT_CONFIG(tabbar) QStyleHelper::WidgetSizePolicy QMacStylePrivate::effectiveAquaSizeConstrain(const QStyleOption *option, @@ -1609,7 +1536,6 @@ QMarginsF QMacStylePrivate::CocoaControl::titleMargins() const return QMarginsF(); } - bool QMacStylePrivate::CocoaControl::getCocoaButtonTypeAndBezelStyle(NSButtonType *buttonType, NSBezelStyle *bezelStyle) const { switch (type) { @@ -1670,9 +1596,9 @@ QMacStylePrivate::CocoaControlType cocoaControlType(const QStyleOption *opt, con Carbon draws comboboxes (and other views) outside the rect given as argument. Use this function to obtain the corresponding inner rect for drawing the same combobox so that it stays inside the given outerBounds. */ -CGRect QMacStylePrivate::comboboxInnerBounds(const CGRect &outterBounds, const CocoaControl &cocoaWidget) +CGRect QMacStylePrivate::comboboxInnerBounds(const CGRect &outerBounds, const CocoaControl &cocoaWidget) { - CGRect innerBounds = outterBounds; + CGRect innerBounds = outerBounds; // Carbon draw parts of the view outside the rect. // So make the rect a bit smaller to compensate // (I wish HIThemeGetButtonBackgroundBounds worked) @@ -1727,9 +1653,9 @@ CGRect QMacStylePrivate::comboboxInnerBounds(const CGRect &outterBounds, const C Inside a combobox Qt places a line edit widget. The size of this widget should depend on the kind of combobox we choose to draw. This function calculates and returns this size. */ -QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outterBounds, const CocoaControl &cw) +QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const CocoaControl &cw) { - QRectF ret = outterBounds; + QRectF ret = outerBounds; if (cw.type == ComboBox) { switch (cw.size) { case QStyleHelper::SizeLarge: @@ -1785,27 +1711,12 @@ QMacStylePrivate::~QMacStylePrivate() [cell release]; } -#if 0 -ThemeDrawState QMacStylePrivate::getDrawState(QStyle::State flags) -{ - ThemeDrawState tds = kThemeStateActive; - if (flags & QStyle::State_Sunken) { - tds = kThemeStatePressed; - } else if (flags & QStyle::State_Active) { - if (!(flags & QStyle::State_Enabled)) - tds = kThemeStateUnavailable; - } else { - if (flags & QStyle::State_Enabled) - tds = kThemeStateInactive; - else - tds = kThemeStateUnavailableInactive; - } - return tds; -} -#endif - NSView *QMacStylePrivate::cocoaControl(CocoaControl widget) const { + if (widget.type == QMacStylePrivate::NoControl + || widget.size == QStyleHelper::SizeDefault) + return nil; + NSView *bv = cocoaControls.value(widget, nil); if (!bv) { switch (widget.type) { @@ -1987,15 +1898,13 @@ NSCell *QMacStylePrivate::cocoaCell(CocoaControl widget) const return cell; } -void QMacStylePrivate::drawNSViewInRect(CocoaControl widget, NSView *view, const QRectF &qtRect, QPainter *p, bool isQWidget, __attribute__((noescape)) DrawRectBlock drawRectBlock) const +void QMacStylePrivate::drawNSViewInRect(NSView *view, const QRectF &qtRect, QPainter *p, + __attribute__((noescape)) DrawRectBlock drawRectBlock) const { - Q_UNUSED(isQWidget); - Q_UNUSED(widget); - QMacCGContext ctx(p); setupNSGraphicsContext(ctx, YES); - const CGRect rect = CGRectMake(qtRect.x(), qtRect.y(), qtRect.width(), qtRect.height()); + const CGRect rect = qtRect.toCGRect(); [backingStoreNSView addSubview:view]; view.frame = rect; @@ -3003,9 +2912,9 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai case PE_FrameTabWidget: #endif { - const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Box, QStyleHelper::SizeDefault); + const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Box, QStyleHelper::SizeLarge); auto *box = static_cast(d->cocoaControl(cw)); - d->drawNSViewInRect(cw, box, opt->rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) { + d->drawNSViewInRect(box, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { CGContextTranslateCTM(ctx, 0, rect.origin.y + rect.size.height); CGContextScaleCTM(ctx, 1, -1); [box drawRect:rect]; @@ -3165,7 +3074,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai return cs == QStyleHelper::SizeSmall ? 0.5 : 0.0; } (); - d->drawNSViewInRect(cw, tb, opt->rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) { + d->drawNSViewInRect(tb, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { CGContextTranslateCTM(ctx, 0, vOffset); [tb.cell drawInteriorWithFrame:rect inView:tb]; }); @@ -3176,7 +3085,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai case PE_IndicatorBranch: { if (!(opt->state & State_Children)) break; - const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Button_Disclosure, QStyleHelper::SizeLarge); + const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::Button_Disclosure, QStyleHelper::SizeLarge); NSButtonCell *triangleCell = static_cast(d->cocoaCell(cw)); [triangleCell setState:(opt->state & State_Open) ? NSOnState : NSOffState]; bool viewHasFocus = (w && w->hasFocus()) || (opt->state & State_HasFocus); @@ -3218,7 +3127,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai tf.bezeled = YES; static_cast(tf.cell).bezelStyle = isRounded ? NSTextFieldRoundedBezel : NSTextFieldSquareBezel; tf.frame = opt->rect.toCGRect(); - d->drawNSViewInRect(cw, tf, opt->rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) { + d->drawNSViewInRect(tf, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { Q_UNUSED(ctx); [tf.cell drawWithFrame:rect inView:tf]; }); @@ -3308,7 +3217,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } } -static inline QPixmap darkenPixmap(const QPixmap &pixmap) +static QPixmap darkenPixmap(const QPixmap &pixmap) { QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32); int imgh = img.height(); @@ -3331,8 +3240,6 @@ static inline QPixmap darkenPixmap(const QPixmap &pixmap) return QPixmap::fromImage(img); } - - void QMacStylePrivate::setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const { if (vertical) { @@ -3552,7 +3459,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter pb.enabled = isEnabled; [pb highlight:isPressed]; pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState; - d->drawNSViewInRect(cw, pb, frameRect, p, true, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { [pb.cell drawBezelWithFrame:r inView:pb.superview]; }); [pb highlight:NO]; @@ -3732,7 +3639,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter auto vOffset = isSelected ? 2 : 1; if (tabDirection == QMacStylePrivate::East) vOffset -= 1; - const auto outterAdjust = isSelected ? 4 : 1; + const auto outerAdjust = isSelected ? 4 : 1; const auto innerAdjust = isSelected ? 10 : 20; QRectF frameRect = tabOpt->rect; if (verticalTabs) @@ -3743,9 +3650,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter case QStyleOptionTab::Beginning: // Pressed state hack: tweak adjustments in preparation for flip below if (!isSelected && tabDirection == QMacStylePrivate::West) - frameRect = frameRect.adjusted(-innerAdjust, 0, outterAdjust, 0); + frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0); else - frameRect = frameRect.adjusted(-outterAdjust, 0, innerAdjust, 0); + frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0); break; case QStyleOptionTab::Middle: frameRect = frameRect.adjusted(-innerAdjust, 0, innerAdjust, 0); @@ -3753,12 +3660,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter case QStyleOptionTab::End: // Pressed state hack: tweak adjustments in preparation for flip below if (isSelected || tabDirection == QMacStylePrivate::West) - frameRect = frameRect.adjusted(-innerAdjust, 0, outterAdjust, 0); + frameRect = frameRect.adjusted(-innerAdjust, 0, outerAdjust, 0); else - frameRect = frameRect.adjusted(-outterAdjust, 0, innerAdjust, 0); + frameRect = frameRect.adjusted(-outerAdjust, 0, innerAdjust, 0); break; case QStyleOptionTab::OnlyOneTab: - frameRect = frameRect.adjusted(-outterAdjust, 0, outterAdjust, 0); + frameRect = frameRect.adjusted(-outerAdjust, 0, outerAdjust, 0); break; } pb.frame = frameRect.toCGRect(); @@ -3766,7 +3673,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter pb.enabled = isEnabled; [pb highlight:isPressed]; pb.state = isSelected && !isPressed ? NSOnState : NSOffState; - d->drawNSViewInRect(cw, pb, frameRect, p, true, ^(CGContextRef ctx, const CGRect &r) { + d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef ctx, const CGRect &r) { CGContextClipToRect(ctx, opt->rect.toCGRect()); if (!isSelected) { // Final stage of the pressed state hack: flip NSPopupButton rendering @@ -4203,7 +4110,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const auto cw = QMacStylePrivate::CocoaControl(QMacStylePrivate::ProgressIndicator_Determinate, aquaSize); auto *pi = static_cast(d->cocoaControl(cw)); - d->drawNSViewInRect(cw, pi, rect, p, w != nullptr, ^(CGContextRef ctx, const CGRect &rect) { + d->drawNSViewInRect(pi, rect, p, ^(CGContextRef ctx, const CGRect &rect) { d->setupVerticalInvertedXform(ctx, reverse, vertical, rect); pi.minValue = pb->minimum; pi.maxValue = pb->maximum; @@ -4253,7 +4160,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter const auto cw = QMacStylePrivate::CocoaControl(ct, QStyleHelper::SizeLarge); auto *sv = static_cast(d->cocoaControl(cw)); sv.frame = opt->rect.toCGRect(); - d->drawNSViewInRect(cw, sv, opt->rect, p, w != nullptr, ^(CGContextRef __unused ctx, const CGRect &rect) { + d->drawNSViewInRect(sv, opt->rect, p, ^(CGContextRef __unused ctx, const CGRect &rect) { [sv drawDividerInRect:rect]; }); } else { @@ -5098,7 +5005,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [slider.cell startTrackingAt:pressPoint inView:slider]; } - d->drawNSViewInRect(cw, slider, opt->rect, p, widget != 0, ^(CGContextRef ctx, const CGRect &rect) { + d->drawNSViewInRect(slider, opt->rect, p, ^(CGContextRef ctx, const CGRect &rect) { if (isHorizontal && sl->upsideDown) { CGContextTranslateCTM(ctx, rect.size.width, 0); CGContextScaleCTM(ctx, -1, 1); @@ -5260,7 +5167,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex } pb.frame = frameRect.toCGRect(); [pb highlight:isPressed]; - d->drawNSViewInRect(cw, pb, frameRect, p, widget != 0, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { [pb.cell drawBezelWithFrame:r inView:pb.superview]; }); } else if (cw.type == QMacStylePrivate::ComboBox) { @@ -5273,7 +5180,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex #else // TODO Render to pixmap and darken the button manually #endif - d->drawNSViewInRect(cw, cb, frameRect, p, widget != 0, ^(CGContextRef __unused ctx, const CGRect &r) { + d->drawNSViewInRect(cb, frameRect, p, ^(CGContextRef __unused ctx, const CGRect &r) { // FIXME This is usually drawn in the control's superview, but we wouldn't get inactive look in this case [cb.cell drawWithFrame:r inView:cb]; }); @@ -5310,12 +5217,12 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex // FIXME A single drawPath() with 0-sized pen // doesn't look as good as this double fillPath(). - const auto outterFrameRect = QRectF(opt->rect.adjusted(0, 0, 0, opt->rect.height())); - QPainterPath outterFramePath = d->windowPanelPath(outterFrameRect); - p->fillPath(outterFramePath, opt->palette.dark()); + const auto outerFrameRect = QRectF(opt->rect.adjusted(0, 0, 0, opt->rect.height())); + QPainterPath outerFramePath = d->windowPanelPath(outerFrameRect); + p->fillPath(outerFramePath, opt->palette.dark()); const auto frameAdjust = 1.0 / p->device()->devicePixelRatioF(); - const auto innerFrameRect = outterFrameRect.adjusted(frameAdjust, frameAdjust, -frameAdjust, 0); + const auto innerFrameRect = outerFrameRect.adjusted(frameAdjust, frameAdjust, -frameAdjust, 0); QPainterPath innerFramePath = d->windowPanelPath(innerFrameRect); if (isActive) { QLinearGradient g; @@ -5351,7 +5258,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex auto *wbCell = static_cast(wb.cell); [wbCell drawWithFrame:rect inView:wb]; }; - d->drawNSViewInRect(cw, wb, buttonRect, p, widget != nullptr, drawBlock); + d->drawNSViewInRect(wb, buttonRect, p, drawBlock); } } @@ -5461,7 +5368,7 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex [pb highlight:isPressed]; pb.state = isHighlighted && !isPressed ? NSOnState : NSOffState; const auto buttonRect = proxy()->subControlRect(cc, tb, SC_ToolButton, widget); - d->drawNSViewInRect(cw, pb, buttonRect, p, ^(CGContextRef __unused ctx, const CGRect &rect) { + d->drawNSViewInRect(pb, buttonRect, p, ^(CGContextRef __unused ctx, const CGRect &rect) { [pb.cell drawBezelWithFrame:rect inView:pb]; }); } diff --git a/src/plugins/styles/mac/qmacstyle_mac_p_p.h b/src/plugins/styles/mac/qmacstyle_mac_p_p.h index 2a81274765..4eac0a59d6 100644 --- a/src/plugins/styles/mac/qmacstyle_mac_p_p.h +++ b/src/plugins/styles/mac/qmacstyle_mac_p_p.h @@ -236,13 +236,7 @@ public: // Ideally these wouldn't exist, but since they already exist we need some accessors. static const int PushButtonLeftOffset; - static const int PushButtonTopOffset; static const int PushButtonRightOffset; - static const int PushButtonBottomOffset; - static const int MiniButtonH; - static const int SmallButtonH; - static const int BevelButtonW; - static const int BevelButtonH; static const int PushButtonContentPadding; enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar }; @@ -269,7 +263,7 @@ public: void setupVerticalInvertedXform(CGContextRef cg, bool reverse, bool vertical, const CGRect &rect) const; - void drawNSViewInRect(CocoaControl widget, NSView *view, const QRectF &rect, QPainter *p, bool isQWidget = true, __attribute__((noescape)) DrawRectBlock drawRectBlock = nil) const; + void drawNSViewInRect(NSView *view, const QRectF &rect, QPainter *p, __attribute__((noescape)) DrawRectBlock drawRectBlock = nil) const; void resolveCurrentNSView(QWindow *window) const; void drawFocusRing(QPainter *p, const QRectF &targetRect, int hMargin, int vMargin, const CocoaControl &cw) const; @@ -283,6 +277,7 @@ public: #if QT_CONFIG(tabbar) void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const; static Direction tabDirection(QTabBar::Shape shape); + static bool verticalTabs(QMacStylePrivate::Direction tabDirection); #endif public: -- cgit v1.2.3 From 85cb183488a821a23a15710dc610dd0e506f72f5 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 11 Apr 2018 11:40:49 -0700 Subject: QMacStyle: Fix appearance of selected inactive tab bar button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Because we use toggle NSButton for selected tabs, the inactive appearance doesn't follow what NSSegmentedControl would have shown. Therefore, we fall back to our good old habits, i.e., render on a pixmap and do some pixel transformations. Change-Id: I838a2f23abee5846219ba67328c79fa8cc359a9b Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 59 ++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 9 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 81abbc6caf..4dc3cfd634 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -3602,6 +3602,7 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter return; } + const bool isActive = tabOpt->state & State_Active; const bool isEnabled = tabOpt->state & State_Enabled; const bool isPressed = tabOpt->state & State_Sunken; const bool isSelected = tabOpt->state & State_Selected; @@ -3630,17 +3631,20 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter // a push NSButton instead and clip the CGContext. const auto cs = d->effectiveAquaSizeConstrain(opt, w); - // Extra hack to get the proper pressed appreance when not selected - const auto ct = isSelected || tp == QStyleOptionTab::OnlyOneTab ? + // Extra hacks to get the proper pressed appreance when not selected or selected and inactive + const bool needsInactiveHack = (!isActive && isSelected); + const auto ct = !needsInactiveHack && (isSelected || tp == QStyleOptionTab::OnlyOneTab) ? QMacStylePrivate::Button_PushButton : QMacStylePrivate::Button_PopupButton; + const bool isPopupButton = ct == QMacStylePrivate::Button_PopupButton; const auto cw = QMacStylePrivate::CocoaControl(ct, cs); auto *pb = static_cast(d->cocoaControl(cw)); - auto vOffset = isSelected ? 2 : 1; + + auto vOffset = isPopupButton ? 1 : 2; if (tabDirection == QMacStylePrivate::East) vOffset -= 1; - const auto outerAdjust = isSelected ? 4 : 1; - const auto innerAdjust = isSelected ? 10 : 20; + const auto outerAdjust = isPopupButton ? 1 : 4; + const auto innerAdjust = isPopupButton ? 20 : 10; QRectF frameRect = tabOpt->rect; if (verticalTabs) frameRect = QRectF(frameRect.y(), frameRect.x(), frameRect.height(), frameRect.width()); @@ -3672,10 +3676,12 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter pb.enabled = isEnabled; [pb highlight:isPressed]; - pb.state = isSelected && !isPressed ? NSOnState : NSOffState; - d->drawNSViewInRect(pb, frameRect, p, ^(CGContextRef ctx, const CGRect &r) { + // Set off state when inactive. See needsInactiveHack for when it's selected + pb.state = (isActive && isSelected && !isPressed) ? NSOnState : NSOffState; + + const auto drawBezelBlock = ^(CGContextRef ctx, const CGRect &r) { CGContextClipToRect(ctx, opt->rect.toCGRect()); - if (!isSelected) { + if (!isSelected || needsInactiveHack) { // Final stage of the pressed state hack: flip NSPopupButton rendering if (!verticalTabs && tp == QStyleOptionTab::End) { CGContextTranslateCTM(ctx, opt->rect.right(), 0); @@ -3703,7 +3709,42 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } [pb.cell drawBezelWithFrame:r inView:pb.superview]; - }); + }; + + if (needsInactiveHack) { + // First, render tab as non-selected tab on a pixamp + const qreal pixelRatio = p->device()->devicePixelRatioF(); + QImage tabPixmap(opt->rect.size() * pixelRatio, QImage::Format_ARGB32_Premultiplied); + tabPixmap.setDevicePixelRatio(pixelRatio); + tabPixmap.fill(Qt::transparent); + QPainter tabPainter(&tabPixmap); + d->drawNSViewInRect(pb, frameRect, &tabPainter, ^(CGContextRef ctx, const CGRect &r) { + CGContextTranslateCTM(ctx, -opt->rect.left(), -opt->rect.top()); + drawBezelBlock(ctx, r); + }); + tabPainter.end(); + + // Then, darken it with the proper shade of gray + const qreal inactiveGray = 0.898; // As measured + const int inactiveGray8 = qRound(inactiveGray * 255.0); + const QRgb inactiveGrayRGB = qRgb(inactiveGray8, inactiveGray8, inactiveGray8); + for (int l = 0; l < tabPixmap.height(); ++l) { + auto *line = reinterpret_cast(tabPixmap.scanLine(l)); + for (int i = 0; i < tabPixmap.width(); ++i) { + if (qAlpha(line[i]) == 255) { + line[i] = inactiveGrayRGB; + } else if (qAlpha(line[i]) > 128) { + const int g = qRound(inactiveGray * qRed(line[i])); + line[i] = qRgba(g, g, g, qAlpha(line[i])); + } + } + } + + // Finally, draw the tab pixmap on the current painter + p->drawImage(opt->rect, tabPixmap); + } else { + d->drawNSViewInRect(pb, frameRect, p, drawBezelBlock); + } if (!isSelected && sp != QStyleOptionTab::NextIsSelected && tp != QStyleOptionTab::End -- cgit v1.2.3 From e991fd480242a1148a9988e7830a8e77afc90e33 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 12 Apr 2018 16:37:36 -0700 Subject: QMacStyle: Fix SC_ComboBoxEditField rect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I851e4bb1e0177ef5c594328c717e58ec7c9494e3 Reviewed-by: Morten Johan Sørvig --- src/plugins/styles/mac/qmacstyle_mac.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 4dc3cfd634..569eeef0ff 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -1682,8 +1682,7 @@ QRectF QMacStylePrivate::comboboxEditBounds(const QRectF &outerBounds, const Coc ret.adjust(13, 4, -20, -3); break; case QStyleHelper::SizeMini: - // FIXME Wrong - ret.adjust(16, 5, -19, 0); + ret.adjust(12, 0, -19, 0); ret.setHeight(13); break; default: -- cgit v1.2.3 From 0c936d74118a31dcee777a3a4a8938590e79c334 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Mon, 16 Apr 2018 11:16:42 -0700 Subject: QCocoaPlatformTheme: Fix tooltip background color MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It use to be yellowish in the past, but modern versions of macOS show it light gray. Change-Id: I8cca5cbb37c73a6dfc79e633a746b9a7d7bced05 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoasystemsettings.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm index 7c6f879b18..bad91a2d5d 100644 --- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm +++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm @@ -90,7 +90,9 @@ QPalette * qt_mac_createSystemPalette() palette->setColor(QPalette::Disabled, QPalette::Text, qc); palette->setColor(QPalette::Disabled, QPalette::WindowText, qc); palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc); - palette->setBrush(QPalette::ToolTipBase, QColor(255, 255, 199)); + + palette->setBrush(QPalette::ToolTipBase, qt_mac_toQBrush([NSColor controlColor])); + return palette; } -- cgit v1.2.3 From 34e34f22097c87e8e937d72117d83d8c572bbea4 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 18 Apr 2018 15:37:58 +0200 Subject: iOS: Use the non deprecated application:openURL function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In iOS 9.0, the original application:openURL function was deprecated and replaced with a newer one. As iOS 9.0 is no longer supported we can safely switch to the new one. This is also required to prevent a crash when the LSSupportsOpeningDocumentsInPlace and UIFileSharingEnabled keys are set to true in the Info.plist file. Change-Id: I59a7ee82e3ddb2777ef78e28b964ef8666c629af Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/ios/qiosapplicationdelegate.mm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/ios/qiosapplicationdelegate.mm b/src/plugins/platforms/ios/qiosapplicationdelegate.mm index 9cdbed303c..a56c1e4568 100644 --- a/src/plugins/platforms/ios/qiosapplicationdelegate.mm +++ b/src/plugins/platforms/ios/qiosapplicationdelegate.mm @@ -50,11 +50,10 @@ @implementation QIOSApplicationDelegate -- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url options:(NSDictionary *)options { Q_UNUSED(application); - Q_UNUSED(sourceApplication); - Q_UNUSED(annotation); + Q_UNUSED(options); if (!QGuiApplication::instance()) return NO; -- cgit v1.2.3