-
Notifications
You must be signed in to change notification settings - Fork 60
fix: return mute icon for silent audio #1429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts AudioApplet volume icon selection so that silent or near-silent audio correctly uses the mute icon and non-zero volumes map to the appropriate volume levels. Flow diagram for AudioApplet volume icon selection logicgraph TD
A["Start: fetchIconName"] --> B["Read m_volumeValue into volume"]
B --> C{Is volume > 0?}
C -- "No" --> D["Set level to mute"]
C -- "Yes" --> E{Is volume <= 0.33?}
E -- "Yes" --> F["Set level to 33"]
E -- "No" --> G{Is volume <= 0.66?}
G -- "Yes" --> H["Set level to 66"]
G -- "No" --> I["Set level to 100"]
D --> J["Return icon name based on level"]
F --> J
H --> J
I --> J
J --> K["End: icon rendered in OSD"]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - I've left some high level feedback:
- Consider making the mute case explicit (e.g.,
if (volume <= 0.0) level = "mute";) rather than relying on the default initialization, which will improve readability and reduce the chance of regressions if the logic is reordered later. - Double-check that
"mute"is a valid level string for all icon name compositions that uselevel(e.g.,osd_volume_<level>); if some paths assume numeric levels, it might be safer to special-case the mute icon name instead of changing the default level.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider making the mute case explicit (e.g., `if (volume <= 0.0) level = "mute";`) rather than relying on the default initialization, which will improve readability and reduce the chance of regressions if the logic is reordered later.
- Double-check that `"mute"` is a valid level string for all icon name compositions that use `level` (e.g., `osd_volume_<level>`); if some paths assume numeric levels, it might be safer to special-case the mute icon name instead of changing the default level.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, qxp930712 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 |
Updated the logic in the AudioApplet to correctly identify and
display the mute icon when the volume level is less than or
equal to 1.
Previously, the code failed to explicitly handle the state where
volume was 0 or very low, potentially resulting in incorrect
icon rendering or undefined behavior. The change adds an else
block to return "osd_volume_mute" in these cases, ensuring
accurate UI feedback for users.
Log: Fixed the audio OSD mute icon display for silent state
Influence:
1. Test volume at 0% to ensure the mute icon is displayed
2. Test volume between 1% and 66% to ensure the low/mid volume icon
is displayed
3. Test volume above 66% to ensure the high volume icon is displayed
4. Verify icon switching behavior when sliding the volume slider
pms: BUG-349767
|
/forcemerge |
|
This pr force merged! (status: blocked) |
deepin pr auto review这段代码的修改将音量图标的默认状态从字符串 1. 语法逻辑
2. 代码质量
3. 代码性能
4. 代码安全
5. 综合改进代码示例基于以上分析,建议重构代码如下: // 建议在类定义中或匿名命名空间中定义常量
namespace {
const QString kLevelMute = "mute";
const QString kLevelLow = "33";
const QString kLevelMid = "66";
const QString kLevelHigh = "100";
const double kLowThreshold = 0.33;
const double kHighThreshold = 0.66;
}
QString AudioApplet::fetchIconName() const
{
// 确保音量值在合法范围内,防止越界
const double volume = qBound(0.0, m_volumeValue, 1.0);
QString level;
if (volume <= 0.0) {
level = kLevelMute;
} else if (volume <= kLowThreshold) {
level = kLevelLow;
} else if (volume <= kHighThreshold) {
level = kLevelMid;
} else {
level = kLevelHigh;
}
// ... 后续拼接图标名称的逻辑
}总结原代码修改将默认状态改为 |
Updated the logic in the AudioApplet to correctly identify and
display the mute icon when the volume level is less than or
equal to 1.
Summary by Sourcery
Bug Fixes: