diff options
author | Tang Haixiang <tanghaixiang@uniontech.com> | 2021-03-08 19:49:44 +0800 |
---|---|---|
committer | Tang Haixiang <tanghaixiang@uniontech.com> | 2021-03-12 08:39:04 +0800 |
commit | 24226bb5f595581a239356c18a338783a85349ca (patch) | |
tree | 1f27498d130fc69f8c98c0a911259bbb9c4d824c | |
parent | 674747bac1c8b57d4940de2ee68b6b562dfcad61 (diff) |
Add setting the ICON size attribute in lineedit to the style plugin
When the font is large enough, using PM_SmallIconSize will get a large
lineedit,but the icon is very small. This is very unsightly, and the
style plug-in hopes to be able to define the size of the icon by itself.
Change-Id: I0e35b331301472541d3378e748dbcd074d5419a2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qfusionstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.cpp | 3 | ||||
-rw-r--r-- | src/widgets/styles/qstyle.h | 2 | ||||
-rw-r--r-- | src/widgets/widgets/qlineedit_p.cpp | 2 |
5 files changed, 12 insertions, 1 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index a2f52562c8..358edc230b 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -4828,6 +4828,9 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWid case PM_IconViewIconSize: ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); break; + case PM_LineEditIconSize: + ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); + break; case PM_LargeIconSize: ret = int(QStyleHelper::dpiScaled(32, opt)); diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 5772c7d4c4..51cd5109a0 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -3045,6 +3045,9 @@ int QFusionStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, co case PM_ListViewIconSize: val = 24; break; + case PM_LineEditIconSize: + val = 24; + break; case PM_DialogButtonsSeparator: case PM_ScrollBarSliderMin: val = 26; diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp index 8aa423c224..9c4e66b0ba 100644 --- a/src/widgets/styles/qstyle.cpp +++ b/src/widgets/styles/qstyle.cpp @@ -1516,6 +1516,9 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, \value PM_TitleBarButtonSize The size of buttons on a title bar. This enum value has been introduced in Qt 5.8. + \value PM_LineEditIconSize The default size for icons in a line edit. + This enum value has been introduced in Qt 6.2. + \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 ba64a6b1bf..c3c99d9974 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -567,6 +567,8 @@ public: PM_TitleBarButtonIconSize, PM_TitleBarButtonSize, + PM_LineEditIconSize, + // do not add any values below/greater than this PM_CustomBase = 0xf0000000 }; diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 4143b848b5..7526379f3c 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -495,7 +495,7 @@ QLineEditPrivate::SideWidgetParameters QLineEditPrivate::sideWidgetParameters() { Q_Q(const QLineEdit); SideWidgetParameters result; - result.iconSize = q->style()->pixelMetric(QStyle::PM_SmallIconSize, nullptr, q); + result.iconSize = q->style()->pixelMetric(QStyle::PM_LineEditIconSize, nullptr, q); result.margin = result.iconSize / 4; result.widgetWidth = result.iconSize + 6; result.widgetHeight = result.iconSize + 2; |