Skip to content

Commit f2a102c

Browse files
committed
feat: add support for custom line edit icon margin
Added PM_LineEditIconMargin pixel metric handling to support custom icon margins in line edit widgets. The implementation checks for a "_d_dtk_lineeditIconMargin" property on the widget and returns the custom margin value if valid. This allows applications to specify precise icon spacing in line edit fields for better UI customization and visual consistency. Influence: 1. Test line edit widgets with custom icon margin property set 2. Verify default behavior when no custom margin is specified 3. Test with various valid margin values (positive integers) 4. Verify behavior with invalid margin values (negative numbers, invalid types) 5. Check UI layout consistency with custom icon margins applied feat: 添加支持自定义行编辑图标边距 添加了 PM_LineEditIconMargin 像素度量处理,以支持在行编辑部件中自定义图 标边距。该实现检查部件上的 "_d_dtk_lineeditIconMargin" 属性,如果有效则 返回自定义边距值。这允许应用程序为行编辑字段指定精确的图标间距,以实现更 好的 UI 定制和视觉一致性。 Influence: 1. 测试设置了自定义图标边距属性的行编辑部件 2. 验证未指定自定义边距时的默认行为 3. 使用各种有效边距值(正整数)进行测试 4. 验证无效边距值(负数、无效类型)时的行为 5. 检查应用自定义图标边距后的 UI 布局一致性 PMS: BUG-334965
1 parent 04913bf commit f2a102c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/widgets/dstyle.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,6 +2255,19 @@ int DStyle::pixelMetric(QStyle::PixelMetric m, const QStyleOption *opt, const QW
22552255
return 16;
22562256
case PM_MenuButtonIndicator:
22572257
return DSizeModeHelper::element(8, QCommonStyle::pixelMetric(m, opt, widget));
2258+
// since Qt 6.3 or applied patch Add-setting-thc-ICON-size-attribute-in-lineedit-to-the-style-plugin.patch( uos or deepin).
2259+
case PM_LineEditIconMargin: {
2260+
if (widget) {
2261+
const QVariant &margin_value = widget->property("_d_dtk_lineeditIconMargin");
2262+
if (margin_value.isValid()) {
2263+
bool ok = false;
2264+
int margin = margin_value.toInt(&ok);
2265+
if (ok && margin >= 0) {
2266+
return margin;
2267+
}
2268+
}
2269+
}
2270+
}
22582271
case PM_FloatingButtonFrameMargin:
22592272
return 3;
22602273
default:

0 commit comments

Comments
 (0)