Browse Source

fix: 限制HMI控件属性文本长度

main
suyu 4 weeks ago
parent
commit
bfb9943b34
3 changed files with 8 additions and 4 deletions
  1. +1
    -0
      app/src/domain/project_limits.h
  2. +3
    -4
      app/src/ui/property_panel_controller.cpp
  3. +4
    -0
      app/tests/main_window_tests.cpp

+ 1
- 0
app/src/domain/project_limits.h View File

@@ -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;


+ 3
- 4
app/src/ui/property_panel_controller.cpp View File

@@ -195,7 +195,8 @@ void PropertyPanelController::showControlProperties(const std::string &control_i

if (!has_control)
{
ui_.controlTextEdit->setMaxLength(32767);
ui_.controlTextEdit->setMaxLength(
static_cast<int>(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<int>(ProjectLimits::kMaximumAlarmTitleCharacters)
: 32767);
static_cast<int>(ProjectLimits::kMaximumHmiControlTextCharacters));
ui_.controlIdEdit->setText(fromUtf8(control->id));
ui_.controlTextEdit->setText(fromUtf8(control->text));
ui_.controlXSpinBox->setValue(control->bounds.x);


+ 4
- 0
app/tests/main_window_tests.cpp View File

@@ -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<int>(
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");



Loading…
Cancel
Save