From 0dddcd2ac81e06f983e1725b75b6339b56e1234f Mon Sep 17 00:00:00 2001 From: elecpower Date: Wed, 12 May 2021 08:45:14 +1000 Subject: [PATCH] Function to update all autowidgets --- companion/src/shared/autobitsetcheckbox.h | 2 +- companion/src/shared/autocheckbox.h | 2 +- companion/src/shared/autocombobox.h | 2 +- companion/src/shared/autodoublespinbox.h | 2 +- companion/src/shared/autohexspinbox.h | 2 +- companion/src/shared/autolabel.h | 2 +- companion/src/shared/autolineedit.h | 2 +- companion/src/shared/autoprecisioncombobox.h | 2 +- companion/src/shared/autoslider.h | 2 +- companion/src/shared/autospinbox.h | 2 +- companion/src/shared/autotimeedit.h | 2 +- companion/src/shared/autowidget.h | 2 ++ companion/src/shared/genericpanel.cpp | 11 +++++++++++ companion/src/shared/genericpanel.h | 1 + 14 files changed, 25 insertions(+), 11 deletions(-) diff --git a/companion/src/shared/autobitsetcheckbox.h b/companion/src/shared/autobitsetcheckbox.h index 6c3fef5c7..cf54bae85 100644 --- a/companion/src/shared/autobitsetcheckbox.h +++ b/companion/src/shared/autobitsetcheckbox.h @@ -24,7 +24,7 @@ #include -class AutoBitsetCheckBox: public QCheckBox, AutoWidget +class AutoBitsetCheckBox: public QCheckBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autocheckbox.h b/companion/src/shared/autocheckbox.h index 4f4e3c992..5eb0a3dfb 100644 --- a/companion/src/shared/autocheckbox.h +++ b/companion/src/shared/autocheckbox.h @@ -24,7 +24,7 @@ #include -class AutoCheckBox : public QCheckBox, AutoWidget +class AutoCheckBox : public QCheckBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autocombobox.h b/companion/src/shared/autocombobox.h index 5cecd3e70..1502a6176 100644 --- a/companion/src/shared/autocombobox.h +++ b/companion/src/shared/autocombobox.h @@ -26,7 +26,7 @@ #include -class AutoComboBox : public QComboBox, AutoWidget +class AutoComboBox : public QComboBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autodoublespinbox.h b/companion/src/shared/autodoublespinbox.h index fb3b26591..31eef93c4 100644 --- a/companion/src/shared/autodoublespinbox.h +++ b/companion/src/shared/autodoublespinbox.h @@ -28,7 +28,7 @@ #include #endif -class AutoDoubleSpinBox : public QDoubleSpinBox, AutoWidget +class AutoDoubleSpinBox : public QDoubleSpinBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autohexspinbox.h b/companion/src/shared/autohexspinbox.h index 440fb4740..6d7711c32 100644 --- a/companion/src/shared/autohexspinbox.h +++ b/companion/src/shared/autohexspinbox.h @@ -27,7 +27,7 @@ class QRegExpValidator; -class AutoHexSpinBox : public QSpinBox, AutoWidget +class AutoHexSpinBox : public QSpinBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autolabel.h b/companion/src/shared/autolabel.h index 1b31db024..369a1e680 100644 --- a/companion/src/shared/autolabel.h +++ b/companion/src/shared/autolabel.h @@ -24,7 +24,7 @@ #include -class AutoLabel: public QLabel, AutoWidget +class AutoLabel: public QLabel, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autolineedit.h b/companion/src/shared/autolineedit.h index 0820bc5dc..be1cccaa3 100644 --- a/companion/src/shared/autolineedit.h +++ b/companion/src/shared/autolineedit.h @@ -25,7 +25,7 @@ #include #include -class AutoLineEdit: public QLineEdit, AutoWidget +class AutoLineEdit: public QLineEdit, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autoprecisioncombobox.h b/companion/src/shared/autoprecisioncombobox.h index 7cebeaa36..b973c09fd 100644 --- a/companion/src/shared/autoprecisioncombobox.h +++ b/companion/src/shared/autoprecisioncombobox.h @@ -25,7 +25,7 @@ #include #include -class AutoPrecisionComboBox : public QComboBox, AutoWidget +class AutoPrecisionComboBox : public QComboBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autoslider.h b/companion/src/shared/autoslider.h index f83177c87..cb3a2fd11 100644 --- a/companion/src/shared/autoslider.h +++ b/companion/src/shared/autoslider.h @@ -24,7 +24,7 @@ #include -class AutoSlider : public QSlider, AutoWidget +class AutoSlider : public QSlider, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autospinbox.h b/companion/src/shared/autospinbox.h index a92d6db56..38842fbe0 100644 --- a/companion/src/shared/autospinbox.h +++ b/companion/src/shared/autospinbox.h @@ -24,7 +24,7 @@ #include -class AutoSpinBox : public QSpinBox, AutoWidget +class AutoSpinBox : public QSpinBox, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autotimeedit.h b/companion/src/shared/autotimeedit.h index e27607ce5..f398fd855 100644 --- a/companion/src/shared/autotimeedit.h +++ b/companion/src/shared/autotimeedit.h @@ -24,7 +24,7 @@ #include -class AutoTimeEdit : public QTimeEdit, AutoWidget +class AutoTimeEdit : public QTimeEdit, public AutoWidget { Q_OBJECT diff --git a/companion/src/shared/autowidget.h b/companion/src/shared/autowidget.h index 9680726b7..820befbdc 100644 --- a/companion/src/shared/autowidget.h +++ b/companion/src/shared/autowidget.h @@ -25,6 +25,8 @@ class GenericPanel; // Note: cannot be a Qt object otherwise it will create a compiler ambiguity in the inheriting class class AutoWidget { + friend class GenericPanel; + public: explicit AutoWidget(); ~AutoWidget(); diff --git a/companion/src/shared/genericpanel.cpp b/companion/src/shared/genericpanel.cpp index 5dfad648e..a60ed0cf0 100644 --- a/companion/src/shared/genericpanel.cpp +++ b/companion/src/shared/genericpanel.cpp @@ -19,6 +19,7 @@ */ #include "genericpanel.h" +#include "autowidget.h" #include #include @@ -127,3 +128,13 @@ void GenericPanel::disableMouseScrolling() foreach(QWidget * te, findChildren()) setFocusFilter(te); } + +void GenericPanel::updateAutoWidgets() +{ + foreach(QWidget *wdgt, findChildren()) { + AutoWidget *autowdgt = dynamic_cast(wdgt); + if (autowdgt) { + autowdgt->updateValue(); + } + } +} diff --git a/companion/src/shared/genericpanel.h b/companion/src/shared/genericpanel.h index f013584bd..32dfdadc8 100644 --- a/companion/src/shared/genericpanel.h +++ b/companion/src/shared/genericpanel.h @@ -58,4 +58,5 @@ class GenericPanel : public QWidget virtual bool eventFilter(QObject *obj, QEvent *event); void setFocusFilter(QWidget * w); void disableMouseScrolling(); + void updateAutoWidgets(); };