From 9836d40a49f72ef9be094b9f45157296d45d654c Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Sat, 25 Oct 2025 08:23:56 +0200 Subject: [PATCH] Add doxygen documentation to client ui --- client/ui/better_radiobutton.hpp | 30 +++++++++++++++++++- client/ui/can_transceive.hpp | 47 ++++++++++++++++++++++++++++++++ client/ui/hex_spinbox.cpp | 6 +++- client/ui/hex_spinbox.hpp | 26 +++++++++++++++++- client/ui/led.hpp | 34 +++++++++++++++++++++++ client/ui/plot_wrapper.hpp | 11 ++++++++ 6 files changed, 151 insertions(+), 3 deletions(-) diff --git a/client/ui/better_radiobutton.hpp b/client/ui/better_radiobutton.hpp index 103d7c1..26f1c30 100644 --- a/client/ui/better_radiobutton.hpp +++ b/client/ui/better_radiobutton.hpp @@ -6,13 +6,41 @@ class Better_Radiobutton : public QWidget { Q_OBJECT public: + /** + * @brief Construct a new Better_Radiobutton object + * + * @param parent A pointer to the parent widget + */ explicit Better_Radiobutton(QWidget *parent = nullptr); - explicit Better_Radiobutton(std::vector names, QWidget *partent = nullptr); + /** + * @brief Construct a new Better_Radiobutton object + * + * @param names A list of names for the radiobuttons + * @param parent A pointer to the parent widget + */ + explicit Better_Radiobutton(std::vector names, QWidget *parent = nullptr); + /** + * @brief Add a radiobutton to the group + * + * @param name The name of the radiobutton + */ void add_radiobutton(QString name); + + /** + * @brief Get the name of the currently checked radiobutton + * + * @return QString The name of the checked radiobutton + */ QString isChecked() const; signals: + /** + * @brief Emitted when a radiobutton is toggled + * + * @param name The name of the radiobutton + * @param checked Whether the radiobutton is checked + */ void toggled(QString name, bool checked); private: diff --git a/client/ui/can_transceive.hpp b/client/ui/can_transceive.hpp index 8798b65..bdbd059 100644 --- a/client/ui/can_transceive.hpp +++ b/client/ui/can_transceive.hpp @@ -12,15 +12,62 @@ class Can_Transceive : public QWidget Q_OBJECT public: + /** + * @brief Construct a new Can_Transceive object + * + * @param parent A pointer to the parent widget + */ explicit Can_Transceive(QWidget *parent = nullptr); + /** + * @brief Destroy the Can_Transceive object + * + */ ~Can_Transceive(); + + /** + * @brief This function enables or disables the CAN data input fields based on the selected DLC + * + */ void enable_can_send_data(); + + /** + * @brief Clear the CAN message lists + * + */ void clear(); + + /** + * @brief Add a sent CAN message to the send list + * + * @param id The CAN message ID + * @param dlc The Data Length Code + * @param payload The CAN message payload + */ void add_send_item(uint32_t id, uint8_t dlc, std::array payload); + + /** + * @brief Add a received CAN message to the receive list + * + * @param id The CAN message ID + * @param dlc The Data Length Code + * @param payload The CAN message payload + */ void add_receive_item(uint32_t id, uint8_t dlc, std::array payload); signals: + /** + * @brief Emitted when a CAN message is to be sent + * + * @param id The CAN message ID + * @param dlc The Data Length Code + * @param payload The CAN message payload + */ void send_can_message(uint32_t id, uint8_t dlc, std::array payload); + + /** + * @brief Emitted when the CAN message lists are to be cleared + * + */ void can_clear(); private: diff --git a/client/ui/hex_spinbox.cpp b/client/ui/hex_spinbox.cpp index 2dcee28..5e51f25 100644 --- a/client/ui/hex_spinbox.cpp +++ b/client/ui/hex_spinbox.cpp @@ -1,6 +1,10 @@ #include "hex_spinbox.hpp" -HexSpinBox::HexSpinBox(QWidget *parent, bool showPrefix, const QString &format) : QSpinBox(parent), format(format) +HexSpinBox::HexSpinBox(QWidget *parent) : HexSpinBox(false, QStringLiteral("%X"), parent) +{ +} + +HexSpinBox::HexSpinBox(bool showPrefix, const QString &format, QWidget *parent) : QSpinBox(parent), format(format) { // Validates hex strings up to 8 chars with or w/out leading "0x" prefix. // For arbitrary prefix/suffix, the regex could be built dynamically diff --git a/client/ui/hex_spinbox.hpp b/client/ui/hex_spinbox.hpp index 627c051..33f4f9c 100644 --- a/client/ui/hex_spinbox.hpp +++ b/client/ui/hex_spinbox.hpp @@ -11,10 +11,34 @@ class HexSpinBox : public QSpinBox Q_OBJECT public: - HexSpinBox(QWidget *parent = nullptr, bool showPrefix = false, const QString &format = QStringLiteral("%X")); + /** + * @brief Construct a new Hex Spin Box object + * + * @param parent The parent QWidget + */ + explicit HexSpinBox(QWidget *parent = nullptr); + /** + * @brief Construct a new Hex Spin Box object + * + * @param showPrefix Whether to show the "0x" prefix + * @param format The printf-style format string to use for displaying the value + * @param parent The parent QWidget + */ + HexSpinBox(bool showPrefix = false, const QString &format = QStringLiteral("%X"), QWidget *parent = nullptr); public slots: + /** + * @brief Set the Show Prefix object + * + * @param show True to show the "0x" prefix, false to hide it + */ void setShowPrefix(bool show); + + /** + * @brief Set the Format object + * + * @param text The printf-style format string to use for displaying the value + */ void setFormat(const QString &text); protected: diff --git a/client/ui/led.hpp b/client/ui/led.hpp index 29293db..a652f82 100644 --- a/client/ui/led.hpp +++ b/client/ui/led.hpp @@ -5,12 +5,46 @@ class Led : public QPushButton { Q_OBJECT public: + /** + * @brief Construct a new Led object + * + * @param parent The parent widget + */ explicit Led(QWidget *parent = nullptr); + + /** + * @brief Construct a new Led object + * + * @param text The text to display on the button + * @param parent The parent widget + */ explicit Led(const QString &text, QWidget *parent = nullptr); + + /** + * @brief Construct a new Led object + * + * @param icon The icon to display on the button + * @param text The text to display on the button + * @param parent The parent widget + */ Led(const QIcon &icon, const QString &text, QWidget *parent = nullptr); ~Led(); private: + /** + * @brief Check if the widget is read-only + * + * @param widget The widget to check + * @return true If the widget is read-only + * @return false If the widget is not read-only + */ bool is_read_only(QWidget *widget); + + /** + * @brief Set the read-only state of the widget + * + * @param widget The widget to set + * @param read_only The read-only state to set + */ void set_read_only(QWidget *widget, bool read_only); }; diff --git a/client/ui/plot_wrapper.hpp b/client/ui/plot_wrapper.hpp index 13f31aa..9830d4d 100644 --- a/client/ui/plot_wrapper.hpp +++ b/client/ui/plot_wrapper.hpp @@ -8,7 +8,18 @@ class Plot_wrapper : public QwtPlot { Q_OBJECT public: + /** + * @brief Construct a new Plot_wrapper object + * + * @param parent The parent QWidget + */ Plot_wrapper(QWidget *parent = nullptr); + + /** + * @brief Get the curve associated with the plot + * + * @return QwtPlotCurve* + */ QwtPlotCurve *curve() const; private: