2 #include <Device/Protocol/ProtocolSettingsWidget.hpp>
4 #include <ossia/network/sockets/configuration.hpp>
19 auto layout =
new QFormLayout{
this};
20 layout->setContentsMargins(0, 0, 0, 0);
22 m_remotePort =
new QSpinBox(
this);
23 m_remotePort->setRange(0, 65535);
24 m_remotePort->setValue(9996);
25 m_remotePort->setWhatsThis(
26 tr(
"This is where the other software listens from incoming messages. Score will "
27 "send packets to this port."));
28 proto.checkForChanges(m_remotePort);
30 m_localPort =
new QSpinBox(
this);
31 m_localPort->setRange(0, 65535);
32 m_localPort->setValue(9997);
33 m_localPort->setWhatsThis(
34 tr(
"This is where the other software sends feedback messages to. Score will "
35 "listen for incoming OSC messages on this port."));
36 proto.checkForChanges(m_localPort);
38 m_broadcast =
new QCheckBox{
this};
39 m_broadcast->setCheckState(Qt::Unchecked);
40 m_broadcast->setWhatsThis(tr(
"Broadcast to every device in the IP broadcast range"));
41 connect(m_broadcast, &QCheckBox::stateChanged,
this, [
this](
int checked) {
42 m_host->setEnabled(!checked);
45 m_host =
new QLineEdit(
this);
46 m_host->setText(
"127.0.0.1");
48 tr(
"This is the IP address of the computer the OSC-compatible software is "
49 "located on. You can use 127.0.0.1 if the software runs on the same machine "
52 layout->addRow(tr(
"Device listening port"), m_remotePort);
53 layout->addRow(tr(
"Broadcast"), m_broadcast);
54 layout->addRow(tr(
"Device host"), m_host);
55 layout->addRow(tr(
"score listening port"), m_localPort);
58 ossia::net::udp_configuration settings()
const noexcept
60 ossia::net::udp_configuration conf;
61 conf.local = ossia::net::inbound_socket_configuration{
62 "0.0.0.0", (uint16_t)m_localPort->value()};
63 conf.remote = ossia::net::outbound_socket_configuration{
64 m_host->text().toStdString(), (uint16_t)m_remotePort->value(),
65 m_broadcast->isChecked()};
69 void setSettings(
const ossia::net::udp_configuration& conf)
73 m_remotePort->setValue(conf.remote->port);
74 m_host->setText(QString::fromStdString(conf.remote->host));
75 m_broadcast->setChecked(conf.remote->broadcast);
79 m_localPort->setValue(conf.local->port);
84 QSpinBox* m_localPort{};
85 QSpinBox* m_remotePort{};
86 QCheckBox* m_broadcast{};