@@ -23,39 +23,56 @@ class DeviceState: public QObject {
2323
2424public:
2525 enum Enum : quint8 {
26+ // / The device state is unknown.
2627 Unknown = 0 ,
27- Disconnected = 10 ,
28- Connecting = 20 ,
29- Connected = 30 ,
30- Disconnecting = 40 ,
28+ // / The device is not connected.
29+ Disconnected = 1 ,
30+ // / The device is connected.
31+ Connected = 2 ,
32+ // / The device is disconnecting.
33+ Disconnecting = 3 ,
34+ // / The device is connecting.
35+ Connecting = 4 ,
3136 };
3237 Q_ENUM (Enum);
3338 Q_INVOKABLE static QString toString (DeviceState::Enum state);
3439};
3540
41+ // /! A tracked network device.
3642class Device : public QObject {
3743 Q_OBJECT;
3844 QML_ELEMENT;
3945 QML_UNCREATABLE (" Devices can only be acquired through Network" );
4046
4147 // clang-format off
48+ // / The name of the device's interface.
4249 Q_PROPERTY (QString name READ default NOTIFY nameChanged BINDABLE bindableName);
50+ // / The hardware address of the device's interface in the XX:XX:XX:XX:XX:XX format.
4351 Q_PROPERTY (QString address READ default NOTIFY addressChanged BINDABLE bindableAddress);
52+ // / Connection state of the device.
4453 Q_PROPERTY (DeviceState::Enum state READ default NOTIFY stateChanged BINDABLE bindableState);
4554 // clang-format on
4655
4756signals:
57+ void signalDisconnect ();
58+
59+ // Frontend-facing signals
4860 void nameChanged ();
4961 void addressChanged ();
5062 void stateChanged ();
5163
5264public slots:
65+ // Slots for the backend to connect signals to
5366 void setName (const QString& name);
5467 void setAddress (const QString& address);
5568 void setState (DeviceState::Enum state);
5669
5770public:
5871 explicit Device (QObject* parent = nullptr );
72+
73+ // / Disconnects the device and prevents it from automatically activating further connections.
74+ Q_INVOKABLE void disconnect ();
75+
5976 [[nodiscard]] QBindable<QString> bindableName () const { return &this ->bName ; };
6077 [[nodiscard]] QBindable<QString> bindableAddress () const { return &this ->bAddress ; };
6178 [[nodiscard]] QBindable<DeviceState::Enum> bindableState () const { return &this ->bState ; };
0 commit comments