From b727d2f0e152243c1c46e2916dcb3c8481f03ebe Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 30 May 2019 23:44:44 +0900 Subject: [PATCH] Fix build without feature.dockwidget and tabwidget Change-Id: I621664f646475c1b5cfde47b7087c0c9f5ad8e4d Reviewed-by: Richard Moe Gustavsen --- src/plugins/styles/mac/qmacstyle_mac.mm | 7 ++++++- src/widgets/widgets/qmainwindowlayout.cpp | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 6c4605b5d2..675f37c4c7 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -233,6 +233,7 @@ static QLinearGradient titlebarGradientInactive() return qt_mac_applicationIsInDarkMode() ? darkGradient : lightGradient; } +#if QT_CONFIG(tabwidget) static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextRef ctx) { Q_ASSERT(option); @@ -252,6 +253,7 @@ static void clipTabBarFrame(const QStyleOption *option, const QMacStyle *style, CGContextClipToRects(ctx, &cgRects[0], size_t(cgRects.size())); } } +#endif static const QColor titlebarSeparatorLineActive(111, 111, 111); static const QColor titlebarSeparatorLineInactive(131, 131, 131); @@ -2949,7 +2951,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai p->restore(); return; } - +#if QT_CONFIG(tabwidget) QRegion region(tbb->rect); region -= tbb->tabBarRect; p->save(); @@ -2973,6 +2975,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai } proxy()->drawPrimitive(PE_FrameTabWidget, &twf, p, w); p->restore(); +#endif } break; #endif @@ -3019,8 +3022,10 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai needTranslation = true; } d->drawNSViewInRect(box, adjustedRect, p, ^(CGContextRef ctx, const CGRect &rect) { +#if QT_CONFIG(tabwidget) if (QTabWidget *tabWidget = qobject_cast(opt->styleObject)) clipTabBarFrame(opt, this, ctx); +#endif CGContextTranslateCTM(ctx, 0, rect.origin.y + rect.size.height); CGContextScaleCTM(ctx, 1, -1); if (QOperatingSystemVersion::current() < QOperatingSystemVersion::MacOSMojave diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index b8f997b782..0e67c56afd 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -2413,7 +2413,7 @@ static bool unplugGroup(QMainWindowLayout *layout, QLayoutItem **item, */ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, bool group) { -#if QT_CONFIG(dockwidget) && QT_CONFIG(tabbar) +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) auto *groupWindow = qobject_cast(widget->parentWidget()); if (!widget->isWindow() && groupWindow) { if (group && groupWindow->tabLayoutInfo()) { @@ -2525,10 +2525,10 @@ void QMainWindowLayout::updateGapIndicator() #endif // QT_CONFIG(rubberband) } +#if QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) { QTabBar::Shape result = QTabBar::RoundedSouth; -#if QT_CONFIG(tabwidget) if (qobject_cast(w)) { switch (static_cast(qt_widget_private(w))->tabPosition) { case QTabWidget::North: @@ -2545,9 +2545,9 @@ static QTabBar::Shape tabwidgetPositionToTabBarShape(QWidget *w) break; } } -#endif // tabwidget return result; } +#endif // QT_CONFIG(dockwidget) && QT_CONFIG(tabwidget) void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) { @@ -2591,6 +2591,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (!w->geometry().contains(mousePos)) continue; +#if QT_CONFIG(tabwidget) if (auto dropTo = qobject_cast(w)) { // dropping to a normal widget, we mutate it in a QDockWidgetGroupWindow with two // tabs @@ -2612,6 +2613,7 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) w = floatingTabs; widget->raise(); // raise, as our newly created drop target is now on top } +#endif Q_ASSERT(qobject_cast(w)); auto group = static_cast(w); if (group->hover(widgetItem, group->mapFromGlobal(mousePos))) {