Skip to content

Commit

Permalink
QCommonStyle::pixelMetric(): Silence warnings about deprecated enum v…
Browse files Browse the repository at this point in the history
…alues

Add the Qt 6 code paths and enclose in warnings exclusions.

Change-Id: I321296ef220fb788f04979ffff42a8a5f226dfdb
Reviewed-by: Richard Moe Gustavsen <[email protected]>
  • Loading branch information
FriedemannKleint committed Mar 31, 2020
1 parent 8f88a39 commit 82a39f1
Showing 1 changed file with 38 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/widgets/styles/qcommonstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4498,6 +4498,21 @@ QRect QCommonStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex
return ret;
}

static inline int defaultLayoutTopMargin(const QStyleOption *opt)
{
return int(QStyleHelper::dpiScaled(11, opt));
}

static inline int defaultLayoutChildMargin(const QStyleOption *opt)
{
return int(QStyleHelper::dpiScaled(9, opt));
}

static inline int defaultLayoutSpacing(const QStyleOption *opt)
{
return int(QStyleHelper::dpiScaled(6, opt));
}

/*! \reimp */
int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *widget) const
{
Expand Down Expand Up @@ -4776,28 +4791,44 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
case PM_LayoutBottomMargin:
{
bool isWindow = false;
if (opt) {
isWindow = (opt->state & State_Window);
} else if (widget) {
if (opt)
isWindow = opt->state.testFlag(State_Window);
else if (widget)
isWindow = widget->isWindow();
}
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
ret = isWindow ? defaultLayoutTopMargin(opt) : defaultLayoutChildMargin(opt);
#else
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin, opt);
QT_WARNING_POP
#endif
}
break;
case PM_LayoutHorizontalSpacing:
case PM_LayoutVerticalSpacing:
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
ret = defaultLayoutTopMargin(opt);
#else
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing, opt);
QT_WARNING_POP
#endif
break;

QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
case PM_DefaultTopLevelMargin:
ret = int(QStyleHelper::dpiScaled(11, opt));
ret = defaultLayoutTopMargin(opt);
break;
case PM_DefaultChildMargin:
ret = int(QStyleHelper::dpiScaled(9, opt));
ret = defaultLayoutChildMargin(opt);
break;
case PM_DefaultLayoutSpacing:
ret = int(QStyleHelper::dpiScaled(6, opt));
ret = defaultLayoutSpacing(opt);
break;
QT_WARNING_POP

case PM_ToolBarIconSize:
ret = 0;
Expand Down

0 comments on commit 82a39f1

Please sign in to comment.