From 2b5ca09c90c5e091c094e9ed8f02079674b8aeda Mon Sep 17 00:00:00 2001 From: bd Date: Sat, 19 Apr 2025 15:14:56 -0400 Subject: Add new widget to display number in base 10 and 16 --- gui/digitlabel.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 gui/digitlabel.h (limited to 'gui/digitlabel.h') diff --git a/gui/digitlabel.h b/gui/digitlabel.h new file mode 100644 index 0000000..9106cc9 --- /dev/null +++ b/gui/digitlabel.h @@ -0,0 +1,52 @@ +#ifndef DIGITLABEL_H +#define DIGITLABEL_H + +#include + +class DigitLabel : public QLabel +{ + Q_OBJECT + + public: + /** + * Constructor. + * @return a newly allocated DigitLabel. + */ + explicit DigitLabel(QWidget *parent = nullptr); + + /** + * Sets the empty flag. + */ + void clear(); + /** + * @param the value to set `this->v' with. + */ + void set_value(int v); + + public slots: + /** + * Toggles the base this label displays in, by setting `this->is_hex'. + */ + void toggle_mode(); + + private: + /** + * Refreshes the display of this label, taking base into consideration.. + */ + void update_display(); + + /** + * The decimal value associated with this label. + */ + int v = 0; + /** + * To display in hexidecimal or not. + */ + bool is_hex = true; + /** + * To display in hexidecimal or not. + */ + bool is_cleared = true; +}; + +#endif // DIGITLABEL_H -- cgit v1.2.3