QStyle/QWidget: Avoid repetitive invocation of QStyleHelper::dpiScaled()
Store the result of QStyleHelper::dpiScaled() or functions dependent on it in a variable, preparing the addition of a DPI parameter. Task-number: QTBUG-45055 Change-Id: Ic70d65b590793c29a4b1f7a7a5312dd169517fc5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
58b4e07369
commit
6accc102d3
@ -1486,11 +1486,13 @@ case PE_Frame:
|
||||
|
||||
// Inner white border
|
||||
p->setPen(QPen(option->palette.base().color(), 0));
|
||||
p->drawRect(QRectF(option->rect).adjusted(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5),
|
||||
QStyleHelper::dpiScaled(-1), QStyleHelper::dpiScaled(-1)));
|
||||
const auto topLevelAdjustment = QStyleHelper::dpiScaled(0.5);
|
||||
const auto bottomRightAdjustment = QStyleHelper::dpiScaled(-1);
|
||||
p->drawRect(QRectF(option->rect).adjusted(topLevelAdjustment, topLevelAdjustment,
|
||||
bottomRightAdjustment, bottomRightAdjustment));
|
||||
// Outer dark border
|
||||
p->setPen(QPen(bordercolor, 0));
|
||||
p->drawRect(QRectF(option->rect).adjusted(0, 0, QStyleHelper::dpiScaled(-0.5), QStyleHelper::dpiScaled(-0.5)));
|
||||
p->drawRect(QRectF(option->rect).adjusted(0, 0, -topLevelAdjustment, -topLevelAdjustment));
|
||||
p->setPen(oldPen);
|
||||
return;
|
||||
} else if (fillType == BT_NONE) {
|
||||
@ -3534,9 +3536,12 @@ QRect QWindowsXPStyle::subControlRect(ComplexControl cc, const QStyleOptionCompl
|
||||
qRound(QStyleHelper::dpiScaled(16)), he - qRound(QStyleHelper::dpiScaled(2)));
|
||||
break;
|
||||
|
||||
case SC_ComboBoxEditField:
|
||||
rect = QRect(x + qRound(QStyleHelper::dpiScaled(2)), y + qRound(QStyleHelper::dpiScaled(2)),
|
||||
wi - qRound(QStyleHelper::dpiScaled(3 + 16)), he - qRound(QStyleHelper::dpiScaled(4)));
|
||||
case SC_ComboBoxEditField: {
|
||||
const int frame = qRound(QStyleHelper::dpiScaled(2));
|
||||
rect = QRect(x + frame, y + frame,
|
||||
wi - qRound(QStyleHelper::dpiScaled(3 + 16)),
|
||||
he - qRound(QStyleHelper::dpiScaled(4)));
|
||||
}
|
||||
break;
|
||||
|
||||
case SC_ComboBoxListBoxPopup:
|
||||
|
@ -1595,23 +1595,25 @@ bool QWizardPrivate::handleAeroStyleChange()
|
||||
bool vistaMargins = false;
|
||||
|
||||
if (isVistaThemeEnabled()) {
|
||||
const int topOffset = vistaHelper->topOffset();
|
||||
const int topPadding = vistaHelper->topPadding();
|
||||
if (isVistaThemeEnabled(QVistaHelper::VistaAero)) {
|
||||
if (isWindow) {
|
||||
vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
|
||||
q->installEventFilter(vistaHelper);
|
||||
}
|
||||
q->setMouseTracking(true);
|
||||
antiFlickerWidget->move(0, vistaHelper->titleBarSize() + vistaHelper->topOffset());
|
||||
antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset);
|
||||
vistaHelper->backButton()->move(
|
||||
0, vistaHelper->topOffset() // ### should ideally work without the '+ 1'
|
||||
- qMin(vistaHelper->topOffset(), vistaHelper->topPadding() + 1));
|
||||
0, topOffset // ### should ideally work without the '+ 1'
|
||||
- qMin(topOffset, topPadding + 1));
|
||||
vistaMargins = true;
|
||||
vistaHelper->backButton()->show();
|
||||
} else {
|
||||
if (isWindow)
|
||||
vistaHelper->setDWMTitleBar(QVistaHelper::NormalTitleBar);
|
||||
q->setMouseTracking(true);
|
||||
antiFlickerWidget->move(0, vistaHelper->topOffset());
|
||||
antiFlickerWidget->move(0, topOffset);
|
||||
vistaHelper->backButton()->move(0, -1); // ### should ideally work with (0, 0)
|
||||
}
|
||||
if (isWindow)
|
||||
|
@ -293,9 +293,9 @@ void QVistaHelper::drawTitleBar(QPainter *painter)
|
||||
int glowOffset = 0;
|
||||
|
||||
if (vistaState() == VistaAero) {
|
||||
textHeight += 2 * glowSize();
|
||||
textWidth += 2 * glowSize();
|
||||
glowOffset = glowSize();
|
||||
textHeight += 2 * glowOffset;
|
||||
textWidth += 2 * glowOffset;
|
||||
}
|
||||
|
||||
const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
|
||||
|
@ -802,8 +802,10 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
||||
QPen oldPen = p->pen();
|
||||
p->setPen(QPen(opt->palette.shadow().color(), 0));
|
||||
QRectF rect = opt->rect;
|
||||
rect.adjust(QStyleHelper::dpiScaled(0.5), QStyleHelper::dpiScaled(0.5),
|
||||
QStyleHelper::dpiScaled(-1.5), QStyleHelper::dpiScaled(-1.5));
|
||||
const qreal topLevelAdjustment = QStyleHelper::dpiScaled(0.5);
|
||||
const qreal bottomRightAdjustment = QStyleHelper::dpiScaled(-1.5);
|
||||
rect.adjust(topLevelAdjustment, topLevelAdjustment,
|
||||
bottomRightAdjustment, bottomRightAdjustment);
|
||||
p->drawRect(rect);
|
||||
p->setPen(oldPen);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user