40class QeLedArray :
public QWidget
94 enum class SignalType {NONE, WARNING, CRITICAL, INFO};
97 explicit QeLedArray(QWidget* parent =
nullptr);
98 explicit QeLedArray(
int led_count, QWidget* parent =
nullptr);
99 explicit QeLedArray(
const QList<QString>&
labels,
const QList<SignalType>& signal_roles, QWidget* parent =
nullptr);
104 bool IsVertical(){
return m_vertical; }
105 bool AreLabelsVisible(){
return m_labels_visible; }
106 int GetLedsCount(){
return m_leds_count; }
107 QStringList GetStates()
const {
return m_states; }
113 QList<QString> GetLabels(){
return m_labels; }
114 QStringList GetSignalTypes(){
return m_signal_types; }
121 void SetLedType(
QeLed* led, SignalType type);
145 void SetLabel(
int index, QString label_text);
152 void SetState(
int index,
bool state);
163 void SetVertical(
bool new_value) {
164 if(new_value == this->m_vertical)
167 this->m_vertical = new_value;
173 void SetLabelsVisibility(
bool new_value) {
174 if(new_value == this->m_labels_visible)
177 this->m_labels_visible = new_value;
178 this->ChangeLabelsVisibility(this->m_labels_visible);
182 void SetLedsCount(
int new_value){
183 if(new_value == this->m_leds_count)
186 this->m_leds_count = new_value;
190 for(QeLed *led : m_leds_list){
191 m_layout->removeWidget(led);
198 this->RebuildArray();
203 void SetStates(
const QStringList &
states);
205 void SetStates(
int int_value);
207 void SetStates(std::vector<bool> bool_states_list);
209 void SetLabels(QList<QString>
labels);
276 void AddToLayout(
QeLed *led, QLabel *label,
int index);
282 void InitLedColorsMap();
293 void Init(std::optional<
const QList<QString>>
labels = std::nullopt,
294 std::optional<
const QList<SignalType>> signal_roles = std::nullopt);
296 static std::vector<bool> IntToBits(
int value,
int num_bits);
304 void ChangeLabelsVisibility(
bool is_visible);
314 bool Value(
const std::vector<bool> &vec,
size_t index,
bool default_value =
false);
317 bool m_vertical =
false;
318 bool m_labels_visible =
true;
319 int m_leds_count = 4;
320 QList<QString> m_labels;
321 QList<QLabel*> m_labels_list;
323 QList<QeLed*> m_leds_list;
324 QGridLayout* m_layout =
nullptr;
326 QStringList m_states;
327 std::vector<bool> m_bool_states_vector;
329 QStringList m_signal_types;
330 QList<SignalType> m_signal_types_list;
332 QColor warning_color = QColor(255,165,0);
333 QColor critical_color = QColor(255,0,0);
334 QColor info_color = QColor(0,0,255);
335 QColor none_color = QColor(169,169,169);
337 using OnOffMap = QMap<QString, QColor>;
338 using LedColorMap = QMap<SignalType, OnOffMap>;
339 LedColorMap m_led_color_map;
void SetSignalType(int index, SignalType signal_type)
SetSignalType Sets signal type associated with the LED.
Definition QeLedArray.cpp:462
void SetLabel(int index, QString label_text)
SetLabel Sets label under specific index.
Definition QeLedArray.cpp:436
void SetState(int index, bool state)
SetState Sets state of a single LED.
Definition QeLedArray.cpp:448
void SetSignalTypes(const QList< SignalType > &signal_types)
SetSignalTypes method to set signal types using enum values of SignalType type.
Definition QeLedArray.cpp:418