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/qstring.h"
31#include "QtCore/qpointer.h"
32
33QT_BEGIN_NAMESPACE
34
35class QSystemTrayIconSys;
36class QSystemTrayWatcher;
37class QPlatformSystemTrayIcon;
38class QToolButton;
39class QLabel;
40
41class QSystemTrayIconPrivate : public QObjectPrivate
42{
43 Q_DECLARE_PUBLIC(QSystemTrayIcon)
44
45public:
46 QSystemTrayIconPrivate();
47 ~QSystemTrayIconPrivate();
48
49 void install_sys();
50 void remove_sys();
51 void updateIcon_sys();
52 void updateToolTip_sys();
53 void updateMenu_sys();
54 QRect geometry_sys() const;
55 void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon,
56 QSystemTrayIcon::MessageIcon msgIcon, int msecs);
57
58 void destroyIcon();
59
60 static bool isSystemTrayAvailable_sys();
61 static bool supportsMessages_sys();
62
63 void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason);
64
65 QPointer<QMenu> menu;
66 QIcon icon;
67 QString toolTip;
68 QSystemTrayIconSys *sys;
69 QPlatformSystemTrayIcon *qpa_sys;
70 bool visible;
71 QSystemTrayWatcher *trayWatcher;
72
73private:
74 void install_sys_qpa();
75 void remove_sys_qpa();
76
77 void addPlatformMenu(QMenu *menu) const;
78};
79
80class QBalloonTip : public QWidget
81{
82 Q_OBJECT
83public:
84 static void showBalloon(const QIcon &icon, const QString &title,
85 const QString &msg, QSystemTrayIcon *trayIcon,
86 const QPoint &pos, int timeout, bool showArrow = true);
87 static void hideBalloon();
88 static bool isBalloonVisible();
89 static void updateBalloonPosition(const QPoint& pos);
90
91private:
92 QBalloonTip(const QIcon &icon, const QString &title,
93 const QString &msg, QSystemTrayIcon *trayIcon);
94 ~QBalloonTip();
95 void balloon(const QPoint&, int, bool);
96
97protected:
98 void paintEvent(QPaintEvent *) override;
99 void resizeEvent(QResizeEvent *) override;
100 void mousePressEvent(QMouseEvent *e) override;
101 void timerEvent(QTimerEvent *e) override;
102
103private:
104 QSystemTrayIcon *trayIcon;
105 QPixmap pixmap;
106 int timerId;
107 bool showArrow;
108};
109
110QT_END_NAMESPACE
111
112#endif // QT_NO_SYSTEMTRAYICON
113
114#endif // QSYSTEMTRAYICON_P_H
115
116

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