summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/mac
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-06-06 16:51:00 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2018-06-14 04:21:24 +0000
commita93d29198a506b385a006e22538a24c2450c5278 (patch)
treeaf1e608ffb9540239daf2f70fd514c7f19a6639c /src/plugins/styles/mac
parent67227aeffdf94be8d177309d27291d5b3247586c (diff)
Access private properties via sandbox-safe API on Apple OSes
We detect whether or not we're running inside a sandbox and bail out if so. We use runtime lookup of the property, so that static analysis of the application will not mistakenly think we're using the API in sandboxed situations. Change-Id: I5f5c42f5a4a44b62de061d945b62ac63167ece09 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
Diffstat (limited to 'src/plugins/styles/mac')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 5999163c91..2d212bfe3b 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -248,24 +248,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QVerticalSplitView);
}
@end
-#if !QT_CONFIG(appstore_compliant)
-
-// This API was requested to Apple in rdar #36197888.
-// We know it's safe to use up to macOS 10.13.3.
-// See drawComplexControl(CC_ComboBox) for its usage.
-
-@interface NSComboBoxCell (QtButtonCell)
-@property (readonly) NSButtonCell *qt_buttonCell;
-@end
-
-@implementation NSComboBoxCell (QtButtonCell)
-- (NSButtonCell *)qt_buttonCell {
- return self->_buttonCell;
-}
-@end
-
-#endif
-
QT_BEGIN_NAMESPACE
// The following constants are used for adjusting the size
@@ -5215,11 +5197,14 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
auto *cb = static_cast<NSComboBox *>(cc);
const auto frameRect = cw.adjustedControlFrame(combo->rect);
cb.frame = frameRect.toCGRect();
-#if !QT_CONFIG(appstore_compliant)
- static_cast<NSComboBoxCell *>(cc.cell).qt_buttonCell.highlighted = isPressed;
-#else
- // TODO Render to pixmap and darken the button manually
-#endif
+
+ // This API was requested to Apple in rdar #36197888. We know it's safe to use up to macOS 10.13.3
+ if (NSButtonCell *cell = static_cast<NSButtonCell *>([cc.cell qt_valueForPrivateKey:@"_buttonCell"])) {
+ cell.highlighted = isPressed;
+ } else {
+ // TODO Render to pixmap and darken the button manually
+ }
+
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];