fix: keep placeholder within text margins (DLineEditEx) - #76
Draft
mhduiy wants to merge 1 commit into
Draft
Conversation
1. Elide and draw placeholder within QLineEdit rect minus textMargins 2. Map QLineEdit to DLineEditEx via le->mapTo(this, QPoint(0,0)) 3. Fixes overlap with caps-lock, password and hint icons on lock/login Log: Fixed password prompt overlapping icons on lock and login screens Influence: 1. Lock/login: long password hint elided, not overlapping the icons 2. caps-lock/show-password/hint icons stay clear of placeholder 3. Regression: short Chinese placeholder centered, no anomaly 4. Shared DLineEditEx inputs (account/single/ukey) show placeholder ok fix: 将占位符约束在文本边距内 1. 将 DLineEditEx::paintEvent() 中占位符的省略与绘制约束到扣除内嵌 QLineEdit 的 textMargins() 后的文本可用矩形内,不再使用整框 rect() 2. 通过 le->mapTo(this, QPoint(0,0)) 将内嵌 QLineEdit 坐标映射到 DLineEditEx 绘制坐标系,避免父子控件坐标换算导致省略宽度偏差 3. 修复锁屏/登录界面长错误或提示占位符与大写、显示密码、密码提示 图标重叠的问题 Log: 修复锁屏/登录界面密码提示文案省略后仍与图标重叠的问题 Influence: 1. 锁屏/登录界面:英文 locale 或调大字号/缩放下,设较长密码提示, 输错密码后清空密码框,确认占位符省略后止于左右图标内侧、不再重叠 2. 确认大写、显示密码、密码提示图标与占位符区域保持独立 3. 回归:中文短文案占位符居中显示正常、无视觉异常 4. 共用 DLineEditEx 的账号/单因子/ukey 输入框占位符显示正常 PMS: BUG-351887
|
Skipping CI for Draft Pull Request. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts DLineEditEx placeholder rendering so that elided placeholder text is constrained to the inner QLineEdit’s text area, preventing overlap with left/right icons, while keeping existing tooltip behavior intact. Sequence diagram for updated placeholder painting in DLineEditEx::paintEventsequenceDiagram
participant DLineEditEx
participant QLineEdit as lineEdit
participant QPainter as pa
participant QFontMetrics as fm
DLineEditEx->>QPainter: QPainter(this)
DLineEditEx->>QFontMetrics: QFontMetrics(pa.font())
DLineEditEx->>QLineEdit: lineEdit()
DLineEditEx->>QLineEdit: placeholderText()
QLineEdit-->>DLineEditEx: placeholderText
DLineEditEx->>QLineEdit: textMargins()
QLineEdit-->>DLineEditEx: tm
DLineEditEx->>QLineEdit: mapTo(this, QPoint(0,0))
QLineEdit-->>DLineEditEx: topLeftInParent
DLineEditEx->>DLineEditEx: build lineEditRect(topLeftInParent, le->size())
DLineEditEx->>DLineEditEx: build textRect(lineEditRect.adjusted(tm.left(), tm.top(), -tm.right(), -tm.bottom()))
DLineEditEx->>QFontMetrics: elidedText(placeholderText, Qt::ElideRight, textRect.width())
QFontMetrics-->>DLineEditEx: elidedText
DLineEditEx->>QPainter: drawText(textRect, Qt::AlignCenter | Qt::TextSingleLine, elidedText)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
修复:锁屏/登录密码框占位符省略后与功能图标重叠
问题
锁屏/登录界面在「焦点态 + 空文本 + 居中 placeholder」分支手动重绘 placeholder 时,省略与绘制使用的是
DLineEditEx整框rect()宽度,未扣除内嵌QLineEdit的textMargins()(即大写、显示密码、认证状态、密码提示等图标的避让区),导致长错误/提示文案省略后仍横跨整框、与左右功能图标重叠。改动
dde-session-shellsrc/widgets/dlineeditex.cpp—DLineEditEx::paintEvent()elidedText宽度参数)与绘制(drawText目标矩形)从整框rect()约束到「扣除内嵌QLineEdit的textMargins()后的文本可用矩形」内le->mapTo(this, QPoint(0,0))将内嵌QLineEdit(子控件)坐标映射到DLineEditEx(QFrame,QPainter(this)绘制坐标系),避免父子控件坐标换算导致省略宽度偏差deepin-authenticate/ DTK 控件 / DConfig / 翻译 / QSS验证
g++ -std=c++17 -fsyntax-only(Qt6 / dtk6widget 头文件路径)通过,仅余一处与本次改动无关的既有QGuiApplication::fontChanged弃用告警textMargins读取时机、未设textMargins场景回归、Qt6 路径)dde-session-shell_5.6.12.1_amd64.deb已产出关联
说明
本次 PR 仅含业务修复
src/widgets/dlineeditex.cpp;打包适配改动(debian/*)为本地构建所需,未纳入本 PR。PR 保持 draft/待审核状态,请勿合并。Summary by Sourcery
Bug Fixes: