1 // For license of this file, see <project-root-folder>/LICENSE.md. 2 3 #ifndef NOTIFICATION_H 4 #define NOTIFICATION_H 5 6 #include <QString> 7 8 #include "definitions/definitions.h" 9 10 class Application; 11 12 class Notification { 13 public: 14 enum class Event { 15 // Is here to provide "empty" events - events which should 16 // not trigger any notifications. 17 NoEvent = 0, 18 19 // Used for many events which happen throught application lifecycle. 20 GeneralEvent = 1, 21 22 // New (unread) messages were downloaded for some feed. 23 NewUnreadArticlesFetched = 2, 24 25 // RSS Guard started downloading messages for some feed. 26 ArticlesFetchingStarted = 3, 27 28 // Login tokens were successfuly refreshed. 29 // NOTE: This is primarily used in accounts which use 30 // OAuth or similar mechanism. 31 LoginDataRefreshed = 4, 32 33 NewAppVersionAvailable = 5, 34 35 LoginFailure = 6 36 }; 37 38 explicit Notification(Event event = Event::NoEvent, bool balloon = {}, const QString& sound_path = {}, 39 int volume = DEFAULT_NOTIFICATION_VOLUME); 40 41 bool balloonEnabled() const; 42 43 Event event() const; 44 void setEvent(Event event); 45 46 int volume() const; 47 void setVolume(int volume); 48 49 // Returns full path to audio file which should be played when notification 50 // is launched. 51 // NOTE: This property supports "%data%" placeholder. 52 QString soundPath() const; 53 void setSoundPath(const QString& sound_path); 54 55 void playSound(Application* app) const; 56 57 static QList<Event> allEvents(); 58 static QString nameForEvent(Event event); 59 60 private: 61 Event m_event; 62 bool m_balloonEnabled; 63 QString m_soundPath; 64 int m_volume; 65 }; 66 67 #endif // NOTIFICATION_H 68