| 1 | /**************************************************************************** |
|---|---|
| 2 | ** |
| 3 | ** Copyright (C) 2017 The Qt Company Ltd. |
| 4 | ** Contact: http://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the Qt Labs Platform module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL3$ |
| 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 http://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at http://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.LGPLv3 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.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 later as published by the Free |
| 28 | ** Software Foundation and appearing in the file LICENSE.GPL included in |
| 29 | ** the packaging of this file. Please review the following information to |
| 30 | ** ensure the GNU General Public License version 2.0 requirements will be |
| 31 | ** met: http://www.gnu.org/licenses/gpl-2.0.html. |
| 32 | ** |
| 33 | ** $QT_END_LICENSE$ |
| 34 | ** |
| 35 | ****************************************************************************/ |
| 36 | |
| 37 | #ifndef QQUICKPLATFORMSYSTEMTRAYICON_P_H |
| 38 | #define QQUICKPLATFORMSYSTEMTRAYICON_P_H |
| 39 | |
| 40 | // |
| 41 | // W A R N I N G |
| 42 | // ------------- |
| 43 | // |
| 44 | // This file is not part of the Qt API. It exists purely as an |
| 45 | // implementation detail. This header file may change from version to |
| 46 | // version without notice, or even be removed. |
| 47 | // |
| 48 | // We mean it. |
| 49 | // |
| 50 | |
| 51 | #include <QtCore/qurl.h> |
| 52 | #include <QtCore/qrect.h> |
| 53 | #include <QtGui/qpa/qplatformsystemtrayicon.h> |
| 54 | #include <QtQml/qqmlparserstatus.h> |
| 55 | #include <QtQml/qqml.h> |
| 56 | |
| 57 | #include "qquickplatformicon_p.h" |
| 58 | |
| 59 | QT_REQUIRE_CONFIG(systemtrayicon); |
| 60 | |
| 61 | QT_BEGIN_NAMESPACE |
| 62 | |
| 63 | class QQuickPlatformMenu; |
| 64 | class QQuickPlatformIconLoader; |
| 65 | |
| 66 | class QQuickPlatformSystemTrayIcon : public QObject, public QQmlParserStatus |
| 67 | { |
| 68 | Q_OBJECT |
| 69 | Q_INTERFACES(QQmlParserStatus) |
| 70 | Q_PROPERTY(bool available READ isAvailable CONSTANT FINAL) |
| 71 | Q_PROPERTY(bool supportsMessages READ supportsMessages CONSTANT FINAL) |
| 72 | Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) |
| 73 | Q_PROPERTY(QUrl iconSource READ iconSource WRITE setIconSource NOTIFY iconSourceChanged FINAL) |
| 74 | Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged FINAL) |
| 75 | Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged FINAL) |
| 76 | Q_PROPERTY(QQuickPlatformMenu *menu READ menu WRITE setMenu NOTIFY menuChanged FINAL) |
| 77 | Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged FINAL REVISION 1) |
| 78 | Q_PROPERTY(QQuickPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION 1) |
| 79 | Q_ENUMS(QPlatformSystemTrayIcon::ActivationReason QPlatformSystemTrayIcon::MessageIcon) |
| 80 | |
| 81 | public: |
| 82 | explicit QQuickPlatformSystemTrayIcon(QObject *parent = nullptr); |
| 83 | ~QQuickPlatformSystemTrayIcon(); |
| 84 | |
| 85 | QPlatformSystemTrayIcon *handle() const; |
| 86 | |
| 87 | bool isAvailable() const; |
| 88 | bool supportsMessages() const; |
| 89 | |
| 90 | bool isVisible() const; |
| 91 | void setVisible(bool visible); |
| 92 | |
| 93 | QUrl iconSource() const; |
| 94 | void setIconSource(const QUrl &source); |
| 95 | |
| 96 | QString iconName() const; |
| 97 | void setIconName(const QString &name); |
| 98 | |
| 99 | QString tooltip() const; |
| 100 | void setTooltip(const QString &tooltip); |
| 101 | |
| 102 | QQuickPlatformMenu *menu() const; |
| 103 | void setMenu(QQuickPlatformMenu *menu); |
| 104 | |
| 105 | QRect geometry() const; |
| 106 | |
| 107 | QQuickPlatformIcon icon() const; |
| 108 | void setIcon(const QQuickPlatformIcon &icon); |
| 109 | |
| 110 | public Q_SLOTS: |
| 111 | void show(); |
| 112 | void hide(); |
| 113 | |
| 114 | void showMessage(const QString &title, const QString &message, |
| 115 | QPlatformSystemTrayIcon::MessageIcon iconType = QPlatformSystemTrayIcon::Information, int msecs = 10000); |
| 116 | |
| 117 | Q_SIGNALS: |
| 118 | void activated(QPlatformSystemTrayIcon::ActivationReason reason); |
| 119 | void messageClicked(); |
| 120 | void visibleChanged(); |
| 121 | void iconSourceChanged(); |
| 122 | void iconNameChanged(); |
| 123 | void tooltipChanged(); |
| 124 | void menuChanged(); |
| 125 | Q_REVISION(1) void geometryChanged(); |
| 126 | Q_REVISION(1) void iconChanged(); |
| 127 | |
| 128 | protected: |
| 129 | void init(); |
| 130 | void cleanup(); |
| 131 | |
| 132 | void classBegin() override; |
| 133 | void componentComplete() override; |
| 134 | |
| 135 | QQuickPlatformIconLoader *iconLoader() const; |
| 136 | |
| 137 | private Q_SLOTS: |
| 138 | void updateIcon(); |
| 139 | |
| 140 | private: |
| 141 | bool m_complete; |
| 142 | bool m_visible; |
| 143 | QString m_tooltip; |
| 144 | QQuickPlatformMenu *m_menu; |
| 145 | mutable QQuickPlatformIconLoader *m_iconLoader; |
| 146 | QPlatformSystemTrayIcon *m_handle; |
| 147 | }; |
| 148 | |
| 149 | QT_END_NAMESPACE |
| 150 | |
| 151 | QML_DECLARE_TYPE(QQuickPlatformSystemTrayIcon) |
| 152 | Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::ActivationReason) |
| 153 | Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::MessageIcon) |
| 154 | |
| 155 | #endif // QQUICKPLATFORMSYSTEMTRAYICON_P_H |
| 156 |
