UnixStreamWidget.hpp
1 #pragma once
2 #include <Device/Protocol/ProtocolSettingsWidget.hpp>
3 
4 #include <ossia/network/sockets/configuration.hpp>
5 #include <ossia/protocols/osc/osc_factory.hpp>
6 
7 #include <QComboBox>
8 #include <QFormLayout>
9 #include <QLineEdit>
10 namespace Protocols
11 {
12 
13 using framing_type = decltype(ossia::net::osc_protocol_configuration::framing);
14 class UnixStreamWidget : public QWidget
15 {
16 public:
17  UnixStreamWidget(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_host = new QLineEdit(this);
24  m_host->setText("/tmp/ossia.socket");
25 
26  m_framing = new QComboBox{this};
27  m_framing->addItems({"Size prefixing", "SLIP"});
28  m_framing->setCurrentIndex(1);
29 
30  layout->addRow(tr("Path"), m_host);
31  layout->addRow(tr("Framing"), m_framing);
32  }
33 
34  framing_type framing() const noexcept
35  {
36  return (framing_type)m_framing->currentIndex();
37  }
38 
39  ossia::net::unix_stream_configuration settings() const noexcept
40  {
41  ossia::net::unix_stream_configuration conf;
42  conf.fd = m_host->text().toStdString();
43  return conf;
44  }
45 
46  void setSettings(
47  const ossia::net::osc_protocol_configuration& c,
48  const ossia::net::unix_stream_configuration& conf)
49  {
50  m_framing->setCurrentIndex(c.framing);
51  m_host->setText(QString::fromStdString(conf.fd));
52  }
53 
54 private:
55  QComboBox* m_framing{};
56  QLineEdit* m_host{};
57 };
58 }
Definition: ProtocolSettingsWidget.hpp:22
Definition: UnixStreamWidget.hpp:15