| 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 | |
| 33 | QT_BEGIN_NAMESPACE |
| 34 | |
| 35 | class QSystemTrayIconSys; |
| 36 | class QSystemTrayWatcher; |
| 37 | class QPlatformSystemTrayIcon; |
| 38 | class QToolButton; |
| 39 | class QLabel; |
| 40 | |
| 41 | class QSystemTrayIconPrivate : public QObjectPrivate |
| 42 | { |
| 43 | Q_DECLARE_PUBLIC(QSystemTrayIcon) |
| 44 | |
| 45 | public: |
| 46 | QSystemTrayIconPrivate(); |
| 47 | ~QSystemTrayIconPrivate(); |
| 48 | |
| 49 | void install_sys(); |
| 50 | void remove_sys(); |
| 51 | void updateIcon_sys(); |
| 52 | void updateToolTip_sys(); |
| 53 | void (); |
| 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> ; |
| 66 | QIcon icon; |
| 67 | QString toolTip; |
| 68 | QSystemTrayIconSys *sys; |
| 69 | QPlatformSystemTrayIcon *qpa_sys; |
| 70 | bool visible; |
| 71 | QSystemTrayWatcher *trayWatcher; |
| 72 | |
| 73 | private: |
| 74 | void install_sys_qpa(); |
| 75 | void remove_sys_qpa(); |
| 76 | |
| 77 | void (QMenu *) const; |
| 78 | }; |
| 79 | |
| 80 | class QBalloonTip : public QWidget |
| 81 | { |
| 82 | Q_OBJECT |
| 83 | public: |
| 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 | |
| 91 | private: |
| 92 | QBalloonTip(const QIcon &icon, const QString &title, |
| 93 | const QString &msg, QSystemTrayIcon *trayIcon); |
| 94 | ~QBalloonTip(); |
| 95 | void balloon(const QPoint&, int, bool); |
| 96 | |
| 97 | protected: |
| 98 | void paintEvent(QPaintEvent *) override; |
| 99 | void resizeEvent(QResizeEvent *) override; |
| 100 | void mousePressEvent(QMouseEvent *e) override; |
| 101 | void timerEvent(QTimerEvent *e) override; |
| 102 | |
| 103 | private: |
| 104 | QSystemTrayIcon *trayIcon; |
| 105 | QPixmap pixmap; |
| 106 | int timerId; |
| 107 | bool showArrow; |
| 108 | }; |
| 109 | |
| 110 | QT_END_NAMESPACE |
| 111 | |
| 112 | #endif // QT_NO_SYSTEMTRAYICON |
| 113 | |
| 114 | #endif // QSYSTEMTRAYICON_P_H |
| 115 | |
| 116 | |