| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QSYSTEMTRAYICON_P_H |
| 41 | #define QSYSTEMTRAYICON_P_H |
| 42 | |
| 43 | // |
| 44 | // W A R N I N G |
| 45 | // ------------- |
| 46 | // |
| 47 | // This file is not part of the Qt API. It exists purely as an |
| 48 | // implementation detail. This header file may change from version to |
| 49 | // version without notice, or even be removed. |
| 50 | // |
| 51 | // We mean it. |
| 52 | // |
| 53 | |
| 54 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
| 55 | #include "qsystemtrayicon.h" |
| 56 | #include "private/qobject_p.h" |
| 57 | |
| 58 | #ifndef QT_NO_SYSTEMTRAYICON |
| 59 | |
| 60 | #if QT_CONFIG(menu) |
| 61 | #include "QtWidgets/qmenu.h" |
| 62 | #endif |
| 63 | #include "QtWidgets/qwidget.h" |
| 64 | #include "QtGui/qpixmap.h" |
| 65 | #include <qpa/qplatformsystemtrayicon.h> |
| 66 | #include "QtCore/qstring.h" |
| 67 | #include "QtCore/qpointer.h" |
| 68 | |
| 69 | QT_BEGIN_NAMESPACE |
| 70 | |
| 71 | class QSystemTrayIconSys; |
| 72 | class QSystemTrayWatcher; |
| 73 | class QPlatformSystemTrayIcon; |
| 74 | class QToolButton; |
| 75 | class QLabel; |
| 76 | |
| 77 | class QSystemTrayIconPrivate : public QObjectPrivate |
| 78 | { |
| 79 | Q_DECLARE_PUBLIC(QSystemTrayIcon) |
| 80 | |
| 81 | public: |
| 82 | QSystemTrayIconPrivate(); |
| 83 | ~QSystemTrayIconPrivate(); |
| 84 | |
| 85 | void install_sys(); |
| 86 | void remove_sys(); |
| 87 | void updateIcon_sys(); |
| 88 | void updateToolTip_sys(); |
| 89 | void (); |
| 90 | QRect geometry_sys() const; |
| 91 | void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon, |
| 92 | QSystemTrayIcon::MessageIcon msgIcon, int msecs); |
| 93 | |
| 94 | void destroyIcon(); |
| 95 | |
| 96 | static bool isSystemTrayAvailable_sys(); |
| 97 | static bool supportsMessages_sys(); |
| 98 | |
| 99 | void _q_emitActivated(QPlatformSystemTrayIcon::ActivationReason reason); |
| 100 | |
| 101 | QPointer<QMenu> ; |
| 102 | QIcon icon; |
| 103 | QString toolTip; |
| 104 | QSystemTrayIconSys *sys; |
| 105 | QPlatformSystemTrayIcon *qpa_sys; |
| 106 | bool visible; |
| 107 | QSystemTrayWatcher *trayWatcher; |
| 108 | |
| 109 | private: |
| 110 | void install_sys_qpa(); |
| 111 | void remove_sys_qpa(); |
| 112 | |
| 113 | void (QMenu *) const; |
| 114 | }; |
| 115 | |
| 116 | class QBalloonTip : public QWidget |
| 117 | { |
| 118 | Q_OBJECT |
| 119 | public: |
| 120 | static void showBalloon(const QIcon &icon, const QString &title, |
| 121 | const QString &msg, QSystemTrayIcon *trayIcon, |
| 122 | const QPoint &pos, int timeout, bool showArrow = true); |
| 123 | static void hideBalloon(); |
| 124 | static bool isBalloonVisible(); |
| 125 | static void updateBalloonPosition(const QPoint& pos); |
| 126 | |
| 127 | private: |
| 128 | QBalloonTip(const QIcon &icon, const QString &title, |
| 129 | const QString &msg, QSystemTrayIcon *trayIcon); |
| 130 | ~QBalloonTip(); |
| 131 | void balloon(const QPoint&, int, bool); |
| 132 | |
| 133 | protected: |
| 134 | void paintEvent(QPaintEvent *) override; |
| 135 | void resizeEvent(QResizeEvent *) override; |
| 136 | void mousePressEvent(QMouseEvent *e) override; |
| 137 | void timerEvent(QTimerEvent *e) override; |
| 138 | |
| 139 | private: |
| 140 | QSystemTrayIcon *trayIcon; |
| 141 | QPixmap pixmap; |
| 142 | int timerId; |
| 143 | bool showArrow; |
| 144 | }; |
| 145 | |
| 146 | QT_END_NAMESPACE |
| 147 | |
| 148 | #endif // QT_NO_SYSTEMTRAYICON |
| 149 | |
| 150 | #endif // QSYSTEMTRAYICON_P_H |
| 151 | |
| 152 | |