AlarmNotifications
PANDA Slow Control Alarm Daemon
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
desktopalarmwidget.h
Go to the documentation of this file.
1 
34 #include "oldgcccompat.h" // Compatibilty macros for GCC < 4.7
35 
36 #include <boost/thread.hpp>
37 #include <QObject>
38 #include <QFuture>
39 #include <QSystemTrayIcon>
40 #include <QWidget>
41 
42 #ifndef DESKTOPALARMWIDGET_H
43 #define DESKTOPALARMWIDGET_H
44 
45 class QMenu; // Forward declarations
46 class QAction;
47 
48 namespace AlarmNotifications
49 {
50 
51 class AlarmServerConnector; // Forward declaration
52 
53 
59 class DesktopAlarmWidget : public QWidget
60 {
61  Q_OBJECT
62 public:
69  {
75  ActiveOK = 0,
88  };
89 private:
95  const bool _activateBeedo;
104 
110  bool _run;
122  QFuture<void> _iconThread;
128  boost::mutex _ascmutex;
129 
136  virtual void createContextMenu() = 0;
143  void observeAlarmStatus();
144 signals:
151  void alarmStatusChanged ( );
159  void notificationSwitchChanged ( bool enabled );
160 protected slots:
167  void toggleNotifications();
174  void exitApplication();
181  virtual void changeTrayIcon () = 0;
196  virtual void notificationSwitchChange ( bool enabled ) = 0;
197 protected:
204  inline bool getAlarmActive() const noexcept
205  {
206  return _alarmActive;
207  }
221  void showStatusMessage ();
222 public:
229  DesktopAlarmWidget ( const bool activateBeedo = false );
235  virtual ~DesktopAlarmWidget();
242  DesktopAlarmWidget ( const DesktopAlarmWidget& other ) = delete;
249  DesktopAlarmWidget ( DesktopAlarmWidget&& other ) = delete;
257  DesktopAlarmWidget& operator= ( const DesktopAlarmWidget& other ) = delete;
265  DesktopAlarmWidget& operator= ( DesktopAlarmWidget&& other ) = delete;
266 };
267 
268 }
269 #endif // DESKTOPALARMWIDGET_H
void exitApplication()
Close the desktop widget.
void configureNotificationTimeout()
Change timespan between alarm trigger and notification display.
void observeAlarmStatus()
Thread to periodically check the status.
DesktopAlarmWidgetStatus
Status of the desktop widget.
void toggleNotifications()
Toggles the "main switch".
void alarmStatusChanged()
Alarm has been triggered or acknowledged.
virtual void notificationSwitchChange(bool enabled)=0
React on widget enable/disable.
Abstract base class for desktop alarm widgets.
Compatibility macros for older versions of the GCC.
boost::mutex _ascmutex
Protect access to the _asc pointer.
bool getAlarmActive() const noexcept
Show alarm active flag to derived class.
virtual void createContextMenu()=0
Abstract context menu method.
void showStatusMessage()
Show status dialog box.
Namespace for Alarm Notifications application.
void notificationSwitchChanged(bool enabled)
Widget has been enabled or disabled.
DesktopAlarmWidgetStatus getStatus() const noexcept
Query alarm status.
QFuture< void > _iconThread
Alarm status observer thread.
#define noexcept
Allow using the noexcept keyword with GCC < 4.6.
Definition: oldgcccompat.h:52
virtual void changeTrayIcon()=0
Change the tray icon due to status change.
AlarmServerConnector * _asc
Pointer to the AlarmServerConnector instance.
const bool _activateBeedo
Beedo activation flag.