00001 00034 #include "oldgcccompat.h" // Compatibilty macros for GCC < 4.7 00035 00036 #include <boost/thread.hpp> 00037 #include <QObject> 00038 #include <QFuture> 00039 #include <QSystemTrayIcon> 00040 #include <QWidget> 00041 00042 #ifndef DESKTOPALARMWIDGET_H 00043 #define DESKTOPALARMWIDGET_H 00044 00045 class QMenu; // Forward declarations 00046 class QAction; 00047 00048 namespace AlarmNotifications 00049 { 00050 00051 class AlarmServerConnector; // Forward declaration 00052 00053 00059 class DesktopAlarmWidget : public QWidget 00060 { 00061 Q_OBJECT 00062 public: 00068 enum DesktopAlarmWidgetStatus 00069 { 00075 ActiveOK = 0, 00081 ActiveAlarm = 1, 00087 Disabled = 2 00088 }; 00089 private: 00095 const bool _activateBeedo; 00103 AlarmServerConnector* _asc; 00104 00110 bool _run; 00116 bool _alarmActive; 00122 QFuture<void> _iconThread; 00128 boost::mutex _ascmutex; 00129 00136 virtual void createContextMenu() = 0; 00143 void observeAlarmStatus(); 00144 signals: 00151 void alarmStatusChanged ( ); 00159 void notificationSwitchChanged ( bool enabled ); 00160 protected slots: 00167 void toggleNotifications(); 00174 void exitApplication(); 00181 virtual void changeTrayIcon () = 0; 00188 void configureNotificationTimeout(); 00196 virtual void notificationSwitchChange ( bool enabled ) = 0; 00197 protected: 00204 inline bool getAlarmActive() const noexcept 00205 { 00206 return _alarmActive; 00207 } 00214 DesktopAlarmWidgetStatus getStatus() const noexcept; 00221 void showStatusMessage (); 00222 public: 00229 DesktopAlarmWidget ( const bool activateBeedo = false ); 00235 virtual ~DesktopAlarmWidget(); 00242 DesktopAlarmWidget ( const DesktopAlarmWidget& other ) = delete; 00249 DesktopAlarmWidget ( DesktopAlarmWidget&& other ) = delete; 00257 DesktopAlarmWidget& operator= ( const DesktopAlarmWidget& other ) = delete; 00265 DesktopAlarmWidget& operator= ( DesktopAlarmWidget&& other ) = delete; 00266 }; 00267 00268 } 00269 #endif // DESKTOPALARMWIDGET_H