NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
controlbutton.h
1 // Wrapper for QPushButton
2 // Executes attached service call
3 // Button becomes red/green which shows if service call was successfull
4 // Author: Dmytro Pavlichenko dm.mark999@gmail.com
5 
6 #ifndef CONTROLBUTTON_H
7 #define CONTROLBUTTON_H
8 
9 #include <QObject>
10 #include <QPushButton>
11 #include <QTimer>
12 
13 #include <ros/time.h>
14 #include <control_widget/service.h>
15 
16 namespace control_widget
17 {
18 
19 class ControlButton : public QObject
20 {
21 Q_OBJECT
22 public:
23  ControlButton(QPushButton *button_, service::Service *service_);
24  ControlButton(QPushButton *button_, std::string iconName, service::Service *service_);
25  ~ControlButton();
26 
27  void setStatus(bool success); // Makes button red/green for given highlightDuration
28 
29 Q_SIGNALS:
30  void feedback(QStringList&);
31 
32 private Q_SLOTS:
33  void handleClick();
34  void loop(); // Main loop. Is called every 1 second. Checks if its time to turn off the highlight
35 
36 private:
37  void init(QPushButton *button_, service::Service *service_);
38 
39 private:
40  QPushButton *button;
41  service::Service *service;
42 
43  QTimer *mainLoopTimer;
44  ros::Time activatedTime; // Time when button was clicked
45  bool higlightActive;
46 
47  static const int highlightDuration = 5; // How long the button is highlighted, seconds
48 };
49 
50 }
51 
52 #endif