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_P_H
5#define QSYSTEMTRAYICON_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qsystemtrayicon.h"
20#include "private/qobject_p.h"
21
22#ifndef QT_NO_SYSTEMTRAYICON
23
24#if QT_CONFIG(menu)
25#include "QtWidgets/qmenu.h"
26#endif
27#include "QtWidgets/qwidget.h"
28#include "QtGui/qpixmap.h"
29#include <qpa/qplatformsystemtrayicon.h>
30#include "QtCore/qbasictimer.h"
31#include "QtCore/qstring.h"
32#include "QtCore/qpointer.h"
33
34QT_BEGIN_NAMESPACE
35
36class QSystemTrayIconSys;
37class QSystemTrayWatcher;
38class QPlatformSystemTrayIcon;
39class QToolButton;
40class QLabel;
41
42class QSystemTrayIconPrivate : public QObjectPrivate
43{
44 Q_DECLARE_PUBLIC(QSystemTrayIcon)
45
46public:
47 QSystemTrayIconPrivate();
48 ~QSystemTrayIconPrivate();
49
50 void install_sys();
51 void remove_sys();
52 void updateIcon_sys();
53 void updateToolTip_sys();
54 void updateMenu_sys();
55 QRect geometry_sys() const;
56 void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon,
57 QSystemTrayIcon::MessageIcon msgIcon, int msecs);
58
59 void destroyIcon();
60
61 static bool isSystemTrayAvailable_sys();
62 static bool supportsMessages_sys();
63
64 void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason);
65
66 QPointer<QMenu> menu;
67 QIcon icon;
68 QString toolTip;
69 QSystemTrayIconSys *sys;
70 QPlatformSystemTrayIcon *qpa_sys;
71 bool visible;
72 QSystemTrayWatcher *trayWatcher;
73
74private:
75 void install_sys_qpa();
76 void remove_sys_qpa();
77
78 void addPlatformMenu(QMenu *menu) const;
79};
80
81class QBalloonTip : public QWidget
82{
83 Q_OBJECT
84public:
85 static void showBalloon(const QIcon &icon, const QString &title,
86 const QString &msg, QSystemTrayIcon *trayIcon,
87 const QPoint &pos, int timeout, bool showArrow = true);
88 static void hideBalloon();
89 static bool isBalloonVisible();
90 static void updateBalloonPosition(const QPoint& pos);
91
92private:
93 QBalloonTip(const QIcon &icon, const QString &title,
94 const QString &msg, QSystemTrayIcon *trayIcon);
95 ~QBalloonTip();
96 void balloon(const QPoint&, int, bool);
97
98protected:
99 void paintEvent(QPaintEvent *) override;
100 void resizeEvent(QResizeEvent *) override;
101 void mousePressEvent(QMouseEvent *e) override;
102 void timerEvent(QTimerEvent *e) override;
103
104private:
105 QSystemTrayIcon *trayIcon;
106 QPixmap pixmap;
107 QBasicTimer timer;
108 bool showArrow;
109};
110
111QT_END_NAMESPACE
112
113#endif // QT_NO_SYSTEMTRAYICON
114
115#endif // QSYSTEMTRAYICON_P_H
116
117

source code of qtbase/src/widgets/util/qsystemtrayicon_p.h