Repository navigation
fix: limit watermark text input length - #788
Conversation
1. Add setMaxLength(16) to the watermark text input field in the print preview dialog 2. Prevent users from entering excessively long custom watermark text that could cause rendering issues 3. Ensure watermark text remains readable and fits properly on printed pages Log: Limited watermark custom text input to 16 characters maximum Influence: 1. Verify watermark text input accepts up to 16 characters 2. Confirm input is blocked when reaching the 16 character limit 3. Test that existing watermark text longer than 16 characters displays correctly 4. Verify watermark rendering on print preview with maximum length text 5. Test copy-paste behavior with text exceeding the limit fix: 限制水印文本输入长度 1. 在打印预览对话框的水印文本输入框中添加 setMaxLength(16) 2. 防止用户输入过长的自定义水印文本导致渲染问题 3. 确保水印文本保持可读性并正确适配打印页面 Log: 限制水印自定义文本输入最多16个字符 Influence: 1. 验证水印文本输入框最多接受16个字符 2. 确认达到16个字符限制时输入被阻止 3. 测试超过16个字符的现有水印文本是否正确显示 4. 验证最大长度文本在打印预览中的水印渲染效果 5. 测试超出限制的文本复制粘贴行为 PMS: BUG-378143
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe print preview dialog now limits custom watermark text to 16 characters by configuring the underlying line edit, preventing overlong user input while leaving watermark rendering and existing UI behavior otherwise unchanged. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/widgets/dprintpreviewdialog.cpp" line_range="857" />
<code_context>
waterTextEdit->setObjectName(_d_printSettingNameMap[DPrintPreviewSettingInterface::SC_Watermark_CustomText]);
settingHelper->setSubControlEnabled(DPrintPreviewSettingInterface::SC_Watermark_CustomText, false);
waterTextEdit->lineEdit()->setPlaceholderText(qApp->translate("DPrintPreviewDialogPrivate", "Input your text"));
+ waterTextEdit->lineEdit()->setMaxLength(16);
hlayout2->addStretch(5);
hlayout2->addWidget(waterTextEdit, 10);
</code_context>
<issue_to_address>
**issue (bug_risk):** Setting the QLineEdit maximum before watermark settings are restored causes any existing `customText` longer than 16 characters to be silently truncated by subsequent `setText()` calls, so the preview and returned print settings no longer preserve the caller's watermark text.
**Triggers:** When an application restores or supplies a watermark whose custom text exceeds 16 characters.
**Suggested fix:** Apply the 16-character restriction only to user-edited input, while preserving and rendering programmatically supplied existing text, or explicitly handle long restored values without silently truncating them.
</issue_to_address>| waterTextEdit->setObjectName(_d_printSettingNameMap[DPrintPreviewSettingInterface::SC_Watermark_CustomText]); | ||
| settingHelper->setSubControlEnabled(DPrintPreviewSettingInterface::SC_Watermark_CustomText, false); | ||
| waterTextEdit->lineEdit()->setPlaceholderText(qApp->translate("DPrintPreviewDialogPrivate", "Input your text")); | ||
| waterTextEdit->lineEdit()->setMaxLength(16); |
There was a problem hiding this comment.
issue (bug_risk): Setting the QLineEdit maximum before watermark settings are restored causes any existing customText longer than 16 characters to be silently truncated by subsequent setText() calls, so the preview and returned print settings no longer preserve the caller's watermark text.
Triggers: When an application restores or supplies a watermark whose custom text exceeds 16 characters.
Suggested fix: Apply the 16-character restriction only to user-edited input, while preserving and rendering programmatically supplied existing text, or explicitly handle long restored values without silently truncating them.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: ['建议将魔法数字16定义为命名常量,例如:static const int kMaxWatermarkTextLength = 16; 然后使用 waterTextEdit->lineEdit()->setMaxLength(kMaxWatermarkTextLength);'] 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 建议将魔法数字定义为命名常量
static const int kMaxWatermarkTextLength = 16;
// 在 initWaterMarkui() 函数中使用
waterTextEdit->lineEdit()->setMaxLength(kMaxWatermarkTextLength);本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, wjyrich 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 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Log: Limited watermark custom text input to 16 characters maximum
Influence:
fix: 限制水印文本输入长度
Log: 限制水印自定义文本输入最多16个字符
Influence:
PMS: BUG-378143
Summary by Sourcery
Bug Fixes: