diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-05 12:51:10 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-04-08 18:42:30 +0000 |
commit | 6accc102d3300986fcfa7417d3371f6556f8361a (patch) | |
tree | dcf152d729b80b490cc69a0448700b3b36e3c15a /src/widgets | |
parent | 58b4e0736919e0504f5ca5307ad7aefa894a6f38 (diff) |
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>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/dialogs/qwizard.cpp | 10 | ||||
-rw-r--r-- | src/widgets/dialogs/qwizard_win.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 6 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index c692a0f8db..f428114bbe 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -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) diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 4986bbc75f..95f8f6a878 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -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 diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index 4e450813cb..7b5da9bfa8 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -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; |