1// Copyright (C) 2017 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 QQUICKLABSPLATFORMSYSTEMTRAYICON_P_H
5#define QQUICKLABSPLATFORMSYSTEMTRAYICON_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 <QtCore/qurl.h>
19#include <QtCore/qrect.h>
20#include <QtGui/qpa/qplatformsystemtrayicon.h>
21#include <QtQml/qqmlparserstatus.h>
22#include <QtQml/qqml.h>
23
24#include "qquicklabsplatformicon_p.h"
25
26QT_REQUIRE_CONFIG(systemtrayicon);
27
28QT_BEGIN_NAMESPACE
29
30class QQuickLabsPlatformMenu;
31class QQuickLabsPlatformIconLoader;
32
33class QQuickLabsPlatformSystemTrayIcon : public QObject, public QQmlParserStatus
34{
35 Q_OBJECT
36 QML_NAMED_ELEMENT(SystemTrayIcon)
37 QML_EXTENDED_NAMESPACE(QPlatformSystemTrayIcon)
38 Q_INTERFACES(QQmlParserStatus)
39 Q_PROPERTY(bool available READ isAvailable CONSTANT FINAL)
40 Q_PROPERTY(bool supportsMessages READ supportsMessages CONSTANT FINAL)
41 Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
42 Q_PROPERTY(QString tooltip READ tooltip WRITE setTooltip NOTIFY tooltipChanged FINAL)
43 Q_PROPERTY(QQuickLabsPlatformMenu *menu READ menu WRITE setMenu NOTIFY menuChanged FINAL)
44 Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged FINAL REVISION(1, 1))
45 Q_PROPERTY(QQuickLabsPlatformIcon icon READ icon WRITE setIcon NOTIFY iconChanged FINAL REVISION(1, 1))
46
47public:
48 explicit QQuickLabsPlatformSystemTrayIcon(QObject *parent = nullptr);
49 ~QQuickLabsPlatformSystemTrayIcon();
50
51 QPlatformSystemTrayIcon *handle() const;
52
53 bool isAvailable() const;
54 bool supportsMessages() const;
55
56 bool isVisible() const;
57 void setVisible(bool visible);
58
59 QString tooltip() const;
60 void setTooltip(const QString &tooltip);
61
62 QQuickLabsPlatformMenu *menu() const;
63 void setMenu(QQuickLabsPlatformMenu *menu);
64
65 QRect geometry() const;
66
67 QQuickLabsPlatformIcon icon() const;
68 void setIcon(const QQuickLabsPlatformIcon &icon);
69
70public Q_SLOTS:
71 void show();
72 void hide();
73
74 void showMessage(const QString &title, const QString &message,
75 QPlatformSystemTrayIcon::MessageIcon iconType = QPlatformSystemTrayIcon::Information, int msecs = 10000);
76
77Q_SIGNALS:
78 void activated(QPlatformSystemTrayIcon::ActivationReason reason);
79 void messageClicked();
80 void visibleChanged();
81 void tooltipChanged();
82 void menuChanged();
83 Q_REVISION(2, 1) void geometryChanged();
84 Q_REVISION(2, 1) void iconChanged();
85
86protected:
87 void init();
88 void cleanup();
89
90 void classBegin() override;
91 void componentComplete() override;
92
93 QQuickLabsPlatformIconLoader *iconLoader() const;
94
95private Q_SLOTS:
96 void updateIcon();
97
98private:
99 bool m_complete;
100 bool m_visible;
101 QString m_tooltip;
102 QQuickLabsPlatformMenu *m_menu;
103 mutable QQuickLabsPlatformIconLoader *m_iconLoader;
104 QPlatformSystemTrayIcon *m_handle;
105};
106
107QT_END_NAMESPACE
108
109QML_DECLARE_TYPE(QQuickLabsPlatformSystemTrayIcon)
110Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::ActivationReason)
111Q_DECLARE_METATYPE(QPlatformSystemTrayIcon::MessageIcon)
112
113#endif // QQUICKLABSPLATFORMSYSTEMTRAYICON_P_H
114

source code of qtdeclarative/src/labs/platform/qquicklabsplatformsystemtrayicon_p.h