Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsystemtrayicon.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QSYSTEMTRAYICON_H
6#define QSYSTEMTRAYICON_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtCore/qobject.h>
10
11#ifndef QT_NO_SYSTEMTRAYICON
12
13#include <QtGui/qicon.h>
14
15QT_BEGIN_NAMESPACE
16
17
18class QSystemTrayIconPrivate;
19
20class QMenu;
21class QEvent;
22class QWheelEvent;
23class QMouseEvent;
24class QPoint;
25
26class Q_WIDGETS_EXPORT QSystemTrayIcon : public QObject
27{
28 Q_OBJECT
29 Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
30 Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
31 Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
32
33public:
34 QSystemTrayIcon(QObject *parent = nullptr);
35 QSystemTrayIcon(const QIcon &icon, QObject *parent = nullptr);
36 ~QSystemTrayIcon();
37
38 enum ActivationReason {
39 Unknown,
40 Context,
41 DoubleClick,
42 Trigger,
43 MiddleClick
44 };
45
46#if QT_CONFIG(menu)
47 void setContextMenu(QMenu *menu);
48 QMenu *contextMenu() const;
49#endif
50
51 QIcon icon() const;
52 void setIcon(const QIcon &icon);
53
54 QString toolTip() const;
55 void setToolTip(const QString &tip);
56
57 static bool isSystemTrayAvailable();
58 static bool supportsMessages();
59
60 enum MessageIcon { NoIcon, Information, Warning, Critical };
61
62 QRect geometry() const;
63 bool isVisible() const;
64
65public Q_SLOTS:
66 void setVisible(bool visible);
67 inline void show() { setVisible(true); }
68 inline void hide() { setVisible(false); }
69 void showMessage(const QString &title, const QString &msg, const QIcon &icon, int msecs);
70 void showMessage(const QString &title, const QString &msg, const QIcon &icon,
71 std::chrono::milliseconds msecs = std::chrono::milliseconds(10000));
72 void showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon,
73 int msecs);
74 void showMessage(const QString &title, const QString &msg,
75 QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information,
76 std::chrono::milliseconds msecs = std::chrono::milliseconds(10000));
77
78Q_SIGNALS:
79 void activated(QSystemTrayIcon::ActivationReason reason);
80 void messageClicked();
81
82protected:
83 bool event(QEvent *event) override;
84
85private:
86 Q_DISABLE_COPY(QSystemTrayIcon)
87 Q_DECLARE_PRIVATE(QSystemTrayIcon)
88
89 Q_PRIVATE_SLOT(d_func(), void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason))
90
91 friend class QSystemTrayIconSys;
92 friend class QBalloonTip;
93};
94
95QT_END_NAMESPACE
96
97#endif // QT_NO_SYSTEMTRAYICON
98#endif // QSYSTEMTRAYICON_H
static void hideBalloon()
static bool isBalloonVisible()
void timerEvent(QTimerEvent *e) override
This event handler can be reimplemented in a subclass to receive timer events for the object.
void mousePressEvent(QMouseEvent *e) override
This event handler, for event event, can be reimplemented in a subclass to receive mouse press events...
static void updateBalloonPosition(QPoint pos)
\inmodule QtGui
Definition qbitmap.h:17
QPainter(QPaintDevice *)
Constructs a painter that begins painting the paint device immediately.
\inmodule QtCore\reentrant
Definition qpoint.h:30
void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason)
QPlatformSystemTrayIcon * qpa_sys
The QSystemTrayIcon class provides an icon for an application in the system tray.
static QBalloonTip * theSolitaryBalloonTip