Fix wrong DPI used by QStyle::pixelMetric()
Pass on the option or the widget in order to ensure usage of the correct DPI for High DPI scaling. Task-number: QTBUG-82356 Change-Id: I5df903a83f88adebd143e514e2fead367d39f015 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>bb10
parent
c58ee54a70
commit
835e18d9ff
|
|
@ -2215,7 +2215,7 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt
|
|||
{
|
||||
const int controlTop = int(6 * factor);
|
||||
const int controlHeight = int(height - controlTop - 3 * factor);
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, option);
|
||||
QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
|
||||
if (tb->icon.isNull())
|
||||
iconSize = QSize(controlHeight, controlHeight);
|
||||
|
|
|
|||
|
|
@ -3508,7 +3508,7 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
|
|||
{
|
||||
const int controlTop = 6;
|
||||
const int controlHeight = height - controlTop - 3;
|
||||
const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
||||
const int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, option);
|
||||
QSize iconSize = tb->icon.actualSize(QSize(iconExtent, iconExtent));
|
||||
if (tb->icon.isNull())
|
||||
iconSize = QSize(controlHeight, controlHeight);
|
||||
|
|
@ -3630,7 +3630,7 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
|
|||
sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin
|
||||
+ qreal(1) / factor - 1);
|
||||
}
|
||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
|
||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin, option) + 1);
|
||||
sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option, widget)
|
||||
+ textMargins, 23), 0); //arrow button
|
||||
}
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect)
|
|||
|
||||
const QPalette & g = palette();
|
||||
QStyleOptionFrame opt;
|
||||
int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||
opt.initFrom(this);
|
||||
int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &opt);
|
||||
opt.lineWidth = dfw;
|
||||
opt.midLineWidth = 1;
|
||||
opt.rect = rect.adjusted(b, b, -b, -b);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@
|
|||
# include "qshortcut.h"
|
||||
#endif
|
||||
#include "qstyle.h"
|
||||
#include "qstyleoption.h"
|
||||
#include "qvarlengtharray.h"
|
||||
#if defined(Q_OS_MACX)
|
||||
#include <QtCore/QMetaMethod>
|
||||
|
|
@ -897,7 +898,9 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
|
|||
|
||||
QWizardLayoutInfo info;
|
||||
|
||||
const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
|
||||
QStyleOption option;
|
||||
option.initFrom(q);
|
||||
const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &option);
|
||||
info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, 0, q);
|
||||
info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, 0, q);
|
||||
info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, 0, q);
|
||||
|
|
@ -909,7 +912,7 @@ QWizardLayoutInfo QWizardPrivate::layoutInfoForCurrentPage()
|
|||
info.hspacing = (layoutHorizontalSpacing == -1)
|
||||
? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
|
||||
: layoutHorizontalSpacing;
|
||||
info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
|
||||
info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &option);
|
||||
info.buttonSpacing = (layoutHorizontalSpacing == -1)
|
||||
? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal)
|
||||
: layoutHorizontalSpacing;
|
||||
|
|
|
|||
|
|
@ -87,8 +87,8 @@ public:
|
|||
Q_ASSERT(style);
|
||||
if (widget) //###
|
||||
m_styleOption.initFrom(widget);
|
||||
m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
|
||||
m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
|
||||
m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &m_styleOption);
|
||||
m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &m_styleOption);
|
||||
}
|
||||
|
||||
inline void invalidate() { m_valid = false; m_style = nullptr; m_widget = nullptr; }
|
||||
|
|
|
|||
|
|
@ -80,7 +80,9 @@ qreal QGraphicsLayoutStyleInfo::perItemSpacing(QLayoutPolicy::ControlType contro
|
|||
qreal QGraphicsLayoutStyleInfo::spacing(Qt::Orientation orientation) const
|
||||
{
|
||||
Q_ASSERT(style());
|
||||
return style()->pixelMetric(orientation == Qt::Horizontal ? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing);
|
||||
return style()->pixelMetric(orientation == Qt::Horizontal
|
||||
? QStyle::PM_LayoutHorizontalSpacing : QStyle::PM_LayoutVerticalSpacing,
|
||||
&m_styleOption);
|
||||
}
|
||||
|
||||
qreal QGraphicsLayoutStyleInfo::windowMargin(Qt::Orientation orientation) const
|
||||
|
|
|
|||
|
|
@ -615,7 +615,7 @@ void QGraphicsWidget::unsetWindowFrameMargins()
|
|||
QStyleOptionTitleBar bar;
|
||||
d->initStyleOptionTitleBar(&bar);
|
||||
QStyle *style = this->style();
|
||||
qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
|
||||
const qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, &bar);
|
||||
qreal titleBarHeight = d->titleBarHeight(bar);
|
||||
setWindowFrameMargins(margin, titleBarHeight, margin, margin);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1122,7 +1122,7 @@ QRect QItemDelegate::textRectangle(QPainter * /*painter*/, const QRect &rect,
|
|||
QSizeF fpSize = d->doTextLayout(rect.width());
|
||||
const QSize size = QSize(qCeil(fpSize.width()), qCeil(fpSize.height()));
|
||||
// ###: textRectangle should take style option as argument
|
||||
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1;
|
||||
const int textMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr) + 1;
|
||||
return QRect(0, 0, size.width() + 2 * textMargin, size.height());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1728,8 +1728,11 @@ void QListViewPrivate::prepareItemsLayout()
|
|||
layoutBounds = QRect(QPoint(), q->maximumViewportSize());
|
||||
|
||||
int frameAroundContents = 0;
|
||||
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
|
||||
frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
|
||||
if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents)) {
|
||||
QStyleOption option;
|
||||
option.initFrom(q);
|
||||
frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, &option) * 2;
|
||||
}
|
||||
|
||||
// maximumViewportSize() already takes scrollbar into account if policy is
|
||||
// Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
|
||||
|
|
|
|||
|
|
@ -431,7 +431,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||
QIcon::Active, QIcon::Off);
|
||||
}
|
||||
|
||||
int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
const int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize, opt);
|
||||
QIcon::Mode mode = opt->state & State_Enabled ?
|
||||
(opt->state & State_Raised ? QIcon::Active : QIcon::Normal)
|
||||
: QIcon::Disabled;
|
||||
|
|
@ -477,7 +477,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||
if (const QStyleOptionFrame *frame = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
||||
int lw = frame->lineWidth;
|
||||
if (lw <= 0)
|
||||
lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth);
|
||||
lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth, opt);
|
||||
|
||||
qDrawShadePanel(p, frame->rect, frame->palette, false, lw);
|
||||
}
|
||||
|
|
@ -563,8 +563,8 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
|
|||
int bsx = 0;
|
||||
int bsy = 0;
|
||||
if (opt->state & State_Sunken) {
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
||||
}
|
||||
p->save();
|
||||
p->translate(sx + bsx, sy + bsy);
|
||||
|
|
@ -994,7 +994,7 @@ QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItem *option, int
|
|||
}
|
||||
|
||||
if (wrapText && option->features & QStyleOptionViewItem::HasCheckIndicator)
|
||||
bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth) - 2 * textMargin);
|
||||
bounds.setWidth(bounds.width() - proxyStyle->pixelMetric(QStyle::PM_IndicatorWidth, option) - 2 * textMargin);
|
||||
|
||||
const int lineWidth = bounds.width();
|
||||
const QSizeF size = viewItemTextLayout(textLayout, lineWidth);
|
||||
|
|
@ -1240,7 +1240,7 @@ void QCommonStylePrivate::tabLayout(const QStyleOptionTab *opt, const QWidget *w
|
|||
if (!opt->icon.isNull()) {
|
||||
QSize iconSize = opt->iconSize;
|
||||
if (!iconSize.isValid()) {
|
||||
int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize, opt);
|
||||
iconSize = QSize(iconExtent, iconExtent);
|
||||
}
|
||||
QSize tabIconSize = opt->icon.actualSize(iconSize,
|
||||
|
|
@ -1490,7 +1490,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
|||
| Qt::TextSingleLine;
|
||||
if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
|
||||
alignment |= Qt::TextHideMnemonic;
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
||||
QPixmap pix = mbi->icon.pixmap(qt_getWindow(widget), QSize(iconExtent, iconExtent), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
||||
if (!pix.isNull())
|
||||
proxy()->drawItemPixmap(p,mbi->rect, alignment, pix);
|
||||
|
|
@ -1646,7 +1646,7 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
|
|||
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
|
||||
QRect rect = header->rect;
|
||||
if (!header->icon.isNull()) {
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
||||
QPixmap pixmap
|
||||
= header->icon.pixmap(qt_getWindow(widget), QSize(iconExtent, iconExtent), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);
|
||||
int pixw = pixmap.width() / pixmap.devicePixelRatio();
|
||||
|
|
@ -3857,8 +3857,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||
if (opt->activeSubControls & QStyle::SC_MdiCloseButton && (opt->state & State_Sunken)) {
|
||||
btnOpt.state |= State_Sunken;
|
||||
btnOpt.state &= ~State_Raised;
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
||||
} else {
|
||||
btnOpt.state |= State_Raised;
|
||||
btnOpt.state &= ~State_Sunken;
|
||||
|
|
@ -3874,8 +3874,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||
if (opt->activeSubControls & QStyle::SC_MdiNormalButton && (opt->state & State_Sunken)) {
|
||||
btnOpt.state |= State_Sunken;
|
||||
btnOpt.state &= ~State_Raised;
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
||||
} else {
|
||||
btnOpt.state |= State_Raised;
|
||||
btnOpt.state &= ~State_Sunken;
|
||||
|
|
@ -3891,8 +3891,8 @@ void QCommonStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCompl
|
|||
if (opt->activeSubControls & QStyle::SC_MdiMinButton && (opt->state & State_Sunken)) {
|
||||
btnOpt.state |= State_Sunken;
|
||||
btnOpt.state &= ~State_Raised;
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
|
||||
bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt);
|
||||
bsy = proxy()->pixelMetric(PM_ButtonShiftVertical, opt);
|
||||
} else {
|
||||
btnOpt.state |= State_Raised;
|
||||
btnOpt.state &= ~State_Sunken;
|
||||
|
|
@ -4775,12 +4775,12 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid
|
|||
} else if (widget) {
|
||||
isWindow = widget->isWindow();
|
||||
}
|
||||
ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin);
|
||||
ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin, opt);
|
||||
}
|
||||
break;
|
||||
case PM_LayoutHorizontalSpacing:
|
||||
case PM_LayoutVerticalSpacing:
|
||||
ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing);
|
||||
ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing, opt);
|
||||
break;
|
||||
|
||||
case PM_DefaultTopLevelMargin:
|
||||
|
|
@ -4931,7 +4931,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
|||
} else {
|
||||
h = mi->fontMetrics.height() + 8;
|
||||
if (!mi->icon.isNull()) {
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
|
||||
int iconExtent = proxy()->pixelMetric(PM_SmallIconSize, opt);
|
||||
h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4);
|
||||
}
|
||||
}
|
||||
|
|
@ -4957,7 +4957,7 @@ QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
|
|||
case CT_ComboBox:
|
||||
if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
|
||||
int fw = cmb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0;
|
||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1);
|
||||
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin, opt) + 1);
|
||||
// QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins...
|
||||
int other = qMax(23, 2*textMargins + proxy()->pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget));
|
||||
sz = QSize(sz.width() + fw + other, sz.height() + fw);
|
||||
|
|
@ -5207,8 +5207,8 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
|
|||
if (widget) {
|
||||
if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
||||
mask->region = widget->rect();
|
||||
int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin),
|
||||
hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin);
|
||||
const int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin, opt);
|
||||
const int hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin, opt);
|
||||
mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin));
|
||||
}
|
||||
}
|
||||
|
|
@ -5221,7 +5221,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget
|
|||
ret = true;
|
||||
if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) {
|
||||
mask->region = opt->rect;
|
||||
int margin = proxy()->pixelMetric(PM_DefaultFrameWidth) * 2;
|
||||
const int margin = proxy()->pixelMetric(PM_DefaultFrameWidth, opt) * 2;
|
||||
mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3347,8 +3347,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
|
|||
switch (subControl) {
|
||||
case SC_SliderHandle: {
|
||||
if (slider->orientation == Qt::Horizontal) {
|
||||
rect.setHeight(proxy()->pixelMetric(PM_SliderThickness));
|
||||
rect.setWidth(proxy()->pixelMetric(PM_SliderLength));
|
||||
rect.setHeight(proxy()->pixelMetric(PM_SliderThickness, option));
|
||||
rect.setWidth(proxy()->pixelMetric(PM_SliderLength, option));
|
||||
int centerY = slider->rect.center().y() - rect.height() / 2;
|
||||
if (slider->tickPosition & QSlider::TicksAbove)
|
||||
centerY += tickSize;
|
||||
|
|
@ -3356,8 +3356,8 @@ QRect QFusionStyle::subControlRect(ComplexControl control, const QStyleOptionCom
|
|||
centerY -= tickSize;
|
||||
rect.moveTop(centerY);
|
||||
} else {
|
||||
rect.setWidth(proxy()->pixelMetric(PM_SliderThickness));
|
||||
rect.setHeight(proxy()->pixelMetric(PM_SliderLength));
|
||||
rect.setWidth(proxy()->pixelMetric(PM_SliderThickness, option));
|
||||
rect.setHeight(proxy()->pixelMetric(PM_SliderLength, option));
|
||||
int centerX = slider->rect.center().x() - rect.width() / 2;
|
||||
if (slider->tickPosition & QSlider::TicksAbove)
|
||||
centerX += tickSize;
|
||||
|
|
|
|||
|
|
@ -1003,13 +1003,13 @@ QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option,
|
|||
return d->computeSize(desc, w, h);
|
||||
}
|
||||
|
||||
QSize QPixmapStyle::lineEditSizeFromContents(const QStyleOption *,
|
||||
QSize QPixmapStyle::lineEditSizeFromContents(const QStyleOption *option,
|
||||
const QSize &contentsSize, const QWidget *) const
|
||||
{
|
||||
Q_D(const QPixmapStyle);
|
||||
|
||||
const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled);
|
||||
const int border = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth);
|
||||
const int border = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, option);
|
||||
|
||||
int w = contentsSize.width() + border + desc.margins.left() + desc.margins.right();
|
||||
int h = contentsSize.height() + border + desc.margins.top() + desc.margins.bottom();
|
||||
|
|
|
|||
|
|
@ -2232,7 +2232,9 @@ QSize QCalendarWidget::minimumSizeHint() const
|
|||
int rows = 7;
|
||||
int cols = 8;
|
||||
|
||||
const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin) + 1) * 2;
|
||||
QStyleOption option;
|
||||
option.initFrom(this);
|
||||
const int marginH = (style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option) + 1) * 2;
|
||||
|
||||
if (horizontalHeaderFormat() == QCalendarWidget::NoHorizontalHeader) {
|
||||
rows = 6;
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ public:
|
|||
setAttribute(Qt::WA_NoMousePropagation);
|
||||
}
|
||||
QSize sizeHint() const override {
|
||||
return QSize(20, style()->pixelMetric(QStyle::PM_MenuScrollerHeight));
|
||||
return QSize(20, style()->pixelMetric(QStyle::PM_MenuScrollerHeight, nullptr, this));
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ bool QCommandLinkButtonPrivate::usingVistaStyle() const
|
|||
//### 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.
|
||||
return q->style()->inherits("QWindowsVistaStyle")
|
||||
&& !q->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal);
|
||||
&& q->style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, nullptr) == 0;
|
||||
}
|
||||
|
||||
void QCommandLinkButtonPrivate::init()
|
||||
|
|
@ -355,8 +355,10 @@ void QCommandLinkButton::paintEvent(QPaintEvent *)
|
|||
option.icon = QIcon(); //we draw this ourselves
|
||||
QSize pixmapSize = icon().actualSize(iconSize());
|
||||
|
||||
int vOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical) : 0;
|
||||
int hOffset = isDown() ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal) : 0;
|
||||
const int vOffset = isDown()
|
||||
? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &option) : 0;
|
||||
const int hOffset = isDown()
|
||||
? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &option) : 0;
|
||||
|
||||
//Draw icon
|
||||
p.drawControl(QStyle::CE_PushButton, option);
|
||||
|
|
|
|||
|
|
@ -86,8 +86,10 @@ void QFocusFramePrivate::updateSize()
|
|||
if (!widget)
|
||||
return;
|
||||
|
||||
int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin),
|
||||
hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
|
||||
QStyleOption opt;
|
||||
q->initStyleOption(&opt);
|
||||
int vmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &opt),
|
||||
hmargin = q->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &opt);
|
||||
QPoint pos(widget->x(), widget->y());
|
||||
if (q->parentWidget() != widget->parentWidget())
|
||||
pos = widget->parentWidget()->mapTo(q->parentWidget(), pos);
|
||||
|
|
@ -98,8 +100,6 @@ void QFocusFramePrivate::updateSize()
|
|||
|
||||
q->setGeometry(geom);
|
||||
QStyleHintReturnMask mask;
|
||||
QStyleOption opt;
|
||||
q->initStyleOption(&opt);
|
||||
if (q->style()->styleHint(QStyle::SH_FocusFrame_Mask, &opt, q, &mask))
|
||||
q->setMask(mask.region);
|
||||
}
|
||||
|
|
@ -263,8 +263,8 @@ QFocusFrame::paintEvent(QPaintEvent *)
|
|||
QStylePainter p(this);
|
||||
QStyleOption option;
|
||||
initStyleOption(&option);
|
||||
int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin);
|
||||
int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
|
||||
const int vmargin = style()->pixelMetric(QStyle::PM_FocusFrameVMargin, &option);
|
||||
const int hmargin = style()->pixelMetric(QStyle::PM_FocusFrameHMargin, &option);
|
||||
QWidgetPrivate *wd = qt_widget_private(d->widget);
|
||||
QRect rect = wd->clipRect().adjusted(0, 0, hmargin*2, vmargin*2);
|
||||
p.setClipRect(rect);
|
||||
|
|
|
|||
|
|
@ -491,9 +491,9 @@ QSize QGroupBox::minimumSizeHint() const
|
|||
int baseWidth = metrics.horizontalAdvance(d->title) + metrics.horizontalAdvance(QLatin1Char(' '));
|
||||
int baseHeight = metrics.height();
|
||||
if (d->checkable) {
|
||||
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth);
|
||||
baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing);
|
||||
baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight));
|
||||
baseWidth += style()->pixelMetric(QStyle::PM_IndicatorWidth, &option);
|
||||
baseWidth += style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, &option);
|
||||
baseHeight = qMax(baseHeight, style()->pixelMetric(QStyle::PM_IndicatorHeight, &option));
|
||||
}
|
||||
|
||||
QSize size = style()->sizeFromContents(QStyle::CT_GroupBox, &option, QSize(baseWidth, baseHeight), this);
|
||||
|
|
|
|||
|
|
@ -2073,7 +2073,7 @@ void QLineEdit::paintEvent(QPaintEvent *)
|
|||
if (d->cursorVisible && !d->control->isReadOnly())
|
||||
flags |= QWidgetLineControl::DrawCursor;
|
||||
|
||||
d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth));
|
||||
d->control->setCursorWidth(style()->pixelMetric(QStyle::PM_TextCursorWidth, &panel));
|
||||
d->control->draw(&p, topLeft, r, flags);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2828,7 +2828,7 @@ void QMenu::paintEvent(QPaintEvent *e)
|
|||
frame.rect = rect();
|
||||
frame.palette = palette();
|
||||
frame.state = QStyle::State_None;
|
||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth);
|
||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuPanelWidth, &frame);
|
||||
frame.midLineWidth = 0;
|
||||
style()->drawPrimitive(QStyle::PE_FrameMenu, &frame, &p, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1019,7 +1019,7 @@ void QMenuBar::paintEvent(QPaintEvent *e)
|
|||
frame.rect = rect();
|
||||
frame.palette = palette();
|
||||
frame.state = QStyle::State_None;
|
||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth);
|
||||
frame.lineWidth = style()->pixelMetric(QStyle::PM_MenuBarPanelWidth, &frame);
|
||||
frame.midLineWidth = 0;
|
||||
style()->drawPrimitive(QStyle::PE_PanelMenuBar, &frame, &p, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ void QToolBarExtension::paintEvent(QPaintEvent *)
|
|||
|
||||
QSize QToolBarExtension::sizeHint() const
|
||||
{
|
||||
int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent);
|
||||
QStyleOption opt;
|
||||
opt.initFrom(this);
|
||||
const int ext = style()->pixelMetric(QStyle::PM_ToolBarExtensionExtent, &opt);
|
||||
return QSize(ext, ext);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2463,7 +2463,7 @@ void QWidgetTextControl::setCursorWidth(int width)
|
|||
Q_UNUSED(width);
|
||||
#else
|
||||
if (width == -1)
|
||||
width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
|
||||
width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth, nullptr);
|
||||
d->doc->documentLayout()->setProperty("cursorWidth", width);
|
||||
#endif
|
||||
d->repaintCursor();
|
||||
|
|
|
|||
Loading…
Reference in New Issue