feat: Add badge icon functionality to ToolButton for AI Assistant#759
Merged
deepin-bot[bot] merged 2 commits intoNov 26, 2025
Merged
feat: Add badge icon functionality to ToolButton for AI Assistant#759deepin-bot[bot] merged 2 commits into
deepin-bot[bot] merged 2 commits into
Conversation
- Introduced badge icon support in ToolButton, allowing for visual indicators on AI Assistant buttons. - Updated SubToolWidget to set badge icons for AI Assistant buttons, enhancing user feedback. - Added new AI badge icon to resource file for consistent UI representation. This enhancement improves the visual interaction of the AI Assistant features, providing users with clear indicators of functionality.
lzwind
approved these changes
Nov 26, 2025
- Fix scrollshot/OCR/pin buttons triggering unexpected sidebar display by removing them from QButtonGroup and using direct clicked signal handling - Change signal parameter from "scroll" to "scrollShot" to match MainWindow::changeShotToolEvent condition - Add clicked signal connection for OCR and pin buttons after removing from button group - Add icon highlight color on button press state in ToolButton, matching SaveButton behavior - Disable hover effect for ToolButton when button is disabled (e.g., undo button with no content to undo) - Update ToolButton hover/press background colors according to design spec: - Light mode: hover #000000 10%, press #000000 20% - Dark mode: hover #FFFFFF 10%, press #000000 15% - Adjust SaveButton color logic to prioritize press state over hover state 修复: 优化按钮状态和修复工具栏显示问题 - 修复滚动截图/OCR/贴图按钮触发意外侧边栏显示的问题,将其从QButtonGroup移除并使用直接的clicked信号处理 - 将信号参数从"scroll"改为"scrollShot"以匹配MainWindow::changeShotToolEvent的判断条件 - 为OCR和贴图按钮添加clicked信号连接 - 为ToolButton添加按下状态时图标变为活动色的功能,与SaveButton行为一致 - 禁用状态的ToolButton不显示hover效果(如无可撤销内容时的撤销按钮) - 按照设计规范更新ToolButton的hover/press背景色: - 浅色模式: hover #000000 10%, press #000000 20% - 深色模式: hover #FFFFFF 10%, press #000000 15% - 调整SaveButton颜色逻辑,press状态优先于hover状态
deepin pr auto review我来对这个代码变更进行详细审查:
a) 在toolbutton.h中: // 建议添加常量定义
namespace {
const QSize DEFAULT_BADGE_SIZE = QSize(10, 7);
const int MIN_ICON_SIZE = 16;
}b) 在toolbutton.cpp的setBadgeIcon方法中: void ToolButton::setBadgeIcon(const QString &iconPath)
{
if (QFile::exists(iconPath)) { // 添加文件存在性检查
m_badgeIcon = QIcon(iconPath);
} else {
qWarning() << "Badge icon file not found:" << iconPath;
m_badgeIcon = QIcon();
}
update();
}c) 在paintEvent方法中: // 建议将绘制逻辑抽取为单独的方法
void ToolButton::drawBackground(QPainter &painter, const QStyleOptionToolButton &opt)
{
// 将背景绘制逻辑移到这里
}
void ToolButton::drawIcon(QPainter &painter, const QStyleOptionToolButton &opt)
{
// 将图标绘制逻辑移到这里
}d) 在main_window.cpp中: // 建议添加边界检查
int finalLeft = aiBtnXInMainWindow - (aiPanelWidth / 2);
finalLeft = qBound(0, finalLeft, m_backgroundRect.width() - aiPanelWidth); // 使用qBound替代max/min组合e) 在savebutton.cpp中: // 建议将颜色计算抽取为方法
QColor SaveButton::getThemeColor(qreal alpha) const
{
QColor windowColor = palette().color(QPalette::Window);
bool isLightTheme = windowColor.lightness() > 128;
return isLightTheme ? QColor(0, 0, 0, alpha * 255)
: QColor(255, 255, 255, alpha * 255);
}这些改进将使代码更加健壮、可维护和高效。总体来说,这次变更实现了所需的功能,代码质量良好,但在细节处理上还有优化空间。 |
lzwind
approved these changes
Nov 26, 2025
|
[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 |
Member
Author
|
/forcemerge |
Contributor
|
This pr force merged! (status: unstable) |
778cd73
into
linuxdeepin:develop/snipe
7 of 9 checks passed
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.
feat: Add badge icon functionality to ToolButton for AI Assistant
This enhancement improves the visual interaction of the AI Assistant features, providing users with clear indicators of functionality.
fix: Optimize button states and fix toolbar display issues
修复: 优化按钮状态和修复工具栏显示问题