summaryrefslogtreecommitdiffstats
path: root/src/plugins/styles/mac/qmacstyle_mac.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/styles/mac/qmacstyle_mac.mm')
-rw-r--r--src/plugins/styles/mac/qmacstyle_mac.mm121
1 files changed, 40 insertions, 81 deletions
diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm
index 35b2fa50ac..85bf71be3f 100644
--- a/src/plugins/styles/mac/qmacstyle_mac.mm
+++ b/src/plugins/styles/mac/qmacstyle_mac.mm
@@ -50,92 +50,30 @@
#define QMAC_QAQUASTYLE_SIZE_CONSTRAIN
//#define DEBUG_SIZE_CONSTRAINT
-#include <private/qcore_mac_p.h>
-#if QT_CONFIG(tabbar)
-#include <private/qtabbar_p.h>
-#endif
-#include <private/qpainter_p.h>
-#include <qapplication.h>
-#include <qbitmap.h>
-#if QT_CONFIG(combobox)
-#include <private/qcombobox_p.h>
-#include <qcombobox.h>
-#endif
-#if QT_CONFIG(dialogbuttonbox)
-#include <qdialogbuttonbox.h>
-#endif
-#if QT_CONFIG(dockwidget)
-#include <qdockwidget.h>
-#endif
-#include <qevent.h>
-#include <qfocusframe.h>
-#include <qformlayout.h>
-#include <qgroupbox.h>
-#include <qhash.h>
-#include <qheaderview.h>
-#if QT_CONFIG(lineedit)
-#include <qlineedit.h>
-#endif
-#if QT_CONFIG(mainwindow)
-#include <qmainwindow.h>
-#endif
+#include <QtCore/qoperatingsystemversion.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qvarlengtharray.h>
+
+#include <QtCore/private/qcore_mac_p.h>
+
+#include <QtGui/private/qcoregraphics_p.h>
+#include <QtGui/qpa/qplatformfontdatabase.h>
+#include <QtGui/qpa/qplatformtheme.h>
+
+#include <QtWidgets/private/qstyleanimation_p.h>
+
#if QT_CONFIG(mdiarea)
-#include <qmdisubwindow.h>
-#endif
-#if QT_CONFIG(menubar)
-#include <qmenubar.h>
-#endif
-#include <qpaintdevice.h>
-#include <qpainter.h>
-#include <qpixmapcache.h>
-#include <qpointer.h>
-#if QT_CONFIG(progressbar)
-#include <qprogressbar.h>
-#endif
-#if QT_CONFIG(pushbutton)
-#include <qpushbutton.h>
-#endif
-#include <qradiobutton.h>
-#if QT_CONFIG(rubberband)
-#include <qrubberband.h>
+#include <QtWidgets/qmdisubwindow.h>
#endif
#if QT_CONFIG(scrollbar)
-#include <qscrollbar.h>
-#endif
-#if QT_CONFIG(sizegrip)
-#include <qsizegrip.h>
+#include <QtWidgets/qscrollbar.h>
#endif
-#include <qstyleoption.h>
-#include <qtoolbar.h>
-#if QT_CONFIG(toolbutton)
-#include <qtoolbutton.h>
-#endif
-#if QT_CONFIG(treeview)
-#include <qtreeview.h>
-#endif
-#if QT_CONFIG(tableview)
-#include <qtableview.h>
+#if QT_CONFIG(tabbar)
+#include <QtWidgets/private/qtabbar_p.h>
#endif
-#include <qoperatingsystemversion.h>
#if QT_CONFIG(wizard)
-#include <qwizard.h>
-#endif
-#include <qdebug.h>
-#if QT_CONFIG(datetimeedit)
-#include <qdatetimeedit.h>
+#include <QtWidgets/qwizard.h>
#endif
-#include <qmath.h>
-#include <QtWidgets/qgraphicsproxywidget.h>
-#if QT_CONFIG(graphicsview)
-#include <QtWidgets/qgraphicsview.h>
-#endif
-#include <QtCore/qvariant.h>
-#include <QtCore/qvarlengtharray.h>
-#include <private/qstylehelper_p.h>
-#include <private/qstyleanimation_p.h>
-#include <qpa/qplatformfontdatabase.h>
-#include <qpa/qplatformtheme.h>
-#include <QtGui/private/qcoregraphics_p.h>
QT_USE_NAMESPACE
@@ -295,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);
@@ -314,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);
@@ -338,6 +278,7 @@ static const qreal titleBarButtonSpacing = 8;
// hovered: tab is hovered
bool isDarkMode() { return qt_mac_applicationIsInDarkMode(); }
+#if QT_CONFIG(tabbar)
static const QColor lightTabBarTabBackgroundActive(190, 190, 190);
static const QColor darkTabBarTabBackgroundActive(38, 38, 38);
static const QColor tabBarTabBackgroundActive() { return isDarkMode() ? darkTabBarTabBackgroundActive : lightTabBarTabBackgroundActive; }
@@ -383,6 +324,7 @@ static const QColor tabBarCloseButtonCrossSelected(115, 115, 115);
static const int closeButtonSize = 14;
static const qreal closeButtonCornerRadius = 2.0;
+#endif // QT_CONFIG(tabbar)
static const int headerSectionArrowHeight = 6;
static const int headerSectionSeparatorInset = 2;
@@ -527,6 +469,7 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY)
}
+#if QT_CONFIG(tabbar)
static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed, bool documentMode)
{
p->setRenderHints(QPainter::Antialiasing);
@@ -564,7 +507,6 @@ static void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pres
p->drawLine(margin, height - margin, width - margin, margin);
}
-#if QT_CONFIG(tabbar)
QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect)
{
const auto tabDirection = QMacStylePrivate::tabDirection(shape);
@@ -886,8 +828,10 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg
else if (qobject_cast<const QLineEdit *>(widg))
ct = QStyle::CT_LineEdit;
#endif
+#if QT_CONFIG(itemviews)
else if (qobject_cast<const QHeaderView *>(widg))
ct = QStyle::CT_HeaderSection;
+#endif
#if QT_CONFIG(menubar)
else if (qobject_cast<const QMenuBar *>(widg))
ct = QStyle::CT_MenuBar;
@@ -2189,10 +2133,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
int ret = 0;
switch (metric) {
+#if QT_CONFIG(tabbar)
case PM_TabCloseIndicatorWidth:
case PM_TabCloseIndicatorHeight:
ret = closeButtonSize;
break;
+#endif
case PM_ToolBarIconSize:
ret = proxy()->pixelMetric(PM_LargeIconSize);
break;
@@ -2349,10 +2295,12 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW
ret = 16;
break;
case QStyleHelper::SizeDefault:
+#if QT_CONFIG(tabbar)
const QStyleOptionTab *tb = qstyleoption_cast<const QStyleOptionTab *>(opt);
if (tb && tb->documentMode)
ret = 30;
else
+#endif
ret = QCommonStyle::pixelMetric(metric, opt, widget);
break;
}
@@ -2863,9 +2811,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w
ret = [NSScroller preferredScrollerStyle] == NSScrollerStyleOverlay;
}
break;
+#if QT_CONFIG(itemviews)
case SH_ItemView_ScrollMode:
ret = QAbstractItemView::ScrollPerPixel;
break;
+#endif
case SH_TitleBar_ShowToolTipsOnButtons:
// min/max/close buttons on windows don't show tool tips
ret = false;
@@ -3007,7 +2957,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();
@@ -3031,6 +2981,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
}
proxy()->drawPrimitive(PE_FrameTabWidget, &twf, p, w);
p->restore();
+#endif
}
break;
#endif
@@ -3077,8 +3028,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<QTabWidget *>(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
@@ -3372,6 +3325,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
} break;
case PE_FrameStatusBarItem:
break;
+#if QT_CONFIG(tabbar)
case PE_IndicatorTabClose: {
// Make close button visible only on the hovered tab.
QTabBar *tabBar = qobject_cast<QTabBar*>(w->parentWidget());
@@ -3396,6 +3350,7 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai
}
}
} break;
+#endif // QT_CONFIG(tabbar)
case PE_PanelStatusBar: {
// Fill the status bar with the titlebar gradient.
QLinearGradient linearGrad;
@@ -4565,6 +4520,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
const int controlSize = getControlSize(opt, widget);
switch (sr) {
+#if QT_CONFIG(itemviews)
case SE_ItemViewItemText:
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
int fw = proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget);
@@ -4574,6 +4530,7 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt,
rect.adjust(-fw, 0, 0, 0);
}
break;
+#endif
case SE_ToolBoxTabContents:
rect = QCommonStyle::subElementRect(sr, opt, widget);
break;
@@ -6401,12 +6358,14 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
sz = sz.expandedTo(QSize(sz.width(), minimumSize));
}
break;
+#if QT_CONFIG(itemviews)
case CT_ItemViewItem:
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
sz = QCommonStyle::sizeFromContents(ct, vopt, csz, widget);
sz.setHeight(sz.height() + 2);
}
break;
+#endif
default:
sz = QCommonStyle::sizeFromContents(ct, opt, csz, widget);