fix: clamp Treeland brightness at 10 percent - #115
Conversation
1. Centralize the brightness step and [10, 100] bounds 2. Apply the shared policy to Treeland brightness changes 3. Add QtTest coverage for lower and upper boundaries Influence: 1. Prevent brightness-down from producing values below Treeland's supported minimum 2. Preserve 5-point increments and the 100 percent upper bound 3. Verify the policy with unit tests and debug-machine runtime validation fix: 将 Treeland 亮度下限限制为 10% 1. 统一亮度步长及 [10, 100] 边界 2. 在 Treeland 亮度调整中使用统一策略 3. 增加亮度上下限 QtTest 覆盖 Influence: 1. 防止亮度降低快捷键产生低于 Treeland 支持下限的值 2. 保持 5% 步进和 100% 上限 3. 已通过单测及调试机运行时验证 PMS: BUG-371285
Reviewer's GuideCentralizes brightness step and [10, 100] bounds into a shared Brightness policy utility, updates the Treeland brightness controller to use it, and adds QtTest coverage plus CMake wiring for the new brightness policy tests. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 当前代码已足够优秀,无需进一步修改。
// 若未来需要支持动态步长或边界,可考虑扩展 adjustedValue 的参数,例如:
/*
namespace Brightness {
constexpr double Step = 5.0;
constexpr double Minimum = 10.0;
constexpr double Maximum = 100.0;
inline double adjustedValue(double current, bool raised, double step = Step, double min = Minimum, double max = Maximum)
{
const double value = current + (raised ? step : -step);
if (value < min) {
return min;
}
if (value > max) {
return max;
}
return value;
}
} // namespace Brightness
*/ |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Consider marking
Brightness::adjustedValueasconstexprsince it only performs arithmetic and comparisons, which would better express its pure, compile-time-friendly nature and keep it consistent with the otherBrightnessconstants. - In
tst_brightnesspolicy.cpp, usingBrightness::MinimumandBrightness::Maximuminstead of hardcoded10.0and100.0would avoid magic numbers and keep the tests aligned with future changes to the brightness policy.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider marking `Brightness::adjustedValue` as `constexpr` since it only performs arithmetic and comparisons, which would better express its pure, compile-time-friendly nature and keep it consistent with the other `Brightness` constants.
- In `tst_brightnesspolicy.cpp`, using `Brightness::Minimum` and `Brightness::Maximum` instead of hardcoded `10.0` and `100.0` would avoid magic numbers and keep the tests aligned with future changes to the brightness policy.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, robertkill 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) |
fix: clamp Treeland brightness at 10 percent
Influence:
fix: 将 Treeland 亮度下限限制为 10%
Influence:
PMS: BUG-371285
Summary by Sourcery
Enforce a shared brightness policy with clamped bounds and apply it to Treeland brightness control.
Bug Fixes:
Enhancements:
Tests: