diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-02-10 09:06:26 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2020-02-10 09:06:26 -0600 |
commit | 8f528ffcdb4ce2f27a015fe7f0867e71a444d614 (patch) | |
tree | c2e9da57ba9fb3aaee1bad4c61b61a00de48981b | |
parent | 89934d31b65f070b1954ae2f6201841bfd90d3e2 (diff) | |
download | horizon-8f528ffcdb4ce2f27a015fe7f0867e71a444d614.tar.gz horizon-8f528ffcdb4ce2f27a015fe7f0867e71a444d614.tar.bz2 horizon-8f528ffcdb4ce2f27a015fe7f0867e71a444d614.tar.xz horizon-8f528ffcdb4ce2f27a015fe7f0867e71a444d614.zip |
Qt 5: Small tweaks to SubnetBox
* Add setSubnetCIDR, to programmatically change the value.
* Add signal for when the value changes.
* Ensure the proper amount of .0 octets are appended when the spinbox changes.
-rw-r--r-- | ui/qt5/subnetbox.cc | 11 | ||||
-rw-r--r-- | ui/qt5/subnetbox.hh | 4 |
2 files changed, 15 insertions, 0 deletions
diff --git a/ui/qt5/subnetbox.cc b/ui/qt5/subnetbox.cc index 54f1732..071cec8 100644 --- a/ui/qt5/subnetbox.cc +++ b/ui/qt5/subnetbox.cc @@ -40,10 +40,16 @@ int SubnetBox::subnetCIDR(void) const { return cidr->value(); } +void SubnetBox::setSubnetCIDR(int value) { + cidr->setValue(value); + cidrEdited(value); +} + void SubnetBox::subnetEdited(const QString &text) { int value = subnet_mask_to_cidr(text.toUtf8()); if(value > 0) { cidr->setValue(value); + emit valueChanged(value); } } @@ -60,6 +66,11 @@ void SubnetBox::cidrEdited(int value) { } snprintf(temp, 4, "%d", lastfilled); data.append(temp); + for(int i = 3; i > bytes; i--) { + data.append(".0"); + } subnet->setText(data); + + emit valueChanged(value); } diff --git a/ui/qt5/subnetbox.hh b/ui/qt5/subnetbox.hh index 9f2edbf..8104a6b 100644 --- a/ui/qt5/subnetbox.hh +++ b/ui/qt5/subnetbox.hh @@ -26,11 +26,15 @@ public: SubnetBox(QWidget *parent = nullptr); QString subnetMask() const; int subnetCIDR() const; + void setSubnetCIDR(int value); public slots: void subnetEdited(const QString &text); void cidrEdited(int value); +signals: + void valueChanged(int value); + private: QHBoxLayout *layout; QLineEdit *subnet; |