From bfb9943b347d7065b3b57e88021a73f64e18ab13 Mon Sep 17 00:00:00 2001 From: suyu <1643689728@qq.com> Date: Fri, 21 Aug 2026 10:56:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=99=90=E5=88=B6HMI=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=96=87=E6=9C=AC=E9=95=BF=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/domain/project_limits.h | 1 + app/src/ui/property_panel_controller.cpp | 7 +++---- app/tests/main_window_tests.cpp | 4 ++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/domain/project_limits.h b/app/src/domain/project_limits.h index 2a9885b..b9f4d15 100644 --- a/app/src/domain/project_limits.h +++ b/app/src/domain/project_limits.h @@ -25,6 +25,7 @@ static_assert(kMaximumLadderColumns == kMaximumConditionColumns + 1); constexpr std::size_t kMaximumHmiProperties = 64U; constexpr std::size_t kMaximumIdBytes = 128U; constexpr std::size_t kMaximumTextBytes = 4096U; +constexpr std::size_t kMaximumHmiControlTextCharacters = 12U; constexpr std::size_t kMaximumAlarmTitleCharacters = 12U; constexpr std::size_t kMaximumAlarmMessageCharacters = 20U; constexpr std::size_t kMaximumPropertyKeyBytes = 128U; diff --git a/app/src/ui/property_panel_controller.cpp b/app/src/ui/property_panel_controller.cpp index 8081622..18f005b 100644 --- a/app/src/ui/property_panel_controller.cpp +++ b/app/src/ui/property_panel_controller.cpp @@ -195,7 +195,8 @@ void PropertyPanelController::showControlProperties(const std::string &control_i if (!has_control) { - ui_.controlTextEdit->setMaxLength(32767); + ui_.controlTextEdit->setMaxLength( + static_cast(ProjectLimits::kMaximumHmiControlTextCharacters)); ui_.bindingAreaLabel->setVisible(false); ui_.bindingAreaComboBox->setVisible(false); ui_.bindingIndexLabel->setVisible(false); @@ -223,9 +224,7 @@ void PropertyPanelController::showControlProperties(const std::string &control_i } ui_.controlTextEdit->setMaxLength( - control->type == HmiControlType::AlarmList - ? static_cast(ProjectLimits::kMaximumAlarmTitleCharacters) - : 32767); + static_cast(ProjectLimits::kMaximumHmiControlTextCharacters)); ui_.controlIdEdit->setText(fromUtf8(control->id)); ui_.controlTextEdit->setText(fromUtf8(control->text)); ui_.controlXSpinBox->setValue(control->bounds.x); diff --git a/app/tests/main_window_tests.cpp b/app/tests/main_window_tests.cpp index 3f9e85d..f921e5a 100644 --- a/app/tests/main_window_tests.cpp +++ b/app/tests/main_window_tests.cpp @@ -1163,6 +1163,10 @@ void testModeActionsControlEditingAvailability() "an unbound added control must be marked in the property panel"); require(text_edit->text() == QStringLiteral("按钮"), "property panel must show the control text"); + require(text_edit->maxLength() + == static_cast( + ProjectLimits::kMaximumHmiControlTextCharacters), + "all HMI control text inputs must be limited to twelve characters"); require(button_operation->currentText() == QStringLiteral("瞬时 ON"), "new HMI buttons must default to momentary ON");