fix(partition): add tolerance to add button enable condition#209
fix(partition): add tolerance to add button enable condition#209GongHeng2017 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Sorry @GongHeng2017, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017 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 |
69a439b to
5809a1c
Compare
Add floating-point tolerance when comparing input value with remaining space to prevent disabling the add button due to precision error. 比较输入值与剩余空间时增加浮点容差,避免因精度误差错误禁用添加按钮。 Log: 修复添加按钮在边界值被错误禁用 PMS: BUG-364667 Influence: 修复后用户输入等于剩余空间时添加按钮可正常启用,提升分区创建交互体验。
5809a1c to
db2cf45
Compare
deepin pr auto review★ 总体评分:95分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // 定义浮点数比较容差常量,单位:MB
static constexpr double kPartitionSizeToleranceMB = 0.01;
void PartitionWidget::onSetSliderValue()
{
m_block = 1;
m_slider->setValue(static_cast<int>((value / (m_total - (sumValue() / 1024))) * 100));
m_currentEditSize = QString::number(value * 1024, 'f', 4);
// 使用容差解决浮点数精度丢失问题,避免在最大可用空间边界误判
if (value < kPartitionSizeToleranceMB || value > (m_total - sumValue() / 1024) + kPartitionSizeToleranceMB) {
m_addButton->setEnabled(false);
} else {
m_addButton->setEnabled(true);
}
} |
Add floating-point tolerance when comparing input value with remaining space to prevent disabling the add button due to precision error.
比较输入值与剩余空间时增加浮点容差,避免因精度误差错误禁用添加按钮。
Log: 修复添加按钮在边界值被错误禁用
PMS: BUG-364667
Influence: 修复后用户输入等于剩余空间时添加按钮可正常启用,提升分区创建交互体验。