MQTTProtocolSettingsWidget.hpp
1 #pragma once
2 #include <Device/Protocol/DeviceSettings.hpp>
3 #include <Device/Protocol/ProtocolSettingsWidget.hpp>
4 
5 #include <Protocols/MQTT/MQTTSpecificSettings.hpp>
6 
7 #include <verdigris>
8 
9 class QStackedLayout;
10 class QLineEdit;
11 class QSpinBox;
12 class QWidget;
13 
14 namespace Protocols
15 {
16 
17 class BasicTCPWidget;
18 class WebsocketClientWidget;
19 class RateWidget;
20 
21 enum class MqttProtocol
22 {
23  TCP = 0,
24  WSClient = 1,
25 };
26 
27 class MQTTTransportWidget : public QWidget
28 {
29 public:
30  explicit MQTTTransportWidget(
31  Device::ProtocolSettingsWidget& proto, QWidget* parent = nullptr);
32 
33  void setCurrentProtocol(MqttProtocol index);
34  ossia::net::mqtt5_configuration configuration(MqttProtocol index) const noexcept;
35  MqttProtocol setConfiguration(const ossia::net::mqtt5_configuration& conf);
36 
37 private:
38  QStackedLayout* m_transportLayout{};
39 
40  BasicTCPWidget* m_tcp{};
41  WebsocketClientWidget* m_ws_client{};
42 };
43 
45 {
46 public:
47  explicit MQTTProtocolSettingsWidget(QWidget* parent = nullptr);
48 
49  Device::DeviceSettings getSettings() const override;
50  void setSettings(const Device::DeviceSettings& settings) override;
51 
52  using Device::ProtocolSettingsWidget::checkForChanges;
53 
54 private:
55  void setDefaults();
56  QLineEdit* m_deviceNameEdit{};
57  RateWidget* m_rate{};
58  QComboBox* m_transport{};
59  MQTTTransportWidget* m_transportWidget{};
60  MQTTSpecificSettings m_settings;
61 };
62 }
Definition: ProtocolSettingsWidget.hpp:22
Definition: TCPWidget.hpp:16
Definition: MQTTProtocolSettingsWidget.hpp:45
Definition: MQTTProtocolSettingsWidget.hpp:28
Definition: RateWidget.hpp:15
Definition: WebsocketClientWidget.hpp:12
Definition: DeviceSettings.hpp:20
Definition: MQTTSpecificSettings.hpp:12