-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuttonwidget.h
50 lines (40 loc) · 1.36 KB
/
buttonwidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef BUTTONWIDGET_H
#define BUTTONWIDGET_H
#include <QPushButton>
#include <list>
#include "visualizationwidget.h"
/**
* The ButtonWidget is used to handle button input from an array of buttons
* and holds a bitwise state per button. This value can be redirected to
* the stubserver.
* <P>
* The button itself is not created here, but in a parent class. The parent
* must connect the public slots of this class.
*/
class ButtonWidget : public QWidget, public VisualizationWidget
{
Q_OBJECT
uint64_t buttonState;
std::list<QPushButton*> buttons;
public:
explicit ButtonWidget(QWidget *parent);
/**
* Register a button: this can be used to be able to set the button labels if necessary.
* The method must be called before 'setLabels'.
*/
void addButton(QPushButton* btn) {
buttons.push_back(btn);
}
/**
* Sets the buttons labels from one string (splits the string into single labels).
* @param label - label string with spaces as separator, '_' will be blank in the label
*/
void setLabels(const std::string &label) const;
//----- derived from VisualizationClient
virtual bool useAsInputSource(unsigned sensorNo) const override;
virtual int64_t getInputState(unsigned sensorNo) const override;
public slots:
void buttonDown(int);
void buttonUp(int);
};
#endif // BUTTONWIDGET_H