sync: from linuxdeepin/dde-session-shell - #525
Conversation
Synchronize source files from linuxdeepin/dde-session-shell. Source-pull-request: linuxdeepin/dde-session-shell#76
There was a problem hiding this comment.
Sorry @deepin-ci-robot, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: deepin-ci-robot 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 text rendering so elision and drawing respect the embedded QLineEdit’s text margins and widget offset, preventing long placeholders from overlapping icons. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已为最佳实践,无需额外修改,此处展示完整上下文以供参考
void DLineEditEx::paintEvent(QPaintEvent *event)
{
// ... 前置条件判断(当 lineEdit 无文本且未获得焦点时) ...
QPainter pa(this);
pa.setFont(lineEdit()->font());
pa.setPen(pa.pen().color());
QFontMetrics fm(pa.font());
const QString &placeholderText = lineEdit()->placeholderText();
// 将 placeholder 的省略与绘制约束到扣除内嵌 QLineEdit 的 textMargins()
// 后的文本可用矩形内,避免长 placeholder 与左右功能图标重叠。
// DLineEditEx(QFrame) 与内嵌 QLineEdit 存在父子控件偏移,需用 mapTo
// 将 QLineEdit 坐标系映射到 DLineEditEx 绘制坐标系。
QLineEdit *le = lineEdit();
const QMargins tm = le->textMargins();
const QRect lineEditRect(le->mapTo(this, QPoint(0, 0)), le->size());
const QRect textRect = lineEditRect.adjusted(tm.left(), tm.top(), -tm.right(), -tm.bottom());
QString elidedText = fm.elidedText(placeholderText, Qt::ElideRight, textRect.width());
pa.drawText(textRect, Qt::AlignCenter | Qt::TextSingleLine, elidedText);
// 当文本被省略时,设置 tooltip 显示完整文本
if (elidedText != placeholderText) {
this->setToolTip(placeholderText);
} else {
this->setToolTip("");
}
// ...
} |
Synchronize source files from linuxdeepin/dde-session-shell.
Source-pull-request: linuxdeepin/dde-session-shell#76
Summary by Sourcery
Bug Fixes: