diff options
author | Wang Peng <wangpeng@uniontech.com> | 2021-08-04 14:06:12 +0800 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-08-17 03:29:12 +0000 |
commit | 6dc9c8991923e9cd0bacf00a05742f0eea574ea5 (patch) | |
tree | 51b5cc27ed032dfc507fe2a36ede3297f8b58307 /src/widgets/styles | |
parent | b781fa79c1146c94f840e2779d9d35bb14eb722e (diff) |
QStyle: allow styles to control the margin around icons in QLineEdit
The styles can't control the margin of the icon container, and its value
is hardcoded to a quarter of the iconSize, which is very unfriendly.
Add a PixelMetric enum value to allow styles to control the margin.
Change-Id: I21274b68d24150db7be78513fe9125f775aa2b00
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 2 |
3 files changed, 7 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index d784315ca7..6f6ddfec44 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4807,6 +4807,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_LineEditIconSize: ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); break; + case PM_LineEditIconMargin: + ret = proxy()->pixelMetric(PM_LineEditIconSize, opt, widget) / 4; + break; case PM_LargeIconSize: ret = int(QStyleHelper::dpiScaled(32, opt)); diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 368eda3396..f26f1a16c8 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1519,6 +1519,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_LineEditIconSize The default size for icons in a line edit. This enum value has been introduced in Qt 6.2. + \value PM_LineEditIconMargin The margin around icons in a line edit. + This enum value has been introduced in Qt 6.3. + \value PM_CustomBase Base value for custom pixel metrics. Custom values must be greater than this value. diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index fc94ed2bf5..6d094cc4f2 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -568,7 +568,7 @@ public: PM_TitleBarButtonSize, PM_LineEditIconSize, - + PM_LineEditIconMargin, // do not add any values below/greater than this PM_CustomBase = 0xf0000000 }; |