Widgets: pass widget to QStyle::pixelMetric()
Make sure to pass the widget to QStyle::pixelMetric() as some styles might use this (e.g. the new windows styles) to determine the correct pixel metric. Pick-to: 6.6 6.5 6.2 Task-number: QTBUG-1857 Change-Id: I5c32f5af8b284749732b610e56b4e3d8c8ed1946 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io> Reviewed-by: David Faure <david.faure@kdab.com> (cherry picked from commit 43ce457cbd093fc06d99b5ac833c789ef7c893d5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
020a7e96d4
commit
a7f052319b
@ -325,7 +325,7 @@ void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect)
|
|||||||
const QPalette & g = palette();
|
const QPalette & g = palette();
|
||||||
QStyleOptionFrame opt;
|
QStyleOptionFrame opt;
|
||||||
opt.initFrom(this);
|
opt.initFrom(this);
|
||||||
int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt);
|
int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt, this);
|
||||||
opt.lineWidth = dfw;
|
opt.lineWidth = dfw;
|
||||||
opt.midLineWidth = 1;
|
opt.midLineWidth = 1;
|
||||||
opt.rect = rect.adjusted(b, b, -b, -b);
|
opt.rect = rect.adjusted(b, b, -b, -b);
|
||||||
|
@ -863,7 +863,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
|
|||||||
|
|
||||||
QStyleOption option;
|
QStyleOption option;
|
||||||
option.initFrom(q);
|
option.initFrom(q);
|
||||||
const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &option);
|
const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &option, q);
|
||||||
info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q);
|
info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q);
|
||||||
info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q);
|
info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q);
|
||||||
info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q);
|
info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q);
|
||||||
@ -875,7 +875,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
|
|||||||
info.hspacing = (layoutHorizontalSpacing == -1)
|
info.hspacing = (layoutHorizontalSpacing == -1)
|
||||||
? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
|
? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
|
||||||
: layoutHorizontalSpacing;
|
: layoutHorizontalSpacing;
|
||||||
info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &option);
|
info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &option, q);
|
||||||
info.buttonSpacing = (layoutHorizontalSpacing == -1)
|
info.buttonSpacing = (layoutHorizontalSpacing == -1)
|
||||||
? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal)
|
? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal)
|
||||||
: layoutHorizontalSpacing;
|
: layoutHorizontalSpacing;
|
||||||
|
@ -51,8 +51,8 @@ public:
|
|||||||
Q_ASSERT(style);
|
Q_ASSERT(style);
|
||||||
if (widget) //###
|
if (widget) //###
|
||||||
m_styleOption.initFrom(widget);
|
m_styleOption.initFrom(widget);
|
||||||
m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption);
|
m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption, widget);
|
||||||
m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption);
|
m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; }
|
inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; }
|
||||||
|
@ -46,7 +46,7 @@ qreal QGraphicsLayoutStyleInfo::spacing(Qt::Orientation orientation) const
|
|||||||
Q_ASSERT(style());
|
Q_ASSERT(style());
|
||||||
return style()->pixelMetric(orientation == Qt::Horizontal
|
return style()->pixelMetric(orientation == Qt::Horizontal
|
||||||
? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing,
|
? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing,
|
||||||
&m_styleOption);
|
&m_styleOption, widget());
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const
|
qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const
|
||||||
|
@ -1797,7 +1797,7 @@ void QListViewPrivate::prepareItemsLayout()
|
|||||||
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
|
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
|
||||||
QStyleOption option;
|
QStyleOption option;
|
||||||
option.initFrom(q);
|
option.initFrom(q);
|
||||||
frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option) * 2;
|
frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option, q) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// maximumViewportSize() already takes scrollbar into account if policy is
|
// maximumViewportSize() already takes scrollbar into account if policy is
|
||||||
|
@ -7601,7 +7601,7 @@ bool QWidget::restoreGeometry(const QByteArray &geometry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const int frameHeight = QApplication::style()
|
const int frameHeight = QApplication::style()
|
||||||
? QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight)
|
? QApplication::style()->pixelMetric(QStyle::PM_TitleBarHeight, nullptr, this)
|
||||||
: 20;
|
: 20;
|
||||||
|
|
||||||
if (!restoredNormalGeometry.isValid())
|
if (!restoredNormalGeometry.isValid())
|
||||||
|
@ -411,7 +411,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||||||
if (d->tabBarcloseButtonIcon.isNull())
|
if (d->tabBarcloseButtonIcon.isNull())
|
||||||
d->tabBarcloseButtonIcon = proxy()->standardIcon(QStyle::SP_TabCloseButton, opt, widget);
|
d->tabBarcloseButtonIcon = proxy()->standardIcon(QStyle::SP_TabCloseButton, opt, widget);
|
||||||
|
|
||||||
const int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize, opt);
|
const int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize, opt, widget);
|
||||||
QIcon::Mode mode = opt->state & State_Enabled ?
|
QIcon::Mode mode = opt->state & State_Enabled ?
|
||||||
(opt->state & State_Raised ? QIcon::Active : QIcon::Normal)
|
(opt->state & State_Raised ? QIcon::Active : QIcon::Normal)
|
||||||
: QIcon::Disabled;
|
: QIcon::Disabled;
|
||||||
@ -457,7 +457,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||||||
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
||||||
int lw = frame->lineWidth;
|
int lw = frame->lineWidth;
|
||||||
if (lw <= 0)
|
if (lw <= 0)
|
||||||
lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, opt);
|
lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, opt, widget);
|
||||||
|
|
||||||
qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
|
qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
|
||||||
}
|
}
|
||||||
@ -532,8 +532,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||||||
const int step2 = step / 2;
|
const int step2 = step / 2;
|
||||||
QPoint center(x + w / 2, y + h / 2);
|
QPoint center(x + w / 2, y + h / 2);
|
||||||
if (opt->state & State_Sunken) {
|
if (opt->state & State_Sunken) {
|
||||||
center += QPoint(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt),
|
center += QPoint(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget),
|
||||||
proxy()->pixelMetric(PM_ButtonShiftVertical, opt));
|
proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget));
|
||||||
}
|
}
|
||||||
p->translate(center);
|
p->translate(center);
|
||||||
p->fillRect(-len / 2, -step2, len, step, opt->palette.buttonText());
|
p->fillRect(-len / 2, -step2, len, step, opt->palette.buttonText());
|
||||||
@ -577,8 +577,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||||||
int bsx = 0;
|
int bsx = 0;
|
||||||
int bsy = 0;
|
int bsy = 0;
|
||||||
if (opt->state & State_Sunken) {
|
if (opt->state & State_Sunken) {
|
||||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget);
|
||||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
|
||||||
}
|
}
|
||||||
p->translate(sx + bsx, sy + bsy);
|
p->translate(sx + bsx, sy + bsy);
|
||||||
p->setPen(opt->palette.buttonText().color());
|
p->setPen(opt->palette.buttonText().color());
|
||||||
@ -1013,7 +1013,7 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
|
if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
|
||||||
bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option) - 2 * textMargin);
|
bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option, widget) - 2 * textMargin);
|
||||||
|
|
||||||
const int lineWidth = bounds.width();
|
const int lineWidth = bounds.width();
|
||||||
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
|
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
|
||||||
@ -1255,7 +1255,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w
|
|||||||
if (!opt->icon.isNull()) {
|
if (!opt->icon.isNull()) {
|
||||||
QSize iconSize = opt->iconSize;
|
QSize iconSize = opt->iconSize;
|
||||||
if (!iconSize.isValid()) {
|
if (!iconSize.isValid()) {
|
||||||
int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize, opt);
|
int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize, opt, widget);
|
||||||
iconSize = QSize(iconExtent, iconExtent);
|
iconSize = QSize(iconExtent, iconExtent);
|
||||||
}
|
}
|
||||||
QSize tabIconSize = opt->icon.actualSize(iconSize,
|
QSize tabIconSize = opt->icon.actualSize(iconSize,
|
||||||
@ -1502,7 +1502,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
|||||||
| Qt::TextSingleLine;
|
| Qt::TextSingleLine;
|
||||||
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
||||||
alignment |= Qt::TextHideMnemonic;
|
alignment |= Qt::TextHideMnemonic;
|
||||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
||||||
QPixmap pix = mbi->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
QPixmap pix = mbi->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
||||||
if (!pix.isNull())
|
if (!pix.isNull())
|
||||||
proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
|
proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
|
||||||
@ -1658,7 +1658,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
|||||||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
||||||
QRect rect = header->rect;
|
QRect rect = header->rect;
|
||||||
if (!header->icon.isNull()) {
|
if (!header->icon.isNull()) {
|
||||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
||||||
QPixmap pixmap
|
QPixmap pixmap
|
||||||
= header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
= header->icon.pixmap(QSize(iconExtent, iconExtent), p->device()->devicePixelRatio(), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
||||||
int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
||||||
@ -2036,7 +2036,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
|||||||
pss.restore();
|
pss.restore();
|
||||||
|
|
||||||
if (tab->state & State_HasFocus) {
|
if (tab->state & State_HasFocus) {
|
||||||
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
|
const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth, opt, widget);
|
||||||
|
|
||||||
int x1, x2;
|
int x1, x2;
|
||||||
x1 = tab->rect.left();
|
x1 = tab->rect.left();
|
||||||
@ -3869,8 +3869,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||||||
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
|
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
|
||||||
btnOpt.state |= State_Sunken;
|
btnOpt.state |= State_Sunken;
|
||||||
btnOpt.state &= ~State_Raised;
|
btnOpt.state &= ~State_Raised;
|
||||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget);
|
||||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
|
||||||
} else {
|
} else {
|
||||||
btnOpt.state |= State_Raised;
|
btnOpt.state |= State_Raised;
|
||||||
btnOpt.state &= ~State_Sunken;
|
btnOpt.state &= ~State_Sunken;
|
||||||
@ -3886,8 +3886,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||||||
if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
|
if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
|
||||||
btnOpt.state |= State_Sunken;
|
btnOpt.state |= State_Sunken;
|
||||||
btnOpt.state &= ~State_Raised;
|
btnOpt.state &= ~State_Raised;
|
||||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget);
|
||||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
|
||||||
} else {
|
} else {
|
||||||
btnOpt.state |= State_Raised;
|
btnOpt.state |= State_Raised;
|
||||||
btnOpt.state &= ~State_Sunken;
|
btnOpt.state &= ~State_Sunken;
|
||||||
@ -3903,8 +3903,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||||||
if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
|
if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
|
||||||
btnOpt.state |= State_Sunken;
|
btnOpt.state |= State_Sunken;
|
||||||
btnOpt.state &= ~State_Raised;
|
btnOpt.state &= ~State_Raised;
|
||||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget);
|
||||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget);
|
||||||
} else {
|
} else {
|
||||||
btnOpt.state |= State_Raised;
|
btnOpt.state |= State_Raised;
|
||||||
btnOpt.state &= ~State_Sunken;
|
btnOpt.state &= ~State_Sunken;
|
||||||
@ -4943,7 +4943,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contentsType, const QStyleOpti
|
|||||||
} else {
|
} else {
|
||||||
height = menuItemOpt->fontMetrics.height() + 8;
|
height = menuItemOpt->fontMetrics.height() + 8;
|
||||||
if (!menuItemOpt->icon.isNull()) {
|
if (!menuItemOpt->icon.isNull()) {
|
||||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt, widget);
|
||||||
height = qMax(height,
|
height = qMax(height,
|
||||||
menuItemOpt->icon.actualSize(QSize(iconExtent,
|
menuItemOpt->icon.actualSize(QSize(iconExtent,
|
||||||
iconExtent)).height() + 4);
|
iconExtent)).height() + 4);
|
||||||
@ -4973,7 +4973,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType contentsType, const QStyleOpti
|
|||||||
const int frameWidth = comboBoxOpt->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth,
|
const int frameWidth = comboBoxOpt->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth,
|
||||||
opt,
|
opt,
|
||||||
widget) * 2 : 0;
|
widget) * 2 : 0;
|
||||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin, opt) + 1);
|
const int textMargins = 2 * (proxy()->pixelMetric(PM_FocusFrameHMargin, opt, widget) + 1);
|
||||||
|
|
||||||
// QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
|
// QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
|
||||||
const int other = qMax(23, 2 * textMargins
|
const int other = qMax(23, 2 * textMargins
|
||||||
@ -5235,8 +5235,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
|
|||||||
if (widget) {
|
if (widget) {
|
||||||
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
||||||
mask->region = widget->rect();
|
mask->region = widget->rect();
|
||||||
const int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt);
|
const int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt, widget);
|
||||||
const int hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt);
|
const int hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt, widget);
|
||||||
mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
|
mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5249,7 +5249,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
|
|||||||
ret = true;
|
ret = true;
|
||||||
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
if (QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
||||||
mask->region = opt->rect;
|
mask->region = opt->rect;
|
||||||
const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, opt) * 2;
|
const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget) * 2;
|
||||||
mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
|
mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ void QFusionStyle::drawPrimitive(PrimitiveElement elem,
|
|||||||
// Shrinking the topMargin if Not checkable AND title is empty
|
// Shrinking the topMargin if Not checkable AND title is empty
|
||||||
topMargin = groupBoxTopMargin;
|
topMargin = groupBoxTopMargin;
|
||||||
} else {
|
} else {
|
||||||
topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
|
topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight, option, widget), option->fontMetrics.height()) + groupBoxTopMargin;
|
||||||
}
|
}
|
||||||
QRect frame = option->rect.adjusted(0, topMargin, 0, 0);
|
QRect frame = option->rect.adjusted(0, topMargin, 0, 0);
|
||||||
qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap);
|
qDrawBorderPixmap(painter, frame, QMargins(6, 6, 6, 6), pixmap);
|
||||||
@ -3032,7 +3032,7 @@ QSize QFusionStyle::sizeFromContents(ContentsType type, const QStyleOption *opti
|
|||||||
break;
|
break;
|
||||||
case CT_GroupBox:
|
case CT_GroupBox:
|
||||||
if (option) {
|
if (option) {
|
||||||
int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight), option->fontMetrics.height()) + groupBoxTopMargin;
|
int topMargin = qMax(pixelMetric(PM_ExclusiveIndicatorHeight, option, widget), option->fontMetrics.height()) + groupBoxTopMargin;
|
||||||
newSize += QSize(10, topMargin); // Add some space below the groupbox
|
newSize += QSize(10, topMargin); // Add some space below the groupbox
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -3216,8 +3216,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
|
|||||||
case SC_SliderHandle: {
|
case SC_SliderHandle: {
|
||||||
const bool bothTicks = (slider->tickPosition & QSlider::TicksBothSides) == QSlider::TicksBothSides;
|
const bool bothTicks = (slider->tickPosition & QSlider::TicksBothSides) == QSlider::TicksBothSides;
|
||||||
if (slider->orientation == Qt::Horizontal) {
|
if (slider->orientation == Qt::Horizontal) {
|
||||||
rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option));
|
rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option, widget));
|
||||||
rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option));
|
rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option, widget));
|
||||||
int centerY = slider->rect.center().y() - rect.height() / 2;
|
int centerY = slider->rect.center().y() - rect.height() / 2;
|
||||||
if (!bothTicks) {
|
if (!bothTicks) {
|
||||||
if (slider->tickPosition & QSlider::TicksAbove)
|
if (slider->tickPosition & QSlider::TicksAbove)
|
||||||
@ -3227,8 +3227,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
|
|||||||
}
|
}
|
||||||
rect.moveTop(centerY);
|
rect.moveTop(centerY);
|
||||||
} else {
|
} else {
|
||||||
rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option));
|
rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option, widget));
|
||||||
rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option));
|
rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option, widget));
|
||||||
int centerX = slider->rect.center().x() - rect.width() / 2;
|
int centerX = slider->rect.center().x() - rect.width() / 2;
|
||||||
if (!bothTicks) {
|
if (!bothTicks) {
|
||||||
if (slider->tickPosition & QSlider::TicksAbove)
|
if (slider->tickPosition & QSlider::TicksAbove)
|
||||||
@ -3325,7 +3325,7 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
|
|||||||
int margin = 3;
|
int margin = 3;
|
||||||
int leftMarginExtension = 0;
|
int leftMarginExtension = 0;
|
||||||
const int exclusiveIndicatorHeight = option->subControls.testFlag(SC_GroupBoxCheckBox) ?
|
const int exclusiveIndicatorHeight = option->subControls.testFlag(SC_GroupBoxCheckBox) ?
|
||||||
pixelMetric(PM_ExclusiveIndicatorHeight) : 0;
|
pixelMetric(PM_ExclusiveIndicatorHeight, option, widget) : 0;
|
||||||
const int topMargin = qMax(exclusiveIndicatorHeight, fontMetricsHeight) +
|
const int topMargin = qMax(exclusiveIndicatorHeight, fontMetricsHeight) +
|
||||||
groupBoxTopMargin;
|
groupBoxTopMargin;
|
||||||
return frameRect.adjusted(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBoxBottomMargin);
|
return frameRect.adjusted(leftMarginExtension + margin, margin + topMargin, -margin, -margin - groupBoxBottomMargin);
|
||||||
|
@ -383,7 +383,7 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
|
|||||||
|
|
||||||
switch (pm) {
|
switch (pm) {
|
||||||
case PM_MaximumDragDistance:
|
case PM_MaximumDragDistance:
|
||||||
ret = QCommonStyle::pixelMetric(PM_MaximumDragDistance);
|
ret = QCommonStyle::pixelMetric(PM_MaximumDragDistance, opt, widget);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
ret = 60;
|
ret = 60;
|
||||||
break;
|
break;
|
||||||
|
@ -2200,7 +2200,7 @@ QSize QCalendarWidget::minimumSizeHint() const
|
|||||||
|
|
||||||
QStyleOption option;
|
QStyleOption option;
|
||||||
option.initFrom(this);
|
option.initFrom(this);
|
||||||
const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option) + 1) * 2;
|
const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, this) + 1) * 2;
|
||||||
|
|
||||||
if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader) {
|
if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader) {
|
||||||
rows = 6;
|
rows = 6;
|
||||||
|
@ -172,7 +172,7 @@ bool QCommandLinkButtonPrivate::usingVistaStyle() const
|
|||||||
//### This is a hack to detect if we are indeed running Vista style themed and not in classic
|
//### This is a hack to detect if we are indeed running Vista style themed and not in classic
|
||||||
// When we add api to query for this, we should change this implementation to use it.
|
// When we add api to query for this, we should change this implementation to use it.
|
||||||
return q->property("_qt_usingVistaStyle").toBool()
|
return q->property("_qt_usingVistaStyle").toBool()
|
||||||
&& q->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, nullptr) == 0;
|
&& q->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, nullptr, q) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QCommandLinkButtonPrivate::init()
|
void QCommandLinkButtonPrivate::init()
|
||||||
@ -325,9 +325,9 @@ void QCommandLinkButton::paintEvent(QPaintEvent *)
|
|||||||
QSize pixmapSize = icon().actualSize(iconSize());
|
QSize pixmapSize = icon().actualSize(iconSize());
|
||||||
|
|
||||||
const int vOffset = isDown()
|
const int vOffset = isDown()
|
||||||
? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &option) : 0;
|
? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &option, this) : 0;
|
||||||
const int hOffset = isDown()
|
const int hOffset = isDown()
|
||||||
? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &option) : 0;
|
? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &option, this) : 0;
|
||||||
|
|
||||||
//Draw icon
|
//Draw icon
|
||||||
p.drawControl(QStyle::CE_PushButton, option);
|
p.drawControl(QStyle::CE_PushButton, option);
|
||||||
|
@ -52,8 +52,8 @@ void QFocusFramePrivate::updateSize()
|
|||||||
|
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
q->initStyleOption(&opt);
|
q->initStyleOption(&opt);
|
||||||
int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &opt),
|
int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &opt, q),
|
||||||
hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &opt);
|
hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &opt, q);
|
||||||
QPoint pos(widget->x(), widget->y());
|
QPoint pos(widget->x(), widget->y());
|
||||||
if (q->parentWidget() != widget->parentWidget())
|
if (q->parentWidget() != widget->parentWidget())
|
||||||
pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
|
pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
|
||||||
@ -229,8 +229,8 @@ QFocusFrame::paintEvent(QPaintEvent *)
|
|||||||
QStylePainter p(this);
|
QStylePainter p(this);
|
||||||
QStyleOption option;
|
QStyleOption option;
|
||||||
initStyleOption(&option);
|
initStyleOption(&option);
|
||||||
const int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &option);
|
const int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &option, this);
|
||||||
const int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option);
|
const int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, this);
|
||||||
QWidgetPrivate *wd = qt_widget_private(d->widget);
|
QWidgetPrivate *wd = qt_widget_private(d->widget);
|
||||||
QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2);
|
QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2);
|
||||||
p.setClipRect(rect);
|
p.setClipRect(rect);
|
||||||
|
@ -464,9 +464,9 @@ QSize QGroupBox::minimumSizeHint() const
|
|||||||
int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(u' ');
|
int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(u' ');
|
||||||
int baseHeight = metrics.height();
|
int baseHeight = metrics.height();
|
||||||
if (d->checkable) {
|
if (d->checkable) {
|
||||||
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth, &option);
|
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth, &option, this);
|
||||||
baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &option);
|
baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &option, this);
|
||||||
baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight, &option));
|
baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight, &option, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this);
|
QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this);
|
||||||
|
@ -2094,7 +2094,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
|
|||||||
if (d->cursorVisible && !d->control->isReadOnly() && d->control->inputMask().isEmpty())
|
if (d->cursorVisible && !d->control->isReadOnly() && d->control->inputMask().isEmpty())
|
||||||
flags |= QWidgetLineControl::DrawCursor;
|
flags |= QWidgetLineControl::DrawCursor;
|
||||||
|
|
||||||
d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth, &panel));
|
d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth, &panel, this));
|
||||||
d->control->draw(&p, topLeft, r, flags);
|
d->control->draw(&p, topLeft, r, flags);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2856,7 +2856,7 @@ QLayoutItem *QMainWindowLayout::unplug(QWidget *widget, QDockWidgetPrivate::Drag
|
|||||||
const auto *layout = qobject_cast<QDockWidgetLayout *>(dw->layout());
|
const auto *layout = qobject_cast<QDockWidgetLayout *>(dw->layout());
|
||||||
const bool verticalTitleBar = layout ? layout->verticalTitleBar : false;
|
const bool verticalTitleBar = layout ? layout->verticalTitleBar : false;
|
||||||
const int tbHeight = QApplication::style()
|
const int tbHeight = QApplication::style()
|
||||||
? QApplication::style()->pixelMetric(QStyle::PixelMetric::PM_TitleBarHeight)
|
? QApplication::style()->pixelMetric(QStyle::PixelMetric::PM_TitleBarHeight, nullptr, dw)
|
||||||
: 20;
|
: 20;
|
||||||
const int minHeight = verticalTitleBar ? 2 * tbHeight : tbHeight;
|
const int minHeight = verticalTitleBar ? 2 * tbHeight : tbHeight;
|
||||||
const int minWidth = verticalTitleBar ? tbHeight : 2 * tbHeight;
|
const int minWidth = verticalTitleBar ? tbHeight : 2 * tbHeight;
|
||||||
|
@ -2839,7 +2839,7 @@ void QMenu::paintEvent(QPaintEvent *e)
|
|||||||
frame.rect = rect();
|
frame.rect = rect();
|
||||||
frame.palette = palette();
|
frame.palette = palette();
|
||||||
frame.state = QStyle::State_None;
|
frame.state = QStyle::State_None;
|
||||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &frame);
|
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &frame, this);
|
||||||
frame.midLineWidth = 0;
|
frame.midLineWidth = 0;
|
||||||
p.drawPrimitive(QStyle::PE_FrameMenu, frame);
|
p.drawPrimitive(QStyle::PE_FrameMenu, frame);
|
||||||
}
|
}
|
||||||
|
@ -914,7 +914,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
|
|||||||
frame.rect = rect();
|
frame.rect = rect();
|
||||||
frame.palette = palette();
|
frame.palette = palette();
|
||||||
frame.state = QStyle::State_None;
|
frame.state = QStyle::State_None;
|
||||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, &frame);
|
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, &frame, this);
|
||||||
frame.midLineWidth = 0;
|
frame.midLineWidth = 0;
|
||||||
style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);
|
style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ QSize QToolBarExtension::sizeHint() const
|
|||||||
{
|
{
|
||||||
QStyleOption opt;
|
QStyleOption opt;
|
||||||
opt.initFrom(this);
|
opt.initFrom(this);
|
||||||
const int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt);
|
const int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt, this);
|
||||||
return QSize(ext, ext);
|
return QSize(ext, ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2470,7 +2470,7 @@ void QWidgetTextControl::setCursorWidth(int width)
|
|||||||
{
|
{
|
||||||
Q_D(QWidgetTextControl);
|
Q_D(QWidgetTextControl);
|
||||||
if (width == -1)
|
if (width == -1)
|
||||||
width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth, nullptr);
|
width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth, nullptr, qobject_cast<QWidget *>(parent()));
|
||||||
d->doc->documentLayout()->setProperty("cursorWidth", width);
|
d->doc->documentLayout()->setProperty("cursorWidth", width);
|
||||||
d->repaintCursor();
|
d->repaintCursor();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user