MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / ChatMessagePropertyEdit

Method ChatMessagePropertyEdit

plugins/twitch/chat-message-pattern.cpp:299–345  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299ChatMessagePropertyEdit::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 &regex) {
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
347bool ChatMessagePropertyEdit::eventFilter(QObject *obj, QEvent *event)
348{

Callers

nothing calls this directly

Calls 4

setCheckedMethod · 0.80
setTextMethod · 0.80
SetRegexConfigMethod · 0.80
GetLocaleMethod · 0.45

Tested by

no test coverage detected