1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QSYSTEMTRAYICON_H |
5 | #define QSYSTEMTRAYICON_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtCore/qobject.h> |
9 | |
10 | #ifndef QT_NO_SYSTEMTRAYICON |
11 | |
12 | #include <QtGui/qicon.h> |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | |
17 | class QSystemTrayIconPrivate; |
18 | |
19 | class ; |
20 | class QEvent; |
21 | class QWheelEvent; |
22 | class QMouseEvent; |
23 | class QPoint; |
24 | |
25 | class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject |
26 | { |
27 | Q_OBJECT |
28 | Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip) |
29 | Q_PROPERTY(QIcon icon READ icon WRITE setIcon) |
30 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false) |
31 | |
32 | public: |
33 | QSystemTrayIcon(QObject *parent = nullptr); |
34 | QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr); |
35 | ~QSystemTrayIcon(); |
36 | |
37 | enum ActivationReason { |
38 | Unknown, |
39 | Context, |
40 | DoubleClick, |
41 | Trigger, |
42 | MiddleClick |
43 | }; |
44 | |
45 | #if QT_CONFIG(menu) |
46 | void (QMenu *); |
47 | QMenu *() const; |
48 | #endif |
49 | |
50 | QIcon icon() const; |
51 | void setIcon(const QIcon &icon); |
52 | |
53 | QString toolTip() const; |
54 | void setToolTip(const QString &tip); |
55 | |
56 | static bool isSystemTrayAvailable(); |
57 | static bool supportsMessages(); |
58 | |
59 | enum MessageIcon { NoIcon, Information, Warning, Critical }; |
60 | |
61 | QRect geometry() const; |
62 | bool isVisible() const; |
63 | |
64 | public Q_SLOTS: |
65 | void setVisible(bool visible); |
66 | inline void show() { setVisible(true); } |
67 | inline void hide() { setVisible(false); } |
68 | void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs = 10000); |
69 | void showMessage(const QString &title, const QString &msg, |
70 | QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int msecs = 10000); |
71 | |
72 | Q_SIGNALS: |
73 | void activated(QSystemTrayIcon::ActivationReason reason); |
74 | void messageClicked(); |
75 | |
76 | protected: |
77 | bool event(QEvent *event) override; |
78 | |
79 | private: |
80 | Q_DISABLE_COPY(QSystemTrayIcon) |
81 | Q_DECLARE_PRIVATE(QSystemTrayIcon) |
82 | |
83 | Q_PRIVATE_SLOT(d_func(), void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason)) |
84 | |
85 | friend class QSystemTrayIconSys; |
86 | friend class QBalloonTip; |
87 | }; |
88 | |
89 | QT_END_NAMESPACE |
90 | |
91 | #endif // QT_NO_SYSTEMTRAYICON |
92 | #endif // QSYSTEMTRAYICON_H |
93 | |