fix(shapeswidget): improve text shape handling and logging#835
Merged
deepin-bot[bot] merged 1 commit intoMay 7, 2026
Merged
Conversation
- Clear selection state when switching to text shape to ensure immediate text input on first click. - Enhance logging in mouse press events for better debugging of shape interactions and text editing states. This update addresses user experience issues related to shape selection and text input, ensuring a smoother workflow when using the text tool. bug: https://pms.uniontech.com/bug-view-359843.html
0b7a94b to
4397bd3
Compare
deepin pr auto review这段。这是一个很好的重构,将特定于文本工具切换的逻辑封装到了单独的函数中。让我提供一些改进建议: 代码审查意见1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
改进建议// shapeswidget.h
class ShapesWidget : public QWidget {
Q_OBJECT
// ... 其他代码 ...
private:
/**
* @brief 重置状态以切换到文本工具
*
* 当切换到文本工具时,清除所有选中状态并重置相关标志位,
* 确保首次点击即可进入文本输入模式。
*/
void resetForTextToolSwitch();
// 建议使用常量代替硬编码字符串
static const QString TEXT_TOOL_TYPE;
// ... 其他代码 ...
};
// shapeswidget.cpp
const QString ShapesWidget::TEXT_TOOL_TYPE = "text";
void ShapesWidget::setCurrentShape(QString shapeType)
{
qDebug() << __FUNCTION__ << __LINE__ << "type: " << shapeType;
m_currentType = shapeType;
if (shapeType == TEXT_TOOL_TYPE) {
resetForTextToolSwitch();
} else {
setAllTextEditReadOnly();
}
}
void ShapesWidget::resetForTextToolSwitch()
{
// 切换到 text 时仍保留上一个图形的选中态,
// 导致第一次点击先"清选中",第二次点击才进入文本创建。
// 这里在工具切换时清理选中态,保证首次点击直接进入文本输入。
clearSelected();
// 重置所有状态标志
m_isRotated = false;
m_isResize = false;
m_clickedKey = Unknown; // 修正拼写错误
}其他建议
enum class ToolType {
Text,
Rectangle,
Circle,
// ... 其他工具类型
};
void ShapesWidget::setCurrentShape(ToolType toolType)
{
m_currentType = toolType;
if (toolType == ToolType::Text) {
resetForTextToolSwitch();
} else {
setAllTextEditReadOnly();
}
}
void ShapesWidget::resetForTextToolSwitch()
{
if (m_selectedItem) { // 假设 m_selectedItem 是选中的图形
clearSelected();
}
// ... 其他代码 ...
}
总体来说,这是一个很好的重构,提高了代码的可读性和可维护性。 |
lzwind
approved these changes
May 6, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dengzhongyuan365-dev, lzwind 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 |
Contributor
Author
|
/forcemerge |
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.
This update addresses user experience issues related to shape selection and text input, ensuring a smoother workflow when using the text tool.
bug: https://pms.uniontech.com/bug-view-359843.html