mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
server doxygen
Add documentation to the server
This commit is contained in:
@@ -3,18 +3,54 @@
|
||||
|
||||
#define UI_BUTTON_TYPE std::string("ui_button")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI button
|
||||
*
|
||||
*/
|
||||
class UI_button : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI button object
|
||||
*
|
||||
* @param text The text to display on the button
|
||||
* @param fg_color The foreground color of the button
|
||||
* @param bg_color The background color of the button
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_button(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI button object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_button(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Deserialize the button from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the button to JSON
|
||||
*
|
||||
* @param id The id of the button
|
||||
* @return json The JSON representation of the button
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
/**
|
||||
* @brief Handle a click event on the button
|
||||
*
|
||||
*/
|
||||
void click() override;
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the button is clicked
|
||||
*
|
||||
*/
|
||||
void clicked();
|
||||
};
|
||||
|
||||
@@ -4,35 +4,119 @@
|
||||
|
||||
#define UI_CAN_TYPE std::string("ui_can")
|
||||
|
||||
/**
|
||||
* @brief Class representing a CAN UI item
|
||||
*
|
||||
*/
|
||||
class CanFrame
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Can Frame object
|
||||
*
|
||||
* @param sid The standard identifier
|
||||
* @param dlc The data length code
|
||||
* @param payload The data payload
|
||||
*/
|
||||
CanFrame(uint32_t sid, uint8_t dlc, std::array<uint8_t, 8> payload) : m_SID(sid), m_DLC(dlc), m_payload(payload)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @brief Get the Standard Identifier
|
||||
*
|
||||
* @return uint32_t The standard identifier
|
||||
*/
|
||||
uint32_t m_SID;
|
||||
/**
|
||||
* @brief The Data Length Code
|
||||
*
|
||||
*/
|
||||
uint8_t m_DLC;
|
||||
/**
|
||||
* @brief The Payload
|
||||
*
|
||||
*/
|
||||
std::array<uint8_t, 8> m_payload;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Class representing a CAN UI item
|
||||
*
|
||||
*/
|
||||
class UI_can : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI can object
|
||||
*
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_can(Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI can object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_can(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Add a CAN message to the send buffer
|
||||
*
|
||||
* @param msg The CAN message to add
|
||||
*/
|
||||
void add_send_message(QCanBusFrame msg);
|
||||
/**
|
||||
* @brief Add a CAN message to the receive buffer
|
||||
*
|
||||
* @param msg The CAN message to add
|
||||
*/
|
||||
void add_received_message(QCanBusFrame msg);
|
||||
/**
|
||||
* @brief Clear the send buffer
|
||||
*
|
||||
*/
|
||||
void clear_send_buffer();
|
||||
/**
|
||||
* @brief Clear the receive buffer
|
||||
*
|
||||
*/
|
||||
void clear_receive_buffer();
|
||||
|
||||
/**
|
||||
* @brief Deserialize the CAN item from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the CAN item to JSON
|
||||
*
|
||||
* @param id The id of the CAN item
|
||||
* @return json The JSON representation of the CAN item
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
/**
|
||||
* @brief Handle a CAN send event
|
||||
*
|
||||
* @param id The CAN identifier
|
||||
* @param dlc The data length code
|
||||
* @param payload The data payload
|
||||
*/
|
||||
void can_send(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload) override;
|
||||
/**
|
||||
* @brief Clear the CAN item
|
||||
*
|
||||
*/
|
||||
void clear() override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when a CAN message wants to be sent
|
||||
* @param msg The CAN message sent
|
||||
*/
|
||||
void send(QCanBusFrame msg);
|
||||
|
||||
private:
|
||||
|
||||
+49
-1
@@ -3,22 +3,70 @@
|
||||
|
||||
#define UI_CHECKBOX_TYPE std::string("ui_checkbox")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI checkbox
|
||||
*
|
||||
*/
|
||||
class UI_checkbox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI checkbox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_checkbox(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI checkbox object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_checkbox(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Handle a click event on the checkbox
|
||||
*
|
||||
*/
|
||||
void click() override;
|
||||
/**
|
||||
* @brief Set the state of the checkbox
|
||||
*
|
||||
* @param state The state to set
|
||||
*/
|
||||
void set_state(bool state);
|
||||
/**
|
||||
* @brief Get the state of the checkbox
|
||||
*
|
||||
* @return true If checked
|
||||
* @return false If unchecked
|
||||
*/
|
||||
bool state() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the checkbox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the checkbox to JSON
|
||||
*
|
||||
* @param id The id of the checkbox
|
||||
* @return json The JSON representation of the checkbox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
signals:
|
||||
void changed(bool);
|
||||
/**
|
||||
* @brief Signal emitted when the checkbox state changes
|
||||
*
|
||||
* @param checked The new state of the checkbox
|
||||
*/
|
||||
void changed(bool checked);
|
||||
|
||||
private:
|
||||
bool m_checked;
|
||||
|
||||
@@ -3,22 +3,76 @@
|
||||
|
||||
#define UI_COMBOBOX_TYPE std::string("ui_combobox")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI combobox
|
||||
*
|
||||
*/
|
||||
class UI_combobox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI combobox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_combobox(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI combobox object
|
||||
*
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param options The list of options
|
||||
* @param selected The initially selected option
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_combobox(Color fg_color, Color bg_color, std::vector<std::string> options, size_t selected = 0,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the selected option by index
|
||||
*
|
||||
* @param selected The index of the option to select
|
||||
*/
|
||||
void set_selected(size_t selected) override;
|
||||
/**
|
||||
* @brief Set the selected option by text
|
||||
*
|
||||
* @param selected The text of the option to select
|
||||
*/
|
||||
void set_selected(std::string selected);
|
||||
/**
|
||||
* @brief Get the index of the selected option
|
||||
*
|
||||
* @return size_t The index of the selected option
|
||||
*/
|
||||
size_t selected() const;
|
||||
/**
|
||||
* @brief Get the text of the selected option
|
||||
*
|
||||
* @return std::string The text of the selected option
|
||||
*/
|
||||
std::string selected_text() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the combobox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the combobox to JSON
|
||||
*
|
||||
* @param id The id of the combobox
|
||||
* @return json The JSON representation of the combobox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the selected option changes
|
||||
*
|
||||
* @param selected The text of the newly selected option
|
||||
*/
|
||||
void changed(std::string selected);
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,26 +3,113 @@
|
||||
|
||||
#define UI_DIAL_TYPE std::string("ui_dial")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI dial
|
||||
*
|
||||
*/
|
||||
class UI_dial : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI dial object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the dial
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_dial(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI dial object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the dial
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_dial(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI dial object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_dial(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI dial object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_dial(std::string text, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI dial object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_dial(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the dial
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the dial
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the dial
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the dial
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
/**
|
||||
* @brief Get the unit of the dial
|
||||
*
|
||||
* @return std::string The unit of the dial
|
||||
*/
|
||||
std::string unit() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the dial from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the dial to JSON
|
||||
*
|
||||
* @param id The id of the dial
|
||||
* @return json The JSON representation of the dial
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,22 +3,75 @@
|
||||
|
||||
#define UI_DOUBLE_SPINBOX_TYPE std::string("ui_double_spinbox")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI double spinbox
|
||||
*
|
||||
*/
|
||||
class UI_double_spinbox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI double spinbox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_double_spinbox(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI double spinbox object
|
||||
*
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_double_spinbox(double min, double max, double value, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the double spinbox
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the double spinbox
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the double spinbox
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the double spinbox
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the double spinbox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the double spinbox to JSON
|
||||
*
|
||||
* @param id The id of the double spinbox
|
||||
* @return json The JSON representation of the double spinbox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the double spinbox value changes
|
||||
*
|
||||
* @param value The new value
|
||||
*/
|
||||
void changed(double value);
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,18 +7,67 @@ class UI_hex_spinbox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI hex spinbox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_hex_spinbox(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI hex spinbox object
|
||||
*
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_hex_spinbox(double min, double max, double value, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the hex spinbox
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the hex spinbox
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the hex spinbox
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the hex spinbox
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the hex spinbox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the hex spinbox to JSON
|
||||
*
|
||||
* @param id The id of the hex spinbox
|
||||
* @return json The JSON representation of the hex spinbox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the hex spinbox value changes
|
||||
*
|
||||
* @param value The new value
|
||||
*/
|
||||
void changed(double value);
|
||||
|
||||
private:
|
||||
|
||||
@@ -17,10 +17,6 @@ UI_item::UI_item(const json &j, QObject *parent) : QObject(parent)
|
||||
from_json(j);
|
||||
}
|
||||
|
||||
UI_item::~UI_item()
|
||||
{
|
||||
}
|
||||
|
||||
std::string UI_item::type() const
|
||||
{
|
||||
return m_type;
|
||||
|
||||
+181
-1
@@ -10,58 +10,238 @@ using json = nlohmann::json;
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
/**
|
||||
* @brief Base class representing a UI item
|
||||
*
|
||||
*/
|
||||
class UI_item : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new UI item object
|
||||
*
|
||||
* @param type The type of the UI item
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_item(std::string type, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a new UI item object
|
||||
*
|
||||
* @param type The type of the UI item
|
||||
* @param text The text of the UI item
|
||||
* @param fg_color The foreground color of the UI item
|
||||
* @param bg_color The background color of the UI item
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_item(std::string type, std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a new UI item object from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_item(const json &j, QObject *parent = nullptr);
|
||||
~UI_item();
|
||||
|
||||
/**
|
||||
* @brief Get the type of the UI item
|
||||
*
|
||||
* @return std::string The type of the UI item
|
||||
*/
|
||||
std::string type() const;
|
||||
/**
|
||||
* @brief Check if the JSON object is of the correct type
|
||||
*
|
||||
* @param j The JSON object
|
||||
* @return true If the JSON object is of the correct type
|
||||
* @return false If the JSON object is not of the correct type
|
||||
*/
|
||||
bool is_type(json j);
|
||||
|
||||
/**
|
||||
* @brief Set the text of the UI item
|
||||
*
|
||||
* @param text The text to set
|
||||
*/
|
||||
virtual void set_text(std::string text);
|
||||
/**
|
||||
* @brief Append text to the UI item
|
||||
*
|
||||
* @param text The text to append
|
||||
*/
|
||||
void append_text(std::string text);
|
||||
/**
|
||||
* @brief Get the text of the UI item
|
||||
*
|
||||
* @return std::string The text of the UI item
|
||||
*/
|
||||
std::string text() const;
|
||||
|
||||
/**
|
||||
* @brief Set the foreground color of the UI item
|
||||
*
|
||||
* @param fg_color The foreground color to set
|
||||
*/
|
||||
void set_fg_color(Color fg_color);
|
||||
/**
|
||||
* @brief Get the foreground color of the UI item
|
||||
*
|
||||
* @return Color The foreground color of the UI item
|
||||
*/
|
||||
Color fg_color() const;
|
||||
|
||||
/**
|
||||
* @brief Set the background color of the UI item
|
||||
*
|
||||
* @param bg_color The background color to set
|
||||
*/
|
||||
void set_bg_color(Color bg_color);
|
||||
/**
|
||||
* @brief Get the background color of the UI item
|
||||
*
|
||||
* @return Color The background color of the UI item
|
||||
*/
|
||||
Color bg_color() const;
|
||||
|
||||
/**
|
||||
* @brief Enable or disable the UI item
|
||||
*
|
||||
* @param enabled True to enable, false to disable
|
||||
*/
|
||||
void set_enabled(bool enabled);
|
||||
/**
|
||||
* @brief Check if the UI item is enabled
|
||||
*
|
||||
* @return true If enabled
|
||||
* @return false If disabled
|
||||
*/
|
||||
bool is_enabled() const;
|
||||
|
||||
/**
|
||||
* @brief Set the visibility of the UI item
|
||||
*
|
||||
* @param visible True to show, false to hide
|
||||
*/
|
||||
void set_visible(bool visible);
|
||||
/**
|
||||
* @brief Check if the UI item is visible
|
||||
*
|
||||
* @return true If visible
|
||||
* @return false If hidden
|
||||
*/
|
||||
bool is_visible() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the UI item from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
virtual void from_json(const json &j);
|
||||
|
||||
/**
|
||||
* @brief Serialize the UI item to JSON
|
||||
*
|
||||
* @param id The id of the UI item
|
||||
* @return json The JSON representation of the UI item
|
||||
*/
|
||||
virtual json to_json(size_t id) const;
|
||||
|
||||
/**
|
||||
* @brief Virtual method to handle click events
|
||||
*
|
||||
*/
|
||||
virtual void click();
|
||||
/**
|
||||
* @brief Virtual method to set the selected option (for comboboxes)
|
||||
*
|
||||
* @param selected The index of the option to select
|
||||
*/
|
||||
virtual void set_selected(size_t selected);
|
||||
/**
|
||||
* @brief Virtual method to set the value (for spinboxes)
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
virtual void set_value(double value);
|
||||
/**
|
||||
* @brief Virtual method to handle CAN send events
|
||||
*
|
||||
* @param id The CAN ID
|
||||
* @param dlc The data length code
|
||||
* @param payload The payload data
|
||||
*/
|
||||
virtual void can_send(uint32_t id, uint8_t dlc, std::array<uint8_t, 8> payload);
|
||||
/**
|
||||
* @brief Virtual method to clear the UI item
|
||||
*
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the UI item changes
|
||||
*
|
||||
*/
|
||||
void ui_changed();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Setup the UI item properties
|
||||
*
|
||||
* @param text Enable text property
|
||||
* @param fg_color Enable foreground color property
|
||||
* @param bg_color Enable background color property
|
||||
*/
|
||||
void setup_item(bool text, bool fg_color, bool bg_color);
|
||||
|
||||
/**
|
||||
* @brief The id of the UI item
|
||||
*
|
||||
*/
|
||||
size_t m_id;
|
||||
/**
|
||||
* @brief The type of the UI item
|
||||
*
|
||||
*/
|
||||
std::string m_type;
|
||||
/**
|
||||
* @brief The text of the UI item
|
||||
*
|
||||
*/
|
||||
std::string m_text;
|
||||
/**
|
||||
* @brief Whether the text property is enabled
|
||||
*
|
||||
*/
|
||||
bool m_text_enabled = true;
|
||||
/**
|
||||
* @brief The foreground color of the UI item
|
||||
*
|
||||
*/
|
||||
Color m_fg_color;
|
||||
/**
|
||||
* @brief Whether the foreground color property is enabled
|
||||
*
|
||||
*/
|
||||
bool m_fg_color_enabled = true;
|
||||
/**
|
||||
* @brief The background color of the UI item
|
||||
*
|
||||
*/
|
||||
Color m_bg_color;
|
||||
/**
|
||||
* @brief Whether the background color property is enabled
|
||||
*
|
||||
*/
|
||||
bool m_bg_color_enabled = true;
|
||||
/**
|
||||
* @brief Whether the UI item is enabled
|
||||
*
|
||||
*/
|
||||
bool m_enabled;
|
||||
/**
|
||||
* @brief Whether the UI item is visible
|
||||
*
|
||||
*/
|
||||
bool m_visible;
|
||||
};
|
||||
|
||||
@@ -4,13 +4,41 @@
|
||||
|
||||
#define UI_LABEL_TYPE std::string("ui_label")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI label
|
||||
*
|
||||
*/
|
||||
class UI_label : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI label object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_label(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI label object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_label(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Deserialize the label from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the label to JSON
|
||||
*
|
||||
* @param id The id of the label
|
||||
* @return json The JSON representation of the label
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
};
|
||||
|
||||
@@ -4,15 +4,52 @@
|
||||
|
||||
#define UI_LED_TYPE std::string("ui_led")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI led
|
||||
*
|
||||
*/
|
||||
class UI_led : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI led object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_led(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI led object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_led(std::string text, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the state of the LED
|
||||
*
|
||||
* @param state The state to set
|
||||
* @param on The color when the LED is on
|
||||
* @param off The color when the LED is off
|
||||
* @return true If the state was changed
|
||||
* @return false If the state was not changed
|
||||
*/
|
||||
bool set_led(bool state, Color on, Color off);
|
||||
|
||||
/**
|
||||
* @brief Deserialize the LED from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the LED to JSON
|
||||
*
|
||||
* @param id The id of the LED
|
||||
* @return json The JSON representation of the LED
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
};
|
||||
|
||||
@@ -2,24 +2,101 @@
|
||||
#include "ui_item.hpp"
|
||||
#define UI_PLOT_TYPE std::string("ui_plot")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI plot
|
||||
*
|
||||
*/
|
||||
class UI_plot : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI plot object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_plot(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI plot object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param x_label The label for the x-axis
|
||||
* @param y_label The label for the y-axis
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_plot(std::string text, std::string x_label, std::string y_label, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the label for the x-axis
|
||||
*
|
||||
* @param name The name to set
|
||||
*/
|
||||
void set_x_label(std::string name);
|
||||
/**
|
||||
* @brief Get the label for the x-axis
|
||||
*
|
||||
* @return std::string The x-axis label
|
||||
*/
|
||||
std::string x_label() const;
|
||||
|
||||
/**
|
||||
* @brief Set the label for the y-axis
|
||||
*
|
||||
* @param name The name to set
|
||||
*/
|
||||
void set_y_label(std::string name);
|
||||
/**
|
||||
* @brief Get the label for the y-axis
|
||||
*
|
||||
* @return std::string The y-axis label
|
||||
*/
|
||||
std::string y_label() const;
|
||||
|
||||
/**
|
||||
* @brief Add a value to the plot
|
||||
*
|
||||
* @param y The y value to add
|
||||
*/
|
||||
void add_value(double y);
|
||||
/**
|
||||
* @brief Add a value pair to the plot
|
||||
*
|
||||
* @param x The x value to add
|
||||
* @param y The y value to add
|
||||
*/
|
||||
void add_value(double x, double y);
|
||||
/**
|
||||
* @brief Get the x and y values of the plot
|
||||
* This is only for testing purposes
|
||||
*
|
||||
* @return a list of x values and a list of y values
|
||||
*/
|
||||
const std::vector<double> &x_vals() const;
|
||||
/**
|
||||
* @brief Get the y values of the plot
|
||||
* This is only for testing purposes
|
||||
*
|
||||
* @return a list of y values
|
||||
*/
|
||||
const std::vector<double> &y_vals() const;
|
||||
/**
|
||||
* @brief Clear all values from the plot
|
||||
*
|
||||
*/
|
||||
void clean_vals();
|
||||
|
||||
/**
|
||||
* @brief Deserialize the plot from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the plot to JSON
|
||||
*
|
||||
* @param id The id of the plot
|
||||
* @return json The JSON representation of the plot
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,27 +3,114 @@
|
||||
|
||||
#define UI_SLIDER_TYPE std::string("ui_slider")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI slider
|
||||
*
|
||||
*/
|
||||
class UI_slider : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI slider object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the slider
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_slider(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI slider object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the slider
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_slider(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI slider object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_slider(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI slider object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_slider(std::string text, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI slider object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_slider(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the slider
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the slider
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the slider
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the slider
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the slider from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the slider to JSON
|
||||
*
|
||||
* @param id The id of the slider
|
||||
* @return json The JSON representation of the slider
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the slider value changes
|
||||
*
|
||||
* @param value The new value of the slider
|
||||
*/
|
||||
void changed(double value);
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,22 +3,75 @@
|
||||
|
||||
#define UI_SPINBOX_TYPE std::string("ui_spinbox")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI spinbox
|
||||
*
|
||||
*/
|
||||
class UI_spinbox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI spinbox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_spinbox(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI spinbox object
|
||||
*
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_spinbox(double min, double max, double value, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the spinbox
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the spinbox
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the spinbox
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the spinbox
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the spinbox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the spinbox to JSON
|
||||
*
|
||||
* @param id The id of the spinbox
|
||||
* @return json The JSON representation of the spinbox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the spinbox value changes
|
||||
*
|
||||
* @param value The new value of the spinbox
|
||||
*/
|
||||
void changed(double value);
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,18 +2,59 @@
|
||||
#include "ui_item.hpp"
|
||||
#define UI_STACKED_WIDGET_TYPE std::string("ui_stacked_widget")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI stacked widget
|
||||
*
|
||||
*/
|
||||
class UI_stacked_widget : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI stacked widget object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_stacked_widget(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI stacked widget object
|
||||
*
|
||||
* @param tab_count The number of tabs
|
||||
* @param current_tab The currently selected tab
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_stacked_widget(size_t tab_count, size_t current_tab, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the selected tab by index
|
||||
*
|
||||
* @param selected The index of the tab to select
|
||||
*/
|
||||
void set_selected(size_t selected) override;
|
||||
/**
|
||||
* @brief Get the index of the selected tab
|
||||
*
|
||||
* @return size_t The index of the selected tab
|
||||
*/
|
||||
size_t selected() const;
|
||||
/**
|
||||
* @brief Advance to the next tab
|
||||
*
|
||||
*/
|
||||
void advance_tab();
|
||||
|
||||
/**
|
||||
* @brief Deserialize the stacked widget from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the stacked widget to JSON
|
||||
*
|
||||
* @param id The id of the stacked widget
|
||||
* @return json The JSON representation of the stacked widget
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,18 +2,60 @@
|
||||
#include "ui_item.hpp"
|
||||
#define UI_STATUS_BAR_TYPE std::string("ui_status_bar")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI status bar
|
||||
*
|
||||
*/
|
||||
class UI_status_bar : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI status bar object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_status_bar(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI status bar object
|
||||
*
|
||||
* @param message The initial message
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_status_bar(std::string message, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Show a message on the status bar
|
||||
*
|
||||
* @param message The message to show
|
||||
* @param timeout The timeout in milliseconds (0 for no timeout)
|
||||
*/
|
||||
void show_message(std::string message, size_t timeout = 0);
|
||||
/**
|
||||
* @brief Get the current message
|
||||
*
|
||||
* @return std::string The current message
|
||||
*/
|
||||
std::string message() const;
|
||||
/**
|
||||
* @brief Get the timeout for the current message
|
||||
*
|
||||
* @return size_t The timeout in milliseconds
|
||||
*/
|
||||
size_t timeout() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the status bar from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the status bar to JSON
|
||||
*
|
||||
* @param id The id of the status bar
|
||||
* @return json The JSON representation of the status bar
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -3,27 +3,97 @@
|
||||
|
||||
#define UI_TAB_WIDGET_TYPE std::string("ui_tab_widget")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI tab widget
|
||||
*
|
||||
*/
|
||||
class UI_tab_widget : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/** * @brief Construct a UI tab widget object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_tab_widget(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI tab widget object
|
||||
*
|
||||
* @param tab_names The names of the tabs
|
||||
* @param selected The initially selected tab
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_tab_widget(std::vector<std::string> tab_names, size_t selected = 0, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the selected tab by index
|
||||
*
|
||||
* @param selected The index of the tab to select
|
||||
*/
|
||||
void set_selected(size_t selected) override;
|
||||
/**
|
||||
* @brief Get the index of the selected tab
|
||||
*
|
||||
* @return size_t The index of the selected tab
|
||||
*/
|
||||
size_t selected() const;
|
||||
|
||||
/**
|
||||
* @brief Set the visibility of a tab by index
|
||||
*
|
||||
* @param index The index of the tab
|
||||
* @param visible True to show, false to hide
|
||||
*/
|
||||
void set_visible(size_t index, bool visible);
|
||||
/**
|
||||
* @brief Get the visibility of a tab by index
|
||||
*
|
||||
* @param index The index of the tab
|
||||
* @return true If the tab is visible
|
||||
* @return false If the tab is hidden
|
||||
*/
|
||||
bool visible(size_t index) const;
|
||||
|
||||
/**
|
||||
* @brief Set the name of a tab by index
|
||||
*
|
||||
* @param index The index of the tab
|
||||
* @param name The name to set
|
||||
*/
|
||||
void set_tab_name(size_t index, std::string name);
|
||||
/**
|
||||
* @brief Get the name of a tab by index
|
||||
*
|
||||
* @param index The index of the tab
|
||||
* @return std::string The name of the tab
|
||||
*/
|
||||
std::string tab_name(size_t index) const;
|
||||
|
||||
/**
|
||||
* @brief Advance to the next tab
|
||||
*
|
||||
*/
|
||||
void advance_tab();
|
||||
|
||||
/**
|
||||
* @brief Deserialize the tab widget from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the tab widget to JSON
|
||||
*
|
||||
* @param id The id of the tab widget
|
||||
* @return json The JSON representation of the tab widget
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the selected tab changes
|
||||
*
|
||||
* @param index The index of the newly selected tab
|
||||
*/
|
||||
void changed(size_t index);
|
||||
|
||||
private:
|
||||
|
||||
+97
-1
@@ -3,35 +3,131 @@
|
||||
|
||||
#define UI_TABLE_TYPE std::string("ui_table")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI table
|
||||
*
|
||||
*/
|
||||
class UI_table : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI table object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_table(QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI table object
|
||||
*
|
||||
* @param row_count The number of rows
|
||||
* @param column_count The number of columns
|
||||
* @param row_labels The labels for the rows
|
||||
* @param column_labels The labels for the columns
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
explicit UI_table(size_t row_count, size_t column_count, std::vector<std::string> row_labels,
|
||||
std::vector<std::string> column_labels, QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the number of rows in the table
|
||||
*
|
||||
* @param count The number of rows
|
||||
*/
|
||||
void set_row_count(size_t count);
|
||||
/**
|
||||
* @brief Get the number of rows in the table
|
||||
*
|
||||
* @return size_t The number of rows
|
||||
*/
|
||||
size_t row_count() const;
|
||||
|
||||
/**
|
||||
* @brief Set the number of columns in the table
|
||||
*
|
||||
* @param count The number of columns
|
||||
*/
|
||||
void set_column_count(size_t count);
|
||||
/**
|
||||
* @brief Get the number of columns in the table
|
||||
*
|
||||
* @return size_t The number of columns
|
||||
*/
|
||||
size_t column_count() const;
|
||||
|
||||
/**
|
||||
* @brief Get the capacity of the table (rows * columns)
|
||||
*
|
||||
* @return size_t The capacity of the table
|
||||
*/
|
||||
size_t capacity() const;
|
||||
|
||||
/**
|
||||
* @brief Set the label for a specific row
|
||||
*
|
||||
* @param index The index of the row
|
||||
* @param label The label to set
|
||||
*/
|
||||
void set_row_label(size_t index, std::string label);
|
||||
/**
|
||||
* @brief Get the label of a specific row
|
||||
*
|
||||
* @param index The index of the row
|
||||
* @return std::string The label of the row
|
||||
*/
|
||||
std::string row_label(size_t index) const;
|
||||
|
||||
/**
|
||||
* @brief Set the label for a specific column
|
||||
*
|
||||
* @param index The index of the column
|
||||
* @param label The label to set
|
||||
*/
|
||||
void set_column_label(size_t index, std::string label);
|
||||
/**
|
||||
* @brief Get the label of a specific column
|
||||
*
|
||||
* @param index The index of the column
|
||||
* @return std::string The label of the column
|
||||
*/
|
||||
std::string column_label(size_t index) const;
|
||||
|
||||
/**
|
||||
* @brief Insert an item into the table at the specified row and column
|
||||
*
|
||||
* @param row The row of the item
|
||||
* @param column The column of the item
|
||||
* @param text The text of the item
|
||||
*/
|
||||
void insert_item(size_t row, size_t column, std::string text);
|
||||
/**
|
||||
* @brief Get the item at the specified row and column
|
||||
*
|
||||
* @param row The row of the item
|
||||
* @param column The column of the item
|
||||
* @return std::string The text of the item
|
||||
*/
|
||||
std::string item(size_t row, size_t column) const;
|
||||
|
||||
/**
|
||||
* @brief empty_item This function clears the item and makes it invalid
|
||||
* @brief empty_item This function clears the item
|
||||
* @param row The row of the item
|
||||
* @param column The column of the item
|
||||
*/
|
||||
void empty_item(size_t row, size_t column);
|
||||
|
||||
/**
|
||||
* @brief Deserialize the table from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the table to JSON
|
||||
*
|
||||
* @param id The id of the table
|
||||
* @return json The JSON representation of the table
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,21 +4,69 @@
|
||||
|
||||
#define UI_TEXTBOX_TYPE std::string("ui_textbox")
|
||||
|
||||
/**
|
||||
* @brief Class representing a UI textbox
|
||||
*
|
||||
*/
|
||||
class UI_textbox : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI textbox object
|
||||
*
|
||||
* @param hint The hint text
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_textbox(std::string hint, Color fg_color, Color bg_color, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI textbox object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_textbox(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the text of the textbox
|
||||
*
|
||||
* @param text The text to set
|
||||
*/
|
||||
void set_text(std::string text) override;
|
||||
|
||||
/**
|
||||
* @brief Get the hint text of the textbox
|
||||
*
|
||||
* @param hint The hint text to set
|
||||
*/
|
||||
void set_hint(std::string hint);
|
||||
/**
|
||||
* @brief Get the hint text of the textbox
|
||||
*
|
||||
* @return std::string The hint text
|
||||
*/
|
||||
std::string hint() const;
|
||||
|
||||
/**
|
||||
* @brief Deserialize the textbox from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the textbox to JSON
|
||||
*
|
||||
* @param id The id of the textbox
|
||||
* @return json The JSON representation of the textbox
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
signals:
|
||||
/**
|
||||
* @brief Signal emitted when the text changes
|
||||
*
|
||||
* @param text The new text
|
||||
*/
|
||||
void changed(std::string text);
|
||||
|
||||
private:
|
||||
|
||||
@@ -4,32 +4,146 @@
|
||||
#define UI_THERMO_TYPE std::string("ui_thermo")
|
||||
|
||||
// TODO: Add color scale
|
||||
/**
|
||||
* @brief Class representing a UI thermometer
|
||||
*
|
||||
*/
|
||||
class UI_thermo : public UI_item
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a UI thermometer object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the thermometer
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_thermo(std::string text, std::string unit, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI thermometer object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param unit The unit of the thermometer
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_thermo(std::string text, std::string unit, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI thermometer object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param fg_color The foreground color
|
||||
* @param bg_color The background color
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_thermo(std::string text, Color fg_color, Color bg_color, double min, double max, double value,
|
||||
QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI thermometer object
|
||||
*
|
||||
* @param text The text to display
|
||||
* @param min The minimum value
|
||||
* @param max The maximum value
|
||||
* @param value The initial value
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_thermo(std::string text, double min, double max, double value, QObject *parent = nullptr);
|
||||
/**
|
||||
* @brief Construct a UI thermometer object
|
||||
*
|
||||
* @param parent The parent QObject
|
||||
*/
|
||||
UI_thermo(QObject *parent = nullptr);
|
||||
|
||||
/**
|
||||
* @brief Set the value of the thermometer
|
||||
*
|
||||
* @param value The value to set
|
||||
*/
|
||||
void set_value(double value) override;
|
||||
/**
|
||||
* @brief Get the value of the thermometer
|
||||
*
|
||||
* @return double The current value
|
||||
*/
|
||||
double value() const;
|
||||
|
||||
/**
|
||||
* @brief Get the minimum value of the thermometer
|
||||
*
|
||||
* @return double The minimum value
|
||||
*/
|
||||
double min() const;
|
||||
/**
|
||||
* @brief Get the maximum value of the thermometer
|
||||
*
|
||||
* @return double The maximum value
|
||||
*/
|
||||
double max() const;
|
||||
|
||||
/**
|
||||
* @brief Set the start color object
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
void set_start_color(Color color);
|
||||
/**
|
||||
* @brief Set the end color object
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
void set_end_color(Color color);
|
||||
/**
|
||||
* @brief Add a color stop at the given value
|
||||
*
|
||||
* @param value The value at which to add the color stop
|
||||
* @param color The color of the stop
|
||||
*/
|
||||
void add_color_stop(double value, Color color);
|
||||
/**
|
||||
* @brief Add a normalized color stop at the given value
|
||||
*
|
||||
* @param value The normalized value (0.0 to 1.0) at which to add the color stop
|
||||
* @param color The color of the stop
|
||||
*/
|
||||
void add_color_stop_normalized(double value, Color color);
|
||||
/**
|
||||
* @brief Remove the color stop at the given value
|
||||
*
|
||||
* @param value The value of the color stop to remove
|
||||
*/
|
||||
void remove_color_stop(double value);
|
||||
/**
|
||||
* @brief Remove the normalized color stop at the given value
|
||||
*
|
||||
* @param value The normalized value (0.0 to 1.0) of the color stop to remove
|
||||
*/
|
||||
void remove_color_stop_normalized(double value);
|
||||
|
||||
/**
|
||||
* @brief Deserialize the thermometer from JSON
|
||||
*
|
||||
* @param j The JSON object
|
||||
*/
|
||||
void from_json(const json &j) override;
|
||||
/**
|
||||
* @brief Serialize the thermometer to JSON
|
||||
*
|
||||
* @param id The id of the thermometer
|
||||
* @return json The JSON representation of the thermometer
|
||||
*/
|
||||
json to_json(size_t id) const override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user