Remove deprecated QStyle enum values

Change-Id: I7eba336017844c06b2976df53d440e167abd7894
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-04-15 17:01:11 +02:00
parent fe4a5a27e0
commit 90295dcd03
7 changed files with 24 additions and 129 deletions

View File

@ -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]

View File

@ -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:

View File

@ -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;

View File

@ -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.

View File

@ -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,

View File

@ -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;
}

View File

@ -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<Qt42Style> 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()
{