From a58dafd2e8b2ad6ee89dc447e9a98d31f574ec9f Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Mon, 20 Feb 2017 10:09:39 +0100 Subject: Build fix for -no-feature-imageformat_xpm Change-Id: I081fdfb622f21fc63a72e153d4d6c7120107ba67 Reviewed-by: Lars Knoll --- src/widgets/styles/qcommonstyle.cpp | 2 ++ src/widgets/styles/qfusionstyle.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 18a0c4fb64..24070f18a6 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -5239,6 +5239,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget return ret; } +#if QT_CONFIG(imageformat_xpm) static QPixmap cachedPixmapFromXPM(const char * const *xpm) { QPixmap result; @@ -5251,6 +5252,7 @@ static QPixmap cachedPixmapFromXPM(const char * const *xpm) } static inline QPixmap titleBarMenuCachedPixmapFromXPM() { return cachedPixmapFromXPM(qt_menu_xpm); } +#endif // QT_CONFIG(imageformat_xpm) #ifndef QT_NO_IMAGEFORMAT_PNG static inline QString clearText16IconPath() diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 75c50bb146..bf72983138 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -86,7 +86,7 @@ static const int windowsRightBorder = 15; // right border on windows static const int groupBoxBottomMargin = 0; // space below the groupbox static const int groupBoxTopMargin = 3; - +#if QT_CONFIG(imageformat_xpm) /* XPM */ static const char * const dock_widget_close_xpm[] = { "11 13 7 1", @@ -173,7 +173,7 @@ static const char * const qt_titlebar_context_help[] = { " ", " ## ", " ## "}; - +#endif // QT_CONFIG(imageformat_xpm) static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50) { @@ -2368,6 +2368,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); bool sunken = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_Sunken); qt_fusion_draw_mdibutton(painter, titleBar, contextHelpButtonRect, hover, sunken); +#if QT_CONFIG(imageformat_xpm) QImage image(qt_titlebar_context_help); QColor alpha = textColor; alpha.setAlpha(128); @@ -2375,6 +2376,7 @@ void QFusionStyle::drawComplexControl(ComplexControl control, const QStyleOption image.setColor(2, alpha.rgba()); painter->setRenderHint(QPainter::SmoothPixmapTransform); painter->drawImage(contextHelpButtonRect.adjusted(4, 4, -4, -4), image); +#endif } } -- cgit v1.2.3 From e1b9ddc10552b061ef8b4d56a2e3fa7a5daa61bb Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Tue, 28 Feb 2017 20:24:27 +0100 Subject: Add feature.scroller Change-Id: I5313e1f5091d5764994525dae138e288e5125c59 Reviewed-by: Lars Knoll --- src/widgets/styles/qpixmapstyle.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qpixmapstyle.cpp b/src/widgets/styles/qpixmapstyle.cpp index a947f5d079..3aec3cf991 100644 --- a/src/widgets/styles/qpixmapstyle.cpp +++ b/src/widgets/styles/qpixmapstyle.cpp @@ -60,7 +60,9 @@ #include #include +#if QT_CONFIG(scroller) #include +#endif QT_BEGIN_NAMESPACE @@ -194,7 +196,7 @@ void QPixmapStyle::polish(QWidget *widget) view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); } #endif -#if QT_CONFIG(gestures) +#if QT_CONFIG(gestures) && QT_CONFIG(scroller) QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); #endif } @@ -235,7 +237,7 @@ void QPixmapStyle::unpolish(QWidget *widget) if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) widget->removeEventFilter(this); -#if QT_CONFIG(gestures) && QT_CONFIG(scrollarea) +#if QT_CONFIG(gestures) && QT_CONFIG(scrollarea) && QT_CONFIG(scroller) if (QAbstractScrollArea *scrollArea = qobject_cast(widget)) QScroller::ungrabGesture(scrollArea->viewport()); #endif -- cgit v1.2.3 From fd08361ad32d935931eefcbe55cea1330949feea Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Wed, 1 Mar 2017 20:27:40 +0100 Subject: Add feature.radiobutton Change-Id: Ie11f178ce22e2fafdfdf1760288e90563569e0cb Reviewed-by: Lars Knoll --- src/widgets/styles/qstylesheetstyle.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 65894a6dde..35e7060b72 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -58,7 +58,6 @@ #include "private/qabstractscrollarea_p.h" #include #include -#include #include #include #include -- cgit v1.2.3 From dc2512f3088d6f836ef06d35cbf1a5f7acb4ce7b Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Thu, 2 Mar 2017 13:39:22 +0100 Subject: Add feature.label and feature.formlayout Change-Id: Ic8dc0aee7f3fc0d8218ba709352b1378078c6070 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/widgets/styles/qcommonstyle.cpp | 6 ++++++ src/widgets/styles/qstylesheetstyle.cpp | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 24070f18a6..b54f49c8fc 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -49,7 +49,11 @@ #include #include #include +#if QT_CONFIG(formlayout) #include +#else +#include +#endif #include #include #include @@ -5162,12 +5166,14 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = QWizard::ClassicStyle; break; #endif +#if QT_CONFIG(formlayout) case SH_FormLayoutWrapPolicy: ret = QFormLayout::DontWrapRows; break; case SH_FormLayoutFieldGrowthPolicy: ret = QFormLayout::AllNonFixedFieldsGrow; break; +#endif case SH_FormLayoutFormAlignment: ret = Qt::AlignLeft | Qt::AlignTop; break; diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 35e7060b72..3a43f146da 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -75,7 +75,9 @@ #include #include #include +#if QT_CONFIG(label) #include +#endif #include "qdrawutil.h" #include @@ -1414,11 +1416,13 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q static inline QObject *parentObject(const QObject *obj) { +#if QT_CONFIG(tooltip) if (qobject_cast(obj) && qstrcmp(obj->metaObject()->className(), "QTipLabel") == 0) { QObject *p = qvariant_cast(obj->property("_q_stylesheet_parent")); if (p) return p; } +#endif return obj->parent(); } -- cgit v1.2.3 From 5c62fd9a2e01047074b3594153e5652794ac6a36 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Thu, 2 Mar 2017 09:20:00 +0100 Subject: Add feature.dialogbuttonbox Change-Id: I8c136024c3bf431529033a806be646d867919daa Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/widgets/styles/qcommonstyle.cpp | 6 ++++++ src/widgets/styles/qfusionstyle.cpp | 1 - src/widgets/styles/qmacstyle_mac.mm | 4 ++++ src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qwindowsvistastyle.cpp | 10 ++++++++++ src/widgets/styles/qwindowsvistastyle_p_p.h | 2 ++ 6 files changed, 24 insertions(+), 1 deletion(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index b54f49c8fc..604422dc4f 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -48,7 +48,9 @@ #include #include #include +#if QT_CONFIG(dialogbuttonbox) #include +#endif #if QT_CONFIG(formlayout) #include #else @@ -4926,9 +4928,11 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_ScrollBar_ContextMenu: ret = true; break; +#if QT_CONFIG(dialogbuttonbox) case SH_DialogButtons_DefaultButton: // This value not used anywhere. ret = QDialogButtonBox::AcceptRole; break; +#endif #ifndef QT_NO_GROUPBOX case SH_GroupBox_TextLabelVerticalAlignment: ret = Qt::AlignVCenter; @@ -5116,11 +5120,13 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget case SH_TabBar_ElideMode: ret = Qt::ElideNone; break; +#if QT_CONFIG(dialogbuttonbox) case SH_DialogButtonLayout: ret = QDialogButtonBox::WinLayout; if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) ret = theme->themeHint(QPlatformTheme::DialogButtonBoxLayout).toInt(); break; +#endif case SH_ComboBox_PopupFrameStyle: ret = QFrame::StyledPanel | QFrame::Plain; break; diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index bf72983138..cf393744f0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index f884a1c279..e78946577c 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -57,7 +57,9 @@ #include #include #include +#if QT_CONFIG(dialogbuttonbox) #include +#endif #include #include #include @@ -2931,9 +2933,11 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_TabBar_ElideMode: ret = Qt::ElideRight; break; +#if QT_CONFIG(dialogbuttonbox) case SH_DialogButtonLayout: ret = QDialogButtonBox::MacLayout; break; +#endif case SH_FormLayoutWrapPolicy: ret = QFormLayout::DontWrapRows; break; diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 798f6ed90b..819ac42293 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -55,7 +55,9 @@ #include #include #include +#if QT_CONFIG(dialogbuttonbox) #include +#endif #include #include #include diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index 1bdd8bf0c8..5a53627e95 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -775,6 +775,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt } case PE_Widget: { +#if QT_CONFIG(dialogbuttonbox) const QDialogButtonBox *buttonBox = 0; if (qobject_cast (widget)) @@ -801,6 +802,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt theme.partId = TDLG_SECONDARYPANEL; d->drawBackground(theme); } +#endif } break; default: @@ -2315,16 +2317,20 @@ void QWindowsVistaStyle::polish(QWidget *widget) } } else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground); +#if QT_CONFIG(dialogbuttonbox) QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_msgbox_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 9, 0, 0); +#endif } #ifndef QT_NO_INPUTDIALOG else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground); +#if QT_CONFIG(dialogbuttonbox) QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_inputdlg_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 9, 0, 0); +#endif } #endif // QT_NO_INPUTDIALOG else if (QTreeView *tree = qobject_cast (widget)) { @@ -2355,16 +2361,20 @@ void QWindowsVistaStyle::unpolish(QWidget *widget) widget->setAttribute(Qt::WA_Hover, false); else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground, false); +#if QT_CONFIG(dialogbuttonbox) QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_msgbox_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 0, 0, 0); +#endif } #ifndef QT_NO_INPUTDIALOG else if (qobject_cast (widget)) { widget->setAttribute(Qt::WA_StyledBackground, false); +#if QT_CONFIG(dialogbuttonbox) QDialogButtonBox *buttonBox = widget->findChild(QLatin1String("qt_inputdlg_buttonbox")); if (buttonBox) buttonBox->setContentsMargins(0, 0, 0, 0); +#endif } #endif // QT_NO_INPUTDIALOG else if (QTreeView *tree = qobject_cast (widget)) { diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 18b6f9c3f7..038bad0c58 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -80,7 +80,9 @@ #include #include #include +#if QT_CONFIG(dialogbuttonbox) #include +#endif #include #include #include -- cgit v1.2.3 From 0884e424106962785b8f2e6742d3590fb3919a97 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Thu, 2 Mar 2017 20:16:58 +0100 Subject: Add feature.checkbox Change-Id: Ib387390b796c3cab6de4ce94e0d217280a300df8 Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/widgets/styles/qmacstyle_mac.mm | 3 ++- src/widgets/styles/qmacstyle_mac_p_p.h | 2 ++ src/widgets/styles/qstylesheetstyle.cpp | 4 ++++ src/widgets/styles/qwindowsvistastyle_p_p.h | 1 - 4 files changed, 8 insertions(+), 2 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index e78946577c..8aace93328 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -55,7 +55,6 @@ #include #include #include -#include #include #if QT_CONFIG(dialogbuttonbox) #include @@ -668,8 +667,10 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg ct = QStyle::CT_PushButton; else if (qobject_cast(widg)) ct = QStyle::CT_RadioButton; +#if QT_CONFIG(checkbox) else if (qobject_cast(widg)) ct = QStyle::CT_CheckBox; +#endif #ifndef QT_NO_COMBOBOX else if (qobject_cast(widg)) ct = QStyle::CT_ComboBox; diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 819ac42293..063d7e7c80 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -53,7 +53,9 @@ #include #include #include +#if QT_CONFIG(checkbox) #include +#endif #include #if QT_CONFIG(dialogbuttonbox) #include diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 3a43f146da..ba05155b74 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -62,7 +62,9 @@ #include #include #include +#if QT_CONFIG(checkbox) #include +#endif #include #include #include @@ -4740,10 +4742,12 @@ int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const return rule.box()->spacing; break; case PM_CheckBoxLabelSpacing: +#if QT_CONFIG(checkbox) if (qobject_cast(w)) { if (rule.hasBox() && rule.box()->spacing != -1) return rule.box()->spacing; } +#endif // assume group box subRule = renderRule(w, opt, PseudoElement_GroupBoxTitle); if (subRule.hasBox() && subRule.box()->spacing != -1) diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 038bad0c58..7173b2183c 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -66,7 +66,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3 From 00e6863552ab3519e8a9a9ecb6cb56bb6a024041 Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Sun, 5 Mar 2017 18:54:15 +0100 Subject: Add feature.pushbutton Change-Id: I654d91635e60b177df16f6dfe00acc940132f66a Reviewed-by: Lars Knoll --- src/widgets/styles/qfusionstyle.cpp | 4 ++++ src/widgets/styles/qmacstyle_mac.mm | 8 ++++++++ src/widgets/styles/qmacstyle_mac_p.h | 2 ++ src/widgets/styles/qmacstyle_mac_p_p.h | 4 ++++ src/widgets/styles/qwindowsvistastyle_p_p.h | 2 ++ src/widgets/styles/qwindowsxpstyle.cpp | 2 ++ 6 files changed, 22 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index cf393744f0..96af534099 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -43,7 +43,11 @@ #if QT_CONFIG(style_fusion) || defined(QT_PLUGIN) #include "qcommonstyle_p.h" #include +#if QT_CONFIG(pushbutton) #include +#else +#include +#endif #include #include #include diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 8aace93328..6dcebaaf32 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -75,7 +75,9 @@ #include #include #include +#if QT_CONFIG(pushbutton) #include +#endif #include #include #include @@ -663,8 +665,10 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg } if (ct == QStyle::CT_CustomBase && widg) { +#if QT_CONFIG(pushbutton) if (qobject_cast(widg)) ct = QStyle::CT_PushButton; +#endif else if (qobject_cast(widg)) ct = QStyle::CT_RadioButton; #if QT_CONFIG(checkbox) @@ -704,6 +708,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg } switch (ct) { +#if QT_CONFIG(pushbutton) case QStyle::CT_PushButton: { const QPushButton *psh = qobject_cast(widg); // If this comparison is false, then the widget was not a push button. @@ -746,6 +751,7 @@ static QSize qt_aqua_get_known_size(QStyle::ContentsType ct, const QWidget *widg // Since there's no default size we return the large size... ret = QSize(-1, qt_mac_aqua_get_metric(kThemeMetricPushButtonHeight)); } +#endif #if 0 //Not sure we are applying the rules correctly for RadioButtons/CheckBoxes --Sam } else if (ct == QStyle::CT_RadioButton) { QRadioButton *rdo = static_cast(widg); @@ -1308,6 +1314,7 @@ void QMacStylePrivate::initHIThemePushButton(const QStyleOptionButton *btn, } } +#if QT_CONFIG(pushbutton) bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option) { QMacStyle *macStyle = qobject_cast(pushButton->style()); @@ -1317,6 +1324,7 @@ bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOpti macStyle->d_func()->initHIThemePushButton(option, pushButton, kThemeStateActive, &bdi); return bdi.kind == kThemeBevelButton; } +#endif /** Creates a HIThemeButtonDrawInfo structure that specifies the correct button diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h index 98a9063bf0..7296539356 100644 --- a/src/widgets/styles/qmacstyle_mac_p.h +++ b/src/widgets/styles/qmacstyle_mac_p.h @@ -127,7 +127,9 @@ private: Q_DISABLE_COPY(QMacStyle) Q_DECLARE_PRIVATE(QMacStyle) +#if QT_CONFIG(pushbutton) friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option); +#endif }; #endif diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 063d7e7c80..1332845f8e 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -78,7 +78,9 @@ #include #include #include +#if QT_CONFIG(pushbutton) #include +#endif #include #include #include @@ -158,7 +160,9 @@ typedef void (^QCocoaDrawRectBlock)(NSRect, CGContextRef); return sizes[controlSize]; \ } while (0) +#if QT_CONFIG(pushbutton) bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option); +#endif class QMacStylePrivate : public QCommonStylePrivate { diff --git a/src/widgets/styles/qwindowsvistastyle_p_p.h b/src/widgets/styles/qwindowsvistastyle_p_p.h index 7173b2183c..ec7c2caad3 100644 --- a/src/widgets/styles/qwindowsvistastyle_p_p.h +++ b/src/widgets/styles/qwindowsvistastyle_p_p.h @@ -64,7 +64,9 @@ #include #include #include +#if QT_CONFIG(pushbutton) #include +#endif #include #include #include diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index f50c143a4a..f3c6069f8a 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -65,7 +65,9 @@ #include #include #include +#if QT_CONFIG(pushbutton) #include +#endif #include #include #include -- cgit v1.2.3 From da730c90a35cce4b24f3cb0cb61246aa87b18e66 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 24 Feb 2017 00:56:55 +0100 Subject: QStyleSheetStyle: introduce class Tampered ... as a replacement for two QPairs and move some common QFont/QPalette functionality into it. Change-Id: Iaab92130dd54eaa7900ac2048014a80cbd04bfb6 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/styles/qstylesheetstyle.cpp | 35 ++++++++++----------------------- src/widgets/styles/qstylesheetstyle_p.h | 29 ++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 30 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index ba05155b74..0c7a3e692c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2594,7 +2594,7 @@ void QStyleSheetStyle::setPalette(QWidget *w) if (!useStyleSheetPropagationInWidgetStyles || p.resolve() != 0) { QPalette wp = w->palette(); - styleSheetCaches->customPaletteWidgets.insert(w, qMakePair(wp, p.resolve())); + styleSheetCaches->customPaletteWidgets.insert(w, {wp, p.resolve()}); if (useStyleSheetPropagationInWidgetStyles) { p = p.resolve(wp); @@ -2614,20 +2614,14 @@ void QStyleSheetStyle::unsetPalette(QWidget *w) const auto it = styleSheetCaches->customPaletteWidgets.find(w); if (it != styleSheetCaches->customPaletteWidgets.end()) { - QPair p = std::move(*it); + auto customizedPalette = std::move(*it); styleSheetCaches->customPaletteWidgets.erase(it); - QPalette original = p.first; - - if (useStyleSheetPropagationInWidgetStyles) { - original.resolve(original.resolve() & p.second); - - QPalette wp = w->palette(); - wp.resolve(wp.resolve() & ~p.second); - wp.resolve(original); - wp.resolve(wp.resolve() | original.resolve()); - original = wp; - } + QPalette original; + if (useStyleSheetPropagationInWidgetStyles) + original = std::move(customizedPalette).reverted(w->palette()); + else + original = customizedPalette.oldWidgetValue; w->setPalette(original); QWidget *ew = embeddedWidget(w); @@ -2657,18 +2651,9 @@ void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const { const auto it = styleSheetCaches->customFontWidgets.find(w); if (it != styleSheetCaches->customFontWidgets.end()) { - QPair f = std::move(*it); + auto customizedFont = std::move(*it); styleSheetCaches->customFontWidgets.erase(it); - - QFont original = f.first; - original.resolve(original.resolve() & f.second); - - QFont font = w->font(); - font.resolve(font.resolve() & ~f.second); - font.resolve(original); - font.resolve(font.resolve() | original.resolve()); - - w->setFont(font); + w->setFont(std::move(customizedFont).reverted(w->font())); } } @@ -5953,7 +5938,7 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const if (rule.font.resolve()) { QFont wf = w->font(); - styleSheetCaches->customFontWidgets.insert(w, qMakePair(wf, rule.font.resolve())); + styleSheetCaches->customFontWidgets.insert(w, {wf, rule.font.resolve()}); QFont font = rule.font.resolve(wf); font.resolve(wf.resolve() | rule.font.resolve()); diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index 55dd2df329..2d302305bd 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -189,12 +189,31 @@ public: QHash renderRulesCache; QHash styleSheetCache; // parsed style sheets QSet autoFillDisabledWidgets; - // widgets whose palettes and fonts we have tampered. stored value pair is - // QPair - QHash > customPaletteWidgets; - QHash > customFontWidgets; + // widgets with whose palettes and fonts we have tampered: + template + struct Tampered { + T oldWidgetValue; + uint resolveMask; + + // only call this function on an rvalue *this (it mangles oldWidgetValue) + T reverted(T current) +#ifdef Q_COMPILER_REF_QUALIFIERS + && +#endif + { + oldWidgetValue.resolve(oldWidgetValue.resolve() & resolveMask); + current.resolve(current.resolve() & ~resolveMask); + current.resolve(oldWidgetValue); + current.resolve(current.resolve() | oldWidgetValue.resolve()); + return current; + } + }; + QHash> customPaletteWidgets; + QHash> customFontWidgets; }; - +template +class QTypeInfo> + : QTypeInfoMerger, T> {}; QT_END_NAMESPACE #endif // QT_NO_STYLE_STYLESHEET -- cgit v1.2.3 From b53d7664c90b0deb2c35f586eb8c6d168f58752f Mon Sep 17 00:00:00 2001 From: Stephan Binner Date: Tue, 7 Mar 2017 21:29:09 +0100 Subject: Add feature.abstractslider Change-Id: Ib5d0186162fc3b750e6440c74b1181787093ef97 Reviewed-by: Paul Olav Tvete --- src/widgets/styles/qfusionstyle.cpp | 4 ++++ src/widgets/styles/qstylesheetstyle.cpp | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 96af534099..33c5a01677 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3294,7 +3294,9 @@ void QFusionStyle::polish(QWidget *widget) #if QT_CONFIG(splitter) || qobject_cast(widget) #endif +#if QT_CONFIG(abstractslider) || qobject_cast(widget) +#endif #if QT_CONFIG(spinbox) || qobject_cast(widget) #endif @@ -3333,7 +3335,9 @@ void QFusionStyle::unpolish(QWidget *widget) #if QT_CONFIG(splitter) || qobject_cast(widget) #endif +#if QT_CONFIG(abstractslider) || qobject_cast(widget) +#endif #if QT_CONFIG(spinbox) || qobject_cast(widget) #endif diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 0c7a3e692c..ab4d0bcb7c 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2426,9 +2426,11 @@ static bool unstylable(const QWidget *w) static quint64 extendedPseudoClass(const QWidget *w) { quint64 pc = w->isWindow() ? quint64(PseudoClass_Window) : 0; +#if QT_CONFIG(abstractslider) if (const QAbstractSlider *slider = qobject_cast(w)) { pc |= ((slider->orientation() == Qt::Vertical) ? PseudoClass_Vertical : PseudoClass_Horizontal); } else +#endif #ifndef QT_NO_COMBOBOX if (const QComboBox *combo = qobject_cast(w)) { if (combo->isEditable()) -- cgit v1.2.3 From 175f33ed855b0a8a30daafacd4f48fa3f8e76a9b Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Tue, 31 Jan 2017 13:38:01 -0800 Subject: QMacStyle: update QTabBar style Task-number: QTBUG-58266 Change-Id: I135e4dae44e2e97d73b7c7c97d8e682bcf459d75 Reviewed-by: Gabriel de Dietrich --- src/widgets/styles/qmacstyle_mac.mm | 464 +++++++++++++++++++-------------- src/widgets/styles/qmacstyle_mac_p_p.h | 4 + 2 files changed, 270 insertions(+), 198 deletions(-) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm index 6dcebaaf32..0d2203f843 100644 --- a/src/widgets/styles/qmacstyle_mac.mm +++ b/src/widgets/styles/qmacstyle_mac.mm @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -190,11 +191,33 @@ static const QColor mainWindowGradientEnd(200, 200, 200); static const int DisclosureOffset = 4; +// Tab bar colors +// active: window is active +// selected: tab is selected +// hovered: tab is hovered +static const QColor tabBarTabBackgroundActive(190, 190, 190); +static const QColor tabBarTabBackgroundActiveHovered(178, 178, 178); +static const QColor tabBarTabBackgroundActiveSelected(211, 211, 211); +static const QColor tabBarTabBackground(227, 227, 227); +static const QColor tabBarTabBackgroundSelected(246, 246, 246); +static const QColor tabBarTabLineActive(160, 160, 160); +static const QColor tabBarTabLineActiveHovered(150, 150, 150); +static const QColor tabBarTabLine(210, 210, 210); +static const QColor tabBarTabLineSelected(189, 189, 189); +static const QColor tabBarCloseButtonBackgroundHovered(162, 162, 162); +static const QColor tabBarCloseButtonBackgroundPressed(153, 153, 153); +static const QColor tabBarCloseButtonBackgroundSelectedHovered(192, 192, 192); +static const QColor tabBarCloseButtonBackgroundSelectedPressed(181, 181, 181); +static const QColor tabBarCloseButtonCross(100, 100, 100); +static const QColor tabBarCloseButtonCrossSelected(115, 115, 115); + +static const int closeButtonSize = 14; +static const qreal closeButtonCornerRadius = 2.0; + // Resolve these at run-time, since the functions was moved in Leopard. typedef HIRect * (*PtrHIShapeGetBounds)(HIShapeRef, HIRect *); static PtrHIShapeGetBounds ptrHIShapeGetBounds = 0; -static int closeButtonSize = 12; #ifndef QT_NO_TABBAR static bool isVerticalTabs(const QTabBar::Shape shape) { return (shape == QTabBar::RoundedEast @@ -217,41 +240,35 @@ static bool isInMacUnifiedToolbarArea(QWindow *window, int windowY) } -void drawTabCloseButton(QPainter *p, bool hover, bool active, bool selected) +void drawTabCloseButton(QPainter *p, bool hover, bool selected, bool pressed) { - // draw background circle p->setRenderHints(QPainter::Antialiasing); QRect rect(0, 0, closeButtonSize, closeButtonSize); - QColor background; + const int width = rect.width(); + const int height = rect.height(); + if (hover) { - background = QColor(124, 124, 124); - } else { - if (active) { - if (selected) - background = QColor(104, 104, 104); - else - background = QColor(83, 83, 83); + // draw background circle + QColor background; + if (selected) { + background = pressed ? tabBarCloseButtonBackgroundSelectedPressed : tabBarCloseButtonBackgroundSelectedHovered; } else { - if (selected) - background = QColor(144, 144, 144); - else - background = QColor(114, 114, 114); + background = pressed ? tabBarCloseButtonBackgroundPressed : tabBarCloseButtonBackgroundHovered; } + p->setPen(Qt::transparent); + p->setBrush(background); + p->drawRoundedRect(rect, closeButtonCornerRadius, closeButtonCornerRadius); } - p->setPen(Qt::transparent); - p->setBrush(background); - p->drawEllipse(rect); // draw cross - int min = 3; - int max = 9; + const int margin = 3; QPen crossPen; - crossPen.setColor(QColor(194, 194, 194)); - crossPen.setWidthF(1.3); + crossPen.setColor(selected ? tabBarCloseButtonCrossSelected : tabBarCloseButtonCross); + crossPen.setWidthF(1.1); crossPen.setCapStyle(Qt::FlatCap); p->setPen(crossPen); - p->drawLine(min, min, max, max); - p->drawLine(min, max, max, min); + p->drawLine(margin, margin, width - margin, height - margin); + p->drawLine(margin, height - margin, width - margin, margin); } #ifndef QT_NO_TABBAR @@ -278,108 +295,71 @@ QRect rotateTabPainter(QPainter *p, QTabBar::Shape shape, QRect tabRect) return tabRect; } -void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified) +void drawTabShape(QPainter *p, const QStyleOptionTab *tabOpt, bool isUnified, int tabOverlap) { - QRect r = tabOpt->rect; - p->translate(tabOpt->rect.x(), tabOpt->rect.y()); - r.moveLeft(0); - r.moveTop(0); - QRect tabRect = rotateTabPainter(p, tabOpt->shape, r); + QRect rect = tabOpt->rect; - int width = tabRect.width(); - int height = 20; - bool active = (tabOpt->state & QStyle::State_Active); - bool selected = (tabOpt->state & QStyle::State_Selected); + 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 (selected) { - QRect rect(1, 0, width - 2, height); + p->translate(rect.x(), rect.y()); + rect.moveLeft(0); + rect.moveTop(0); + const QRect tabRect = rotateTabPainter(p, tabOpt->shape, rect); + + const int width = tabRect.width(); + const int height = tabRect.height(); + const bool active = (tabOpt->state & QStyle::State_Active); + const bool selected = (tabOpt->state & QStyle::State_Selected); + const QRect bodyRect(1, 1, width - 2, height - 2); + const QRect topLineRect(1, 0, width - 2, 1); + const QRect bottomLineRect(1, height - 1, width - 2, 1); + if (selected) { // fill body if (tabOpt->documentMode && isUnified) { p->save(); p->setCompositionMode(QPainter::CompositionMode_Source); - p->fillRect(rect, QColor(Qt::transparent)); + p->fillRect(tabRect, QColor(Qt::transparent)); p->restore(); } else if (active) { - p->fillRect(rect, QColor(167, 167, 167)); - } else { - QLinearGradient gradient(rect.topLeft(), rect.bottomLeft()); - gradient.setColorAt(0, QColor(216, 216, 216)); - gradient.setColorAt(0.5, QColor(215, 215, 215)); - gradient.setColorAt(1, QColor(210, 210, 210)); - p->fillRect(rect, gradient); - } - - // draw border - QColor borderSides; - QColor borderBottom; - if (active) { - borderSides = QColor(88, 88, 88); - borderBottom = QColor(88, 88, 88); + p->fillRect(bodyRect, tabBarTabBackgroundActiveSelected); + // top line + p->fillRect(topLineRect, tabBarTabLineSelected); } else { - borderSides = QColor(121, 121, 121); - borderBottom = QColor(116, 116, 116); + p->fillRect(bodyRect, tabBarTabBackgroundSelected); } - - p->setPen(borderSides); - - int bottom = height; - // left line - p->drawLine(0, 1, 0, bottom-2); - // right line - p->drawLine(width-1, 1, width-1, bottom-2); - - // bottom line - if (active) { - p->setPen(QColor(168, 168, 168)); - p->drawLine(3, bottom-1, width-3, bottom-1); - } - p->setPen(borderBottom); - p->drawLine(2, bottom, width-2, bottom); - - int w = 3; - QRectF rectangleLeft(1, height - w, w, w); - QRectF rectangleRight(width - 2, height - 1, w, w); - int startAngle = 180 * 16; - int spanAngle = 90 * 16; - p->setRenderHint(QPainter::Antialiasing); - p->drawArc(rectangleLeft, startAngle, spanAngle); - p->drawArc(rectangleRight, startAngle, -spanAngle); } else { // when the mouse is over non selected tabs they get a new color - bool hover = (tabOpt->state & QStyle::State_MouseOver); + const bool hover = (tabOpt->state & QStyle::State_MouseOver); if (hover) { - QRect rect(1, 2, width - 1, height - 1); - p->fillRect(rect, QColor(110, 110, 110)); - } - - // seperator lines between tabs - bool west = (tabOpt->shape == QTabBar::RoundedWest || tabOpt->shape == QTabBar::TriangularWest); - bool drawOnRight = !west; - if ((!drawOnRight && tabOpt->selectedPosition != QStyleOptionTab::NextIsSelected) - || (drawOnRight && tabOpt->selectedPosition != QStyleOptionTab::NextIsSelected)) { - QColor borderColor; - QColor borderHighlightColor; - if (active) { - borderColor = QColor(64, 64, 64); - borderHighlightColor = QColor(140, 140, 140); - } else { - borderColor = QColor(135, 135, 135); - borderHighlightColor = QColor(178, 178, 178); - } - - int x = drawOnRight ? width : 0; - - // tab seperator line - p->setPen(borderColor); - p->drawLine(x, 2, x, height + 1); - - // tab seperator highlight - p->setPen(borderHighlightColor); - p->drawLine(x-1, 2, x-1, height + 1); - p->drawLine(x+1, 2, x+1, height + 1); + // fill body + p->fillRect(bodyRect, tabBarTabBackgroundActiveHovered); + // bottom line + p->fillRect(bottomLineRect, tabBarTabLineActiveHovered); } } + + // separator lines between tabs + const QRect leftLineRect(0, 1, 1, height - 2); + const QRect rightLineRect(width - 1, 1, 1, height - 2); + const QColor separatorLineColor = active ? tabBarTabLineActive : tabBarTabLine; + p->fillRect(leftLineRect, separatorLineColor); + p->fillRect(rightLineRect, separatorLineColor); } void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget *w) @@ -390,53 +370,25 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBase *tbb, const QWidget * } else { r.setHeight(w->height()); } - QRect tabRect = rotateTabPainter(p, tbb->shape, r); - int width = tabRect.width(); - int height = tabRect.height(); - bool active = (tbb->state & QStyle::State_Active); - - // top border lines - QColor borderHighlightTop; - QColor borderTop; - if (active) { - borderTop = QColor(64, 64, 64); - borderHighlightTop = QColor(174, 174, 174); - } else { - borderTop = QColor(135, 135, 135); - borderHighlightTop = QColor(207, 207, 207); - } - p->setPen(borderHighlightTop); - p->drawLine(tabRect.x(), 0, width, 0); - p->setPen(borderTop); - p->drawLine(tabRect.x(), 1, width, 1); - - // center block - QRect centralRect(tabRect.x(), 2, width, height - 2); - if (active) { - QColor mainColor = QColor(120, 120, 120); - p->fillRect(centralRect, mainColor); - } else { - QLinearGradient gradient(centralRect.topLeft(), centralRect.bottomLeft()); - gradient.setColorAt(0, QColor(165, 165, 165)); - gradient.setColorAt(0.5, QColor(164, 164, 164)); - gradient.setColorAt(1, QColor(158, 158, 158)); - p->fillRect(centralRect, gradient); - } - - // bottom border lines - QColor borderHighlightBottom; - QColor borderBottom; - if (active) { - borderHighlightBottom = QColor(153, 153, 153); - borderBottom = QColor(64, 64, 64); - } else { - borderHighlightBottom = QColor(177, 177, 177); - borderBottom = QColor(127, 127, 127); - } - p->setPen(borderHighlightBottom); - p->drawLine(tabRect.x(), height - 2, width, height - 2); - p->setPen(borderBottom); - p->drawLine(tabRect.x(), height - 1, width, height - 1); + const QRect tabRect = rotateTabPainter(p, tbb->shape, r); + const int width = tabRect.width(); + const int height = tabRect.height(); + const bool active = (tbb->state & QStyle::State_Active); + + // fill body + const QRect bodyRect(0, 1, width, height - 1); + const QColor bodyColor = active ? tabBarTabBackgroundActive : tabBarTabBackground; + p->fillRect(bodyRect, bodyColor); + + // top line + const QRect topLineRect(0, 0, width, 1); + const QColor topLineColor = active ? tabBarTabLineActive : tabBarTabLine; + p->fillRect(topLineRect, topLineColor); + + // bottom line + const QRect bottomLineRect(0, height - 1, width, 1); + const QColor bottomLineColor = active ? tabBarTabLineActive : tabBarTabLine; + p->fillRect(bottomLineRect, bottomLineColor); } #endif @@ -1105,6 +1057,55 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRect &targetRect, int h QRect(focusRingPixmap.width() - shCornerSize, svCornerSize, shCornerSize, focusRingPixmap.width() - 2 * svCornerSize)); } +#ifndef QT_NO_TABBAR +void QMacStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect) const +{ + Q_ASSERT(textRect); + QRect tr = opt->rect; + const bool verticalTabs = opt->shape == QTabBar::RoundedEast + || opt->shape == QTabBar::RoundedWest + || opt->shape == QTabBar::TriangularEast + || opt->shape == QTabBar::TriangularWest; + if (verticalTabs) + tr.setRect(0, 0, tr.height(), tr.width()); // 0, 0 as we will have a translate transform + + int verticalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftVertical, opt, widget); + int horizontalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, opt, widget); + const int hpadding = 4; + const int vpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2; + if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) + verticalShift = -verticalShift; + tr.adjust(hpadding, verticalShift - vpadding, horizontalShift - hpadding, vpadding); + const bool selected = opt->state & QStyle::State_Selected; + if (selected) { + tr.setTop(tr.top() - verticalShift); + tr.setRight(tr.right() - horizontalShift); + } + + // left widget + if (!opt->leftButtonSize.isEmpty()) { + const int buttonSize = verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width(); + tr.setLeft(tr.left() + 4 + buttonSize); + // make text aligned to center + if (opt->rightButtonSize.isEmpty()) + tr.setRight(tr.right() - 4 - buttonSize); + } + // right widget + if (!opt->rightButtonSize.isEmpty()) { + const int buttonSize = verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width(); + tr.setRight(tr.right() - 4 - buttonSize); + // make text aligned to center + if (opt->leftButtonSize.isEmpty()) + tr.setLeft(tr.left() + 4 + buttonSize); + } + + if (!verticalTabs) + tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); + + *textRect = tr; +} +#endif //QT_NO_TABBAR + QAquaWidgetSize QMacStylePrivate::effectiveAquaSizeConstrain(const QStyleOption *option, const QWidget *widg, QStyle::ContentsType ct, @@ -2473,6 +2474,26 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = int([NSWindow frameRectForContentRect:NSZeroRect styleMask:NSTitledWindowMask].size.height); break; + case QStyle::PM_TabBarTabHSpace: + switch (d->aquaSizeConstrain(opt, widget)) { + case QAquaSizeLarge: + ret = QCommonStyle::pixelMetric(metric, opt, widget); + break; + case QAquaSizeSmall: + ret = 20; + break; + case QAquaSizeMini: + ret = 16; + break; + case QAquaSizeUnknown: + const QStyleOptionTab *tb = qstyleoption_cast(opt); + if (tb && tb->documentMode) + ret = 24; + else + ret = QCommonStyle::pixelMetric(metric, opt, widget); + break; + } + break; case PM_TabBarTabVSpace: ret = 4; break; @@ -2481,10 +2502,10 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW ret = 0; break; case PM_TabBarBaseHeight: - ret = 0; + ret = 21; break; case PM_TabBarTabOverlap: - ret = 0; + ret = 1; break; case PM_TabBarBaseOverlap: switch (d->aquaSizeConstrain(opt, widget)) { @@ -2661,20 +2682,6 @@ int QMacStyle::pixelMetric(PixelMetric metric, const QStyleOption *opt, const QW case PM_LayoutHorizontalSpacing: case PM_LayoutVerticalSpacing: return -1; - case QStyle::PM_TabBarTabHSpace: - switch (d->aquaSizeConstrain(opt, widget)) { - case QAquaSizeLarge: - case QAquaSizeUnknown: - ret = QCommonStyle::pixelMetric(metric, opt, widget); - break; - case QAquaSizeSmall: - ret = 20; - break; - case QAquaSizeMini: - ret = 16; - break; - } - break; case PM_MenuHMargin: ret = 0; break; @@ -3526,10 +3533,18 @@ void QMacStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPai case PE_FrameStatusBarItem: break; case PE_IndicatorTabClose: { - bool hover = (opt->state & State_MouseOver); - bool selected = (opt->state & State_Selected); - bool active = (opt->state & State_Active); - drawTabCloseButton(p, hover, active, selected); + // Make close button visible only on the hovered tab. + if (QTabBar *tabBar = qobject_cast(w->parentWidget())) { + const QTabBarPrivate *tabBarPrivate = static_cast(QObjectPrivate::get(tabBar)); + const int hoveredTabIndex = tabBarPrivate->hoveredTabIndex(); + if (hoveredTabIndex != -1 && ((w == tabBar->tabButton(hoveredTabIndex, QTabBar::LeftSide)) || + (w == tabBar->tabButton(hoveredTabIndex, QTabBar::RightSide)))) { + const bool hover = (opt->state & State_MouseOver); + const bool selected = (opt->state & State_Selected); + const bool pressed = (opt->state & State_Sunken); + drawTabCloseButton(p, hover, selected, pressed); + } + } } break; case PE_PanelStatusBar: { // Fill the status bar with the titlebar gradient. @@ -4066,7 +4081,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter #ifndef QT_NO_TABBAR case CE_TabBarTabShape: if (const QStyleOptionTab *tabOpt = qstyleoption_cast(opt)) { - if (tabOpt->documentMode) { p->save(); bool isUnified = false; @@ -4076,7 +4090,9 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter isUnified = isInMacUnifiedToolbarArea(w->window()->windowHandle(), windowTabStart.y()); } - drawTabShape(p, tabOpt, isUnified); + const int tabOverlap = proxy()->pixelMetric(PM_TabBarTabOverlap, opt, w); + drawTabShape(p, tabOpt, isUnified, tabOverlap); + p->restore(); return; } @@ -4202,23 +4218,6 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter } myTab.rect.setHeight(myTab.rect.height() + heightOffset); - if (myTab.documentMode) { - p->save(); - rotateTabPainter(p, myTab.shape, myTab.rect); - - QColor shadowColor = QColor(myTab.documentMode ? Qt::white : Qt::black); - shadowColor.setAlpha(75); - QPalette np = tab->palette; - np.setColor(QPalette::WindowText, shadowColor); - - QRect nr = proxy()->subElementRect(SE_TabBarTabText, opt, w); - nr.moveTop(-1); - int alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextHideMnemonic; - proxy()->drawItemText(p, nr, alignment, np, tab->state & State_Enabled, - tab->text, QPalette::WindowText); - p->restore(); - } - QCommonStyle::drawControl(ce, &myTab, p, w); } else { p->save(); @@ -4936,6 +4935,73 @@ QRect QMacStyle::subElementRect(SubElement sr, const QStyleOption *opt, } } break; + case SE_TabBarTabText: + if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { + d->tabLayout(tab, widget, &rect); + } + break; + case SE_TabBarTabLeftButton: + case SE_TabBarTabRightButton: + if (const QStyleOptionTab *tab = qstyleoption_cast(opt)) { + bool selected = tab->state & State_Selected; + int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); + int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); + int hpadding = 5; + + bool verticalTabs = tab->shape == QTabBar::RoundedEast + || tab->shape == QTabBar::RoundedWest + || tab->shape == QTabBar::TriangularEast + || tab->shape == QTabBar::TriangularWest; + + QRect tr = tab->rect; + if (tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::TriangularSouth) + verticalShift = -verticalShift; + if (verticalTabs) { + qSwap(horizontalShift, verticalShift); + horizontalShift *= -1; + verticalShift *= -1; + } + if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest) + horizontalShift = -horizontalShift; + + tr.adjust(0, 0, horizontalShift, verticalShift); + if (selected) + { + tr.setBottom(tr.bottom() - verticalShift); + tr.setRight(tr.right() - horizontalShift); + } + + QSize size = (sr == SE_TabBarTabLeftButton) ? tab->leftButtonSize : tab->rightButtonSize; + int w = size.width(); + int h = size.height(); + int midHeight = static_cast(qCeil(float(tr.height() - h) / 2)); + int midWidth = ((tr.width() - w) / 2); + + bool atTheTop = true; + switch (tab->shape) { + case QTabBar::RoundedWest: + case QTabBar::TriangularWest: + atTheTop = (sr == SE_TabBarTabLeftButton); + break; + case QTabBar::RoundedEast: + case QTabBar::TriangularEast: + atTheTop = (sr == SE_TabBarTabRightButton); + break; + default: + if (sr == SE_TabBarTabLeftButton) + rect = QRect(tab->rect.x() + hpadding, midHeight, w, h); + else + rect = QRect(tab->rect.right() - w - hpadding, midHeight, w, h); + rect = visualRect(tab->direction, tab->rect, rect); + } + if (verticalTabs) { + if (atTheTop) + rect = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h); + else + rect = QRect(midWidth, tr.y() + hpadding, w, h); + } + } + break; #endif case SE_LineEditContents: rect = QCommonStyle::subElementRect(sr, opt, widget); @@ -6543,13 +6609,14 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, if (vertTabs) sz = sz.transposed(); int defaultTabHeight; - int defaultExtraSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); // Remove spurious gcc warning (AFAIK) + int extraHSpace = proxy()->pixelMetric(PM_TabBarTabHSpace, tab, widget); + int extraVSpace = proxy()->pixelMetric(PM_TabBarTabVSpace, tab, widget); QFontMetrics fm = opt->fontMetrics; switch (AquaSize) { case QAquaSizeUnknown: case QAquaSizeLarge: if (tab->documentMode) - defaultTabHeight = 23; + defaultTabHeight = 24; else defaultTabHeight = 21; break; @@ -6563,10 +6630,11 @@ QSize QMacStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, bool setWidth = false; if (differentFont || !tab->icon.isNull()) { sz.rheight() = qMax(defaultTabHeight, sz.height()); + sz.rwidth() += extraHSpace; } else { QSize textSize = fm.size(Qt::TextShowMnemonic, tab->text); sz.rheight() = qMax(defaultTabHeight, textSize.height()); - sz.rwidth() = textSize.width() + defaultExtraSpace; + sz.rwidth() = textSize.width() + extraVSpace; setWidth = true; } diff --git a/src/widgets/styles/qmacstyle_mac_p_p.h b/src/widgets/styles/qmacstyle_mac_p_p.h index 1332845f8e..59f6e893b1 100644 --- a/src/widgets/styles/qmacstyle_mac_p_p.h +++ b/src/widgets/styles/qmacstyle_mac_p_p.h @@ -229,6 +229,10 @@ public: void drawFocusRing(QPainter *p, const QRect &targetRect, int hMargin, int vMargin, qreal radius = 0) const; +#ifndef QT_NO_TABBAR + void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect) const; +#endif + public: mutable QPointer pressedButton; mutable QPointer defaultButton; -- cgit v1.2.3 From f8218637e9e5fa8f50ef25da293b95f767eaefc2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 9 Mar 2017 10:11:17 +0100 Subject: Build fix for -no-feature-slider Change-Id: Ibd7d0c2182c6a11f6d595b6d1015ee7de2d35866 Reviewed-by: Lars Knoll --- src/widgets/styles/qfusionstyle.cpp | 3 +++ src/widgets/styles/qstylesheetstyle.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src/widgets/styles') diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 33c5a01677..1267907303 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -59,6 +59,9 @@ #include #include #include +#if QT_CONFIG(abstractslider) +#include +#endif #include #include #include diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index ab4d0bcb7c..275a0550d2 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -60,6 +60,9 @@ #include #include #include +#if QT_CONFIG(abstractslider) +#include +#endif #include #include #if QT_CONFIG(checkbox) -- cgit v1.2.3