2021-05-20 10:02:10 +02:00
|
|
|
// For license of this file, see <project-root-folder>/LICENSE.md.
|
|
|
|
|
|
|
|
#ifndef NOTIFICATION_H
|
|
|
|
#define NOTIFICATION_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
|
2021-09-08 07:34:06 +02:00
|
|
|
#include "definitions/definitions.h"
|
|
|
|
|
2021-05-26 09:26:53 +02:00
|
|
|
class Application;
|
|
|
|
|
2021-05-20 10:02:10 +02:00
|
|
|
class Notification {
|
|
|
|
public:
|
|
|
|
enum class Event {
|
2021-06-17 07:07:51 +02:00
|
|
|
// Is here to provide "empty" events - events which should
|
|
|
|
// not trigger any notifications.
|
|
|
|
NoEvent = 0,
|
2021-06-15 15:02:14 +02:00
|
|
|
|
2021-06-18 13:42:31 +02:00
|
|
|
// Used for many events which happen throught application lifecycle.
|
|
|
|
GeneralEvent = 1,
|
|
|
|
|
2021-05-20 10:02:10 +02:00
|
|
|
// New (unread) messages were downloaded for some feed.
|
2021-06-28 10:08:39 +02:00
|
|
|
NewUnreadArticlesFetched = 2,
|
2021-05-20 10:02:10 +02:00
|
|
|
|
|
|
|
// RSS Guard started downloading messages for some feed.
|
2021-06-18 13:42:31 +02:00
|
|
|
ArticlesFetchingStarted = 3,
|
2021-05-20 10:02:10 +02:00
|
|
|
|
|
|
|
// Login tokens were successfuly refreshed.
|
|
|
|
// NOTE: This is primarily used in accounts which use
|
|
|
|
// OAuth or similar mechanism.
|
2021-06-15 15:02:14 +02:00
|
|
|
LoginDataRefreshed = 4,
|
|
|
|
|
2022-02-11 08:54:49 +01:00
|
|
|
// New RSS Guard version available.
|
2021-08-13 11:11:57 +02:00
|
|
|
NewAppVersionAvailable = 5,
|
|
|
|
|
2022-02-11 08:54:49 +01:00
|
|
|
// Some service failed to login.
|
|
|
|
LoginFailure = 6,
|
|
|
|
|
|
|
|
// Node.js - package updated.
|
|
|
|
NodePackageUpdated = 7,
|
|
|
|
|
|
|
|
// Node.js - package failde to update.
|
|
|
|
NodePackageFailedToUpdate = 8
|
2021-05-20 10:02:10 +02:00
|
|
|
};
|
|
|
|
|
2022-07-07 09:45:00 +02:00
|
|
|
explicit Notification(Event event = Event::NoEvent,
|
|
|
|
bool balloon = {},
|
|
|
|
const QString& sound_path = {},
|
2021-09-08 07:34:06 +02:00
|
|
|
int volume = DEFAULT_NOTIFICATION_VOLUME);
|
2021-06-17 07:07:51 +02:00
|
|
|
|
|
|
|
bool balloonEnabled() const;
|
2021-05-20 10:02:10 +02:00
|
|
|
|
|
|
|
Event event() const;
|
2021-09-07 09:30:24 +02:00
|
|
|
void setEvent(Event event);
|
|
|
|
|
|
|
|
int volume() const;
|
2022-07-07 09:45:00 +02:00
|
|
|
qreal fractionalVolume() const;
|
2021-09-07 09:30:24 +02:00
|
|
|
void setVolume(int volume);
|
2021-05-20 10:02:10 +02:00
|
|
|
|
|
|
|
// Returns full path to audio file which should be played when notification
|
|
|
|
// is launched.
|
|
|
|
// NOTE: This property supports "%data%" placeholder.
|
|
|
|
QString soundPath() const;
|
|
|
|
void setSoundPath(const QString& sound_path);
|
|
|
|
|
2021-05-26 09:26:53 +02:00
|
|
|
void playSound(Application* app) const;
|
|
|
|
|
2021-06-15 15:02:14 +02:00
|
|
|
static QList<Event> allEvents();
|
|
|
|
static QString nameForEvent(Event event);
|
|
|
|
|
2021-05-20 10:02:10 +02:00
|
|
|
private:
|
|
|
|
Event m_event;
|
2021-06-17 07:07:51 +02:00
|
|
|
bool m_balloonEnabled;
|
2021-05-20 10:02:10 +02:00
|
|
|
QString m_soundPath;
|
2022-07-07 09:45:00 +02:00
|
|
|
qreal m_volume;
|
2021-05-20 10:02:10 +02:00
|
|
|
};
|
|
|
|
|
2023-07-27 08:42:41 +02:00
|
|
|
Q_DECLARE_METATYPE(Notification::Event)
|
|
|
|
|
2021-05-20 10:02:10 +02:00
|
|
|
#endif // NOTIFICATION_H
|