diff options
author | bd <bdunahu@operationnull.com> | 2025-04-19 15:14:56 -0400 |
---|---|---|
committer | bd <bdunahu@operationnull.com> | 2025-04-19 15:14:56 -0400 |
commit | 2b5ca09c90c5e091c094e9ed8f02079674b8aeda (patch) | |
tree | 227821d3d081d211e5e27c0eb7358061ed24a686 /gui/digitlabel.cc | |
parent | c375eba808841797a7339afcfe9c4426da53de75 (diff) |
Add new widget to display number in base 10 and 16
Diffstat (limited to 'gui/digitlabel.cc')
-rw-r--r-- | gui/digitlabel.cc | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gui/digitlabel.cc b/gui/digitlabel.cc new file mode 100644 index 0000000..a5c84f1 --- /dev/null +++ b/gui/digitlabel.cc @@ -0,0 +1,39 @@ +#include "digitlabel.h" + +DigitLabel::DigitLabel(QWidget *parent) : QLabel(parent) +{ + this->update_display(); +} + +void DigitLabel::clear() +{ + this->is_cleared = true; + setText(QString()); +} + +void DigitLabel::set_value(int v) +{ + this->is_cleared = false; + if (this->v != v) { + this->v = v; + update_display(); + } +} + +void DigitLabel::toggle_mode() +{ + this->is_hex = !this->is_hex; + this->update_display(); +} + +void DigitLabel::update_display() +{ + QString t; + if (this->is_cleared) { + setText(QString()); + } else { + t = (this->is_hex) ? QString::number(this->v, 6).toUpper() + : QString::number(this->v); + setText(t); + } +} |