Debian Codegraph @

src/librssguard/gui/systemtrayicon.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef SYSTEMTRAYICON_H
4 #define SYSTEMTRAYICON_H
5
6 #include "definitions/definitions.h"
7
8 #include <functional>
9
10 #include <QMenu>
11 #include <QPixmap>
12 #include <QSystemTrayIcon>
13 #include <QTimer>
14
15 class FormMain;
16 class QEvent;
17
18 #if defined(Q_OS_WIN)
19
20 class TrayIconMenu : public QMenu {
21 Q_OBJECT
22
23 public:
24 // Constructors and destructors.
25 explicit TrayIconMenu(const QString& title, QWidget* parent);
26
27 protected:
28 bool event(QEvent* event);
29 };
30
31 #endif
32
33 class SystemTrayIcon : public QSystemTrayIcon {
34 Q_OBJECT
35
36 public:
37 // Constructors and destructors.
38 explicit SystemTrayIcon(const QString& normal_icon, const QString& plain_icon, FormMain* parent = nullptr);
39 virtual ~SystemTrayIcon();
40
41 // Sets the number to be visible in the tray icon, number <= 0 removes it.
42 void setNumber(int number = -1, bool any_feed_has_new_unread_messages = false);
43
44 void showMessage(const QString& title,
45 const QString& message,
46 MessageIcon icon = Information,
47 int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT,
48 const std::function<void()>& functor = nullptr);
49
50 // Returns true if tray area is available and icon can be displayed.
51 static bool isSystemTrayAreaAvailable();
52
53 // Returns true if user wants to have tray icon displayed.
54 static bool isSystemTrayDesired();
55
56 public slots:
57 void show();
58
59 private slots:
60 void showPrivate();
61 void onActivated(QSystemTrayIcon::ActivationReason reason);
62
63 signals:
64 void shown();
65
66 private:
67 QIcon m_normalIcon;
68 QPixmap m_plainPixmap;
69 QFont m_font = QFont();
70 QTimer m_tmrDoubleFire;
71
72 QMetaObject::Connection m_connection;
73 };
74
75 #endif // SYSTEMTRAYICON_H