From 03a509717531af5491087e2959a87def4311e0e6 Mon Sep 17 00:00:00 2001 From: gongheng Date: Tue, 14 Jul 2026 20:18:43 +0800 Subject: [PATCH] fix(partition): add tolerance to add button enable condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 修复后用户输入等于剩余空间时添加按钮可正常启用,提升分区创建交互体验。 --- application/widgets/customcontrol/partitionwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/widgets/customcontrol/partitionwidget.cpp b/application/widgets/customcontrol/partitionwidget.cpp index 94df306c..f465c24a 100644 --- a/application/widgets/customcontrol/partitionwidget.cpp +++ b/application/widgets/customcontrol/partitionwidget.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2022 - 2026 UnionTech Software Technology Co., Ltd. // // SPDX-License-Identifier: GPL-3.0-only @@ -13,6 +13,8 @@ #include #include +constexpr double kFloatCompareEpsilon = 0.01; + PartitionWidget::PartitionWidget(QWidget *parent) : DDialog(parent) { @@ -930,7 +932,7 @@ void PartitionWidget::onSetSliderValue() m_block = 1; m_slider->setValue(static_cast((value / (m_total - (sumValue() / 1024))) * 100)); m_currentEditSize = QString::number(value * 1024, 'f', 4); - if (value == 0.00 || value > (m_total - sumValue() / 1024)) { + if (value == 0.00 || value > (m_total - sumValue() / 1024) + kFloatCompareEpsilon) { qDebug() << "Value is 0 or exceeds remaining space, disabling addButton"; m_addButton->setEnabled(false); } else {