aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-11-24 17:33:47 +0100
committerRichard Moe Gustavsen <richard.gustavsen@qt.io>2020-12-01 10:33:03 +0100
commit86a40625b6a3f2968de1edd454921e0f3385cc45 (patch)
tree2a87546e3ad8f82d17ef93250c8d7f1a5e6ef8b2
parenteed31ce275a6457a9dd409a4a481ff63c461bc0d (diff)
Windows, CT_LineEdit: don't take dpr into account when calculating geometry
The geometry calculated by the style should not take dpr into account. The nativestyle framework (and the scenegraph) understands that all geometry returned by QStyle will need to be scaled according to the dpr. We will for example set a dpr on the QPainter (or the QImage it draws on) before we ask QStyle to draw. This means that the style should not scale the geometry used in the drawing calls to QPainter since QPainter will do this automatically. (cherry picked from commit 3013fce9931913b4f38d4707cb1327be1727a1ef) Task-number: QTBUG-89006 Change-Id: Idfcc6690e0ae0062ca00cb829510d2b68c26ebd4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r--src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp b/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp
index f4defe49..0f07aef0 100644
--- a/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp
+++ b/src/imports/nativestyle/qstyle/windows/qquickwindowsxpstyle.cpp
@@ -3444,15 +3444,17 @@ QSize QWindowsXPStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt
case CT_LineEdit:
case CT_ComboBox:
{
+ if (contentsSize.isEmpty()) {
+ // Minimum size
+ return QSize(20, 20);
+ }
XPThemeData buttontheme(option->window, nullptr, QWindowsXPStylePrivate::ButtonTheme, BP_PUSHBUTTON, PBS_NORMAL);
if (buttontheme.isValid()) {
- const qreal factor = QWindowsXPStylePrivate::nativeMetricScaleFactor(option);
- const QMarginsF borderSize = buttontheme.margins() * factor;
+ const QMarginsF borderSize = buttontheme.margins();
if (!borderSize.isNull()) {
- const qreal margin = qreal(2) * factor;
+ const qreal margin = qreal(2);
sz.rwidth() += qRound(borderSize.left() + borderSize.right() - margin);
- sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin
- + qreal(1) / factor - 1);
+ sz.rheight() += int(borderSize.bottom() + borderSize.top() - margin);
}
const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin, option) + 1);
sz += QSize(qMax(pixelMetric(QStyle::PM_ScrollBarExtent, option)