Debian Codegraph @

src/librssguard/gui/notifications/toastnotificationsmanager.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef TOASTNOTIFICATIONSMANAGER_H
4 #define TOASTNOTIFICATIONSMANAGER_H
5
6 #include "miscellaneous/application.h"
7
8 #include <QObject>
9
10 class BaseToastNotification;
11 class ToastNotification;
12 class ArticleListNotification;
13 class QScreen;
14
15 class ToastNotificationsManager : public QObject {
16 Q_OBJECT
17
18 public:
19 enum NotificationPosition {
20 TopLeft = 0,
21 TopRight = 1,
22 BottomLeft = 2,
23 BottomRight = 3
24 };
25
26 Q_ENUM(NotificationPosition)
27
28 static QString textForPosition(ToastNotificationsManager::NotificationPosition pos);
29
30 explicit ToastNotificationsManager(QObject* parent = nullptr);
31 virtual ~ToastNotificationsManager();
32
33 QList<BaseToastNotification*> activeNotifications() const;
34
35 // Screen ID, setting this to -1 means using default/primary
36 // monitor.
37 int screen() const;
38 void setScreen(int screen);
39
40 NotificationPosition position() const;
41 void setPosition(NotificationPosition position);
42
43 void resetNotifications(bool reload_existing_notifications);
44
45 public slots:
46 void clear(bool delete_from_memory);
47 void showNotification(Notification::Event event, const GuiMessage& msg, const GuiAction& action = {});
48
49 private slots:
50 void closeNotification(BaseToastNotification* notif, bool delete_from_memory);
51
52 signals:
53 void openingArticleInArticleListRequested(Feed* feed, const Message& msg);
54 void reloadMessageListRequested(bool mark_selected_messages_read);
55
56 private:
57 QScreen* activeScreen() const;
58 QScreen* moveToProperScreen(BaseToastNotification* notif);
59 QPoint cornerForNewNotification(QRect screen_rect);
60
61 void processNotification(BaseToastNotification* notif);
62 void initializeArticleListNotification();
63 void hookNotification(BaseToastNotification* notif);
64 void moveNotificationToCorner(BaseToastNotification* notif, QPoint corner);
65 void makeSpaceForNotification(int height_to_make_space, bool reverse = false, int stard_idx = 0);
66 void removeOutOfBoundsNotifications(int height_to_reserve);
67
68 private:
69 NotificationPosition m_position;
70 int m_screen;
71 int m_margins;
72 int m_width;
73 double m_opacity;
74
75 // List of all displayed notifications, newest notifications are in the beginning of the list
76 // and oldest at the end.
77 QList<BaseToastNotification*> m_activeNotifications;
78
79 ArticleListNotification* m_articleListNotification;
80 };
81
82 #endif // TOASTNOTIFICATIONSMANAGER_H