From 8d0b46c3ae506ee81d37755083708fbdee2a712c Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Mon, 27 Feb 2017 20:04:45 -0800 Subject: Remove more tight coupling between QMdiSubWindow and QMacStyle This technically just changes a compile time check to a run time check and better options should be explored later, but it removes the compile time dependency for now. Change-Id: I58c5599baf2c338e88bd558a82093835124d6f67 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qmdisubwindow.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'src/widgets/widgets/qmdisubwindow.cpp') diff --git a/src/widgets/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp index a627c86871..34b64145e3 100644 --- a/src/widgets/widgets/qmdisubwindow.cpp +++ b/src/widgets/widgets/qmdisubwindow.cpp @@ -194,6 +194,11 @@ static const Qt::WindowFlags CustomizeWindowFlags = static const int BoundaryMargin = 5; +static inline bool isMacStyle(QStyle *style) +{ + return style->inherits("QMacStyle"); +} + static inline int getMoveDeltaComponent(uint cflags, uint moveFlag, uint resizeFlag, int delta, int maxDelta, int minDelta) { @@ -1077,7 +1082,7 @@ void QMdiSubWindowPrivate::updateCursor() #ifndef QT_NO_CURSOR Q_Q(QMdiSubWindow); #if QT_CONFIG(style_mac) - if (qobject_cast(q->style())) + if (isMacStyle(q->style())) return; #endif @@ -1505,7 +1510,7 @@ void QMdiSubWindowPrivate::processClickedSubControl() break; case QStyle::SC_TitleBarMinButton: #if QT_CONFIG(style_mac) - if (qobject_cast(q->style())) { + if (isMacStyle(q->style())) { if (q->isMinimized()) q->showNormal(); else @@ -1522,7 +1527,7 @@ void QMdiSubWindowPrivate::processClickedSubControl() break; case QStyle::SC_TitleBarMaxButton: #if QT_CONFIG(style_mac) - if (qobject_cast(q->style())) { + if (isMacStyle(q->style())) { if (q->isMaximized()) q->showNormal(); else @@ -1569,7 +1574,7 @@ QRegion QMdiSubWindowPrivate::getRegion(Operation operation) const QRegion region; #if QT_CONFIG(style_mac) - if (qobject_cast(q->style())) + if (isMacStyle(q->style())) return region; #endif @@ -2192,7 +2197,7 @@ void QMdiSubWindowPrivate::setSizeGrip(QSizeGrip *newSizeGrip) newSizeGrip->setFixedSize(newSizeGrip->sizeHint()); bool putSizeGripInLayout = layout ? true : false; #if QT_CONFIG(style_mac) - if (qobject_cast(q->style())) + if (isMacStyle(q->style())) putSizeGripInLayout = false; #endif if (putSizeGripInLayout) { @@ -2844,7 +2849,7 @@ bool QMdiSubWindow::event(QEvent *event) d->isWidgetHiddenByUs = false; if (!parent()) { #if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) - if (qobject_cast(style())) + if (isMacStyle(style())) delete d->sizeGrip; #endif setOption(RubberBandResize, false); @@ -2939,7 +2944,7 @@ void QMdiSubWindow::showEvent(QShowEvent *showEvent) } #if !defined(QT_NO_SIZEGRIP) && QT_CONFIG(style_mac) - if (qobject_cast(style()) && !d->sizeGrip + if (isMacStyle(style()) && !d->sizeGrip && !(windowFlags() & Qt::FramelessWindowHint)) { d->setSizeGrip(new QSizeGrip(this)); Q_ASSERT(d->sizeGrip); @@ -3334,7 +3339,7 @@ void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent) d->hoveredSubControl, this); } #if QT_CONFIG(style_mac) - if (qobject_cast(style()) && !hoverRegion.isEmpty()) + if (isMacStyle(style()) && !hoverRegion.isEmpty()) hoverRegion += QRegion(0, 0, width(), d->titleBarHeight(options)); #endif if (!hoverRegion.isEmpty()) @@ -3544,7 +3549,7 @@ QSize QMdiSubWindow::minimumSizeHint() const if (d->sizeGrip && d->sizeGrip->isVisibleTo(const_cast(this))) sizeGripHeight = d->sizeGrip->height(); #if QT_CONFIG(style_mac) - else if (parent() && qobject_cast(style()) && !d->sizeGrip) + else if (parent() && isMacStyle(style()) && !d->sizeGrip) sizeGripHeight = style()->pixelMetric(QStyle::PM_SizeGripSize, 0, this); #endif minHeight = qMax(minHeight, decorationHeight + sizeGripHeight); -- cgit v1.2.3