TCPServerWidget.hpp
1 #pragma once
2 #include <Device/Protocol/ProtocolSettingsWidget.hpp>
3 
4 #include <Protocols/NetworkWidgets/TCPWidget.hpp>
5 
6 #include <ossia/network/sockets/configuration.hpp>
7 
8 #include <QComboBox>
9 #include <QFormLayout>
10 #include <QSpinBox>
11 namespace Protocols
12 {
13 
14 class TCPServerWidget : public QWidget
15 {
16 public:
17  TCPServerWidget(Device::ProtocolSettingsWidget& proto, QWidget* parent)
18  : QWidget{parent}
19  {
20  auto layout = new QFormLayout{this};
21  layout->setContentsMargins(0, 0, 0, 0);
22 
23  m_remotePort = new QSpinBox(this);
24  m_remotePort->setRange(0, 65535);
25  m_remotePort->setValue(9996);
26  proto.checkForChanges(m_remotePort);
27 
28  m_framing = new QComboBox{this};
29  m_framing->addItems({"Size prefixing", "SLIP"});
30  m_framing->setCurrentIndex(1);
31 
32  layout->addRow(tr("Port"), m_remotePort);
33  layout->addRow(tr("Framing"), m_framing);
34  }
35 
36  framing_type framing() const noexcept
37  {
38  return (framing_type)m_framing->currentIndex();
39  }
40 
41  ossia::net::tcp_server_configuration settings() const noexcept
42  {
43  ossia::net::tcp_server_configuration conf;
44  conf.port = m_remotePort->value();
45  return conf;
46  }
47 
48  void setSettings(
49  const ossia::net::osc_protocol_configuration& c,
50  const ossia::net::tcp_server_configuration& conf)
51  {
52  m_remotePort->setValue(conf.port);
53  m_framing->setCurrentIndex(c.framing);
54  }
55 
56 private:
57  QSpinBox* m_remotePort{};
58  QComboBox* m_framing{};
59 };
60 }
Definition: ProtocolSettingsWidget.hpp:22
Definition: TCPServerWidget.hpp:15