| 297 | } |
| 298 | |
| 299 | ChatMessagePropertyEdit::ChatMessagePropertyEdit( |
| 300 | QWidget *parent, const ChatMessageProperty &property) |
| 301 | : QWidget(parent), |
| 302 | _boolValue(new QCheckBox(property.GetLocale(), this)), |
| 303 | _textValue(new VariableLineEdit(this)), |
| 304 | _regex(new RegexConfigWidget(this)), |
| 305 | _property(property) |
| 306 | { |
| 307 | installEventFilter(this); |
| 308 | |
| 309 | if (std::holds_alternative<bool>(property._value)) { |
| 310 | const bool value = std::get<bool>(property._value); |
| 311 | _boolValue->setChecked(value); |
| 312 | } else if (std::holds_alternative<StringVariable>(property._value)) { |
| 313 | const auto value = std::get<StringVariable>(property._value); |
| 314 | _textValue->setText(value); |
| 315 | _regex->SetRegexConfig(property._regex); |
| 316 | } |
| 317 | |
| 318 | connect(_boolValue, &QCheckBox::stateChanged, this, [this](int value) { |
| 319 | _property._value = static_cast<bool>(value); |
| 320 | emit PropertyChanged(_property); |
| 321 | }); |
| 322 | connect(_textValue, &VariableLineEdit::editingFinished, this, [this]() { |
| 323 | _property._value = _textValue->text().toStdString(); |
| 324 | emit PropertyChanged(_property); |
| 325 | }); |
| 326 | connect(_regex, &RegexConfigWidget::RegexConfigChanged, this, |
| 327 | [this](const RegexConfig ®ex) { |
| 328 | _property._regex = regex; |
| 329 | emit PropertyChanged(_property); |
| 330 | adjustSize(); |
| 331 | updateGeometry(); |
| 332 | }); |
| 333 | |
| 334 | auto layout = new QHBoxLayout(); |
| 335 | layout->setContentsMargins(0, 0, 0, 0); |
| 336 | layout->addWidget(_boolValue); |
| 337 | layout->addWidget(_textValue); |
| 338 | if (std::holds_alternative<StringVariable>(property._value)) { |
| 339 | layout->insertWidget(0, new QLabel(property.GetLocale())); |
| 340 | layout->addWidget(_regex); |
| 341 | } |
| 342 | setLayout(layout); |
| 343 | |
| 344 | SetVisibility(); |
| 345 | } |
| 346 | |
| 347 | bool ChatMessagePropertyEdit::eventFilter(QObject *obj, QEvent *event) |
| 348 | { |
nothing calls this directly
no test coverage detected