diff --git a/examples/widgets/widgets/tooltips/sortingbox.cpp b/examples/widgets/widgets/tooltips/sortingbox.cpp index f99c38b233..d06fbe1756 100644 --- a/examples/widgets/widgets/tooltips/sortingbox.cpp +++ b/examples/widgets/widgets/tooltips/sortingbox.cpp @@ -129,7 +129,7 @@ bool SortingBox::event(QEvent *event) //! [7] void SortingBox::resizeEvent(QResizeEvent * /* event */) { - int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin); + int margin = style()->pixelMetric(QStyle::PM_LayoutTopMargin); int x = width() - margin; int y = height() - margin; @@ -246,7 +246,7 @@ int SortingBox::updateButtonGeometry(QToolButton *button, int x, int y) size.rwidth(), size.rheight()); return y - size.rheight() - - style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing); + - style()->pixelMetric(QStyle::PM_LayoutVerticalSpacing); } //! [20] diff --git a/src/plugins/styles/mac/qmacstyle_mac.mm b/src/plugins/styles/mac/qmacstyle_mac.mm index 488b1da405..c08e5b0cf1 100644 --- a/src/plugins/styles/mac/qmacstyle_mac.mm +++ b/src/plugins/styles/mac/qmacstyle_mac.mm @@ -2675,7 +2675,7 @@ int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_BlinkCursorWhenTextSelected: ret = false; break; - case SH_ScrollBar_StopMouseOverSlider: + case SH_Slider_StopMouseOverSlider: ret = true; break; case SH_ListViewExpand_SelectMouseType: diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index cb2a620aa8..e3e6cb05df 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4776,21 +4776,11 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid } else if (widget) { isWindow = widget->isWindow(); } - ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin, opt); + ret = int(QStyleHelper::dpiScaled(isWindow ? 11 : 9, opt)); } break; case PM_LayoutHorizontalSpacing: case PM_LayoutVerticalSpacing: - ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing, opt); - break; - - case PM_DefaultTopLevelMargin: - ret = int(QStyleHelper::dpiScaled(11, opt)); - break; - case PM_DefaultChildMargin: - ret = int(QStyleHelper::dpiScaled(9, opt)); - break; - case PM_DefaultLayoutSpacing: ret = int(QStyleHelper::dpiScaled(6, opt)); break; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 70af3e295a..1e698028fd 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1039,8 +1039,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_ProgressBarLabel Area for the text label. \value SE_ProgressBarLayoutItem Area that counts for the parent layout. - \omitvalue SE_ViewItemCheckIndicator - \value SE_FrameContents Area for a frame's contents. \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrame; see QFrame \value SE_FrameLayoutItem Area that counts for the parent layout. @@ -1074,8 +1072,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch. - \omitvalue SE_DialogButtonBoxLayoutItem - \value SE_GroupBoxLayoutItem Area that counts for the parent layout. \value SE_CustomBase Base value for custom sub-elements. @@ -1359,9 +1355,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_SpinBoxFrameWidth Frame width of a spin box, defaults to PM_DefaultFrameWidth. \value PM_ComboBoxFrameWidth Frame width of a combo box, defaults to PM_DefaultFrameWidth. - \value PM_MDIFrameWidth Obsolete. Use PM_MdiSubWindowFrameWidth instead. \value PM_MdiSubWindowFrameWidth Frame width of an MDI window. - \value PM_MDIMinimizedWidth Obsolete. Use PM_MdiSubWindowMinimizedWidth instead. \value PM_MdiSubWindowMinimizedWidth Width of a minimized MDI window. \value PM_LayoutLeftMargin Default \l{QLayout::setContentsMargins()}{left margin} for a @@ -1503,21 +1497,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_CustomBase Base value for custom pixel metrics. Custom values must be greater than this value. - The following values are obsolete: - - \value PM_DefaultTopLevelMargin Use PM_LayoutLeftMargin, - PM_LayoutTopMargin, - PM_LayoutRightMargin, and - PM_LayoutBottomMargin instead. - \value PM_DefaultChildMargin Use PM_LayoutLeftMargin, - PM_LayoutTopMargin, - PM_LayoutRightMargin, and - PM_LayoutBottomMargin instead. - \value PM_DefaultLayoutSpacing Use PM_LayoutHorizontalSpacing - and PM_LayoutVerticalSpacing - instead. - - \sa pixelMetric() */ @@ -1807,9 +1786,6 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value SH_TitleBar_NoBorder The title bar has no border. - \value SH_ScrollBar_StopMouseOverSlider Obsolete. Use - SH_Slider_StopMouseOverSlider instead. - \value SH_Slider_StopMouseOverSlider Stops auto-repeat when the slider reaches the mouse position. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 5844251ae5..ffbff494f5 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -307,9 +307,6 @@ public: SE_TabWidgetRightCorner, SE_ItemViewItemCheckIndicator, -#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove - SE_ViewItemCheckIndicator Q_DECL_ENUMERATOR_DEPRECATED = SE_ItemViewItemCheckIndicator, -#endif SE_TabBarTearIndicator, SE_TabBarTearIndicatorLeft = SE_TabBarTearIndicator, @@ -326,10 +323,7 @@ public: SE_CheckBoxLayoutItem, SE_ComboBoxLayoutItem, SE_DateTimeEditLayoutItem, -#if QT_DEPRECATED_SINCE(5, 15) // ### Qt 6: remove - SE_DialogButtonBoxLayoutItem Q_DECL_ENUMERATOR_DEPRECATED, -#endif - SE_LabelLayoutItem = SE_DateTimeEditLayoutItem + 2, + SE_LabelLayoutItem, SE_ProgressBarLayoutItem, SE_PushButtonLayoutItem, SE_RadioButtonLayoutItem, @@ -510,10 +504,6 @@ public: PM_MdiSubWindowFrameWidth, PM_MdiSubWindowMinimizedWidth, -#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove - PM_MDIFrameWidth Q_DECL_ENUMERATOR_DEPRECATED = PM_MdiSubWindowFrameWidth, - PM_MDIMinimizedWidth Q_DECL_ENUMERATOR_DEPRECATED = PM_MdiSubWindowMinimizedWidth, -#endif PM_HeaderMargin, PM_HeaderMarkSize, @@ -531,13 +521,7 @@ public: PM_SpinBoxSliderHeight, -#if QT_DEPRECATED_SINCE(5, 15) // ### Qt 6: remove - PM_DefaultTopLevelMargin Q_DECL_ENUMERATOR_DEPRECATED, - PM_DefaultChildMargin Q_DECL_ENUMERATOR_DEPRECATED, - PM_DefaultLayoutSpacing Q_DECL_ENUMERATOR_DEPRECATED, -#endif - - PM_ToolBarIconSize = PM_SpinBoxSliderHeight + 4, + PM_ToolBarIconSize, PM_ListViewIconSize, PM_IconViewIconSize, PM_SmallIconSize, @@ -656,9 +640,6 @@ public: SH_ComboBox_Popup, SH_TitleBar_NoBorder, SH_Slider_StopMouseOverSlider, -#if QT_DEPRECATED_SINCE(5, 13) // ### Qt 6: remove - SH_ScrollBar_StopMouseOverSlider Q_DECL_ENUMERATOR_DEPRECATED = SH_Slider_StopMouseOverSlider, -#endif SH_BlinkCursorWhenTextSelected, SH_RichText_FullWidthSelection, SH_Menu_Scrollable, diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp index 1d63d140fb..26dbab5e15 100644 --- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp +++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp @@ -449,33 +449,33 @@ class Qt42Style : public QProxyStyle public: Qt42Style() : QProxyStyle(QStyleFactory::create("windows")) { - spacing = 6; - margin = 9; - margin_toplevel = 11; } - virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = 0, - const QWidget * widget = 0 ) const; + virtual int pixelMetric(PixelMetric metric, const QStyleOption * option = nullptr, + const QWidget * widget = nullptr ) const; - int spacing; - int margin; - int margin_toplevel; + int spacing = 6; + int margin = 9; + int margin_toplevel = 11; }; -int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option /*= 0*/, - const QWidget * widget /*= 0*/ ) const +int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * option, + const QWidget * widget) const { switch (metric) { - case PM_DefaultLayoutSpacing: - return spacing; - break; - case PM_DefaultTopLevelMargin: - return margin_toplevel; - break; - case PM_DefaultChildMargin: + case PM_LayoutLeftMargin: + case PM_LayoutRightMargin: + case PM_LayoutTopMargin: + case PM_LayoutBottomMargin: + if (option && option->state & State_Window) + return margin_toplevel; + if (widget && widget->isWindow()) + return margin_toplevel; return margin; - break; + case PM_LayoutHorizontalSpacing: + case PM_LayoutVerticalSpacing: + return spacing; default: break; } diff --git a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp index 4cec54856f..58dbfeb118 100644 --- a/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp +++ b/tests/auto/widgets/styles/qstyle/tst_qstyle.cpp @@ -83,7 +83,6 @@ private slots: #endif void testStyleFactory(); void testProxyStyle(); - void pixelMetric(); #if !defined(QT_NO_STYLE_WINDOWS) && !defined(QT_NO_STYLE_FUSION) void progressBarChangeStyle(); #endif @@ -348,57 +347,6 @@ void MyWidget::paintEvent(QPaintEvent *) } -class Qt42Style : public QCommonStyle -{ - Q_OBJECT -public: - int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, - const QWidget *widget = nullptr) const override; - - int margin_toplevel = 10; - int margin = 5; - int spacing = 0; -}; - -int Qt42Style::pixelMetric(PixelMetric metric, const QStyleOption * /* option = 0*/, - const QWidget * /* widget = 0*/ ) const -{ - switch (metric) { - case QStyle::PM_DefaultTopLevelMargin: - return margin_toplevel; - case QStyle::PM_DefaultChildMargin: - return margin; - case QStyle::PM_DefaultLayoutSpacing: - return spacing; - default: - break; - } - return -1; -} - - -void tst_QStyle::pixelMetric() -{ - QScopedPointer style(new Qt42Style); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 10); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 5); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), 0); - - style->margin_toplevel = 0; - style->margin = 0; - style->spacing = 0; - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), 0); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), 0); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), 0); - - style->margin_toplevel = -1; - style->margin = -1; - style->spacing = -1; - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultTopLevelMargin), -1); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultChildMargin), -1); - QCOMPARE(style->pixelMetric(QStyle::PM_DefaultLayoutSpacing), -1); -} - #if !defined(QT_NO_STYLE_WINDOWS) && !defined(QT_NO_STYLE_FUSION) void tst_QStyle::progressBarChangeStyle() {