8 qRegisterMetaType<QMessageBox::Icon>();
11 setObjectName(
"Modbus TCP settings");
12 setWindowTitle(objectName());
18 QDialogButtonBox *buttons_box =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
20 connect(buttons_box, &QDialogButtonBox::rejected,
this, &ModbusTCPConfigure::reject);
23 QPushButton *add_handler =
new QPushButton(
"Add handler");
27 QHBoxLayout *handler_op_layout =
new QHBoxLayout;
29 handler_op_layout->addWidget(add_handler);
31 tabs_ =
new QTabWidget;
33 for (
auto &handler : req.handlers)
36 layout_->addLayout(handler_op_layout);
38 layout_->addWidget(buttons_box);
40 if (
tabs_->count() == 0)
54 for (std::size_t i(0); i < (unsigned)
tabs_->count(); ++i)
55 req.handlers.push_back(static_cast<ModbusTCPHandler *>(
tabs_->widget(i))->getHandler());
60 if (
tabs_->count() == 0)
65 if (
tabs_->count() == 0)
74 tabs_->addTab(tab,
"Handler");
80 industrial_modbus_tcp::ModbusHandler h;
82 h.ip_address =
"192.168.100.000";
84 h.modbus_error_recovery_mode = 3;
97 for (std::size_t i(0); i < (unsigned)
tabs_->count(); ++i)
98 static_cast<ModbusTCPHandler *>(
tabs_->widget(i))->getHandler();
100 catch (std::runtime_error &e)
104 QMessageBox::Icon::Warning);
113 for (std::size_t i(0); i < std::size_t(
tabs_->count()); ++i)
114 tabs_->setTabText(i, static_cast<ModbusTCPHandler *>(
tabs_->widget(i))->name());
120 const QMessageBox::Icon icon)
122 const bool old_state(isEnabled());
125 msg_box.setWindowTitle(title);
126 msg_box.setText(text);
127 msg_box.setInformativeText(info);
128 msg_box.setIcon(icon);
129 msg_box.setStandardButtons(QMessageBox::Ok);
131 setEnabled(old_state);