1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qplatformsystemtrayicon.h"
6
7#include <QtGui/private/qguiapplication_p.h>
8#include <QtGui/qpa/qplatformtheme.h>
9
10#ifndef QT_NO_SYSTEMTRAYICON
11
12QT_BEGIN_NAMESPACE
13
14/*!
15 \class QPlatformSystemTrayIcon
16 \inmodule QtGui
17 \brief The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction.
18
19 \internal
20 \sa QSystemTrayIcon
21*/
22
23/*!
24 \enum QPlatformSystemTrayIcon::MessageIcon
25
26 This enum describes the icon that is shown when a balloon message is displayed.
27
28 \value NoIcon No icon is shown.
29 \value Information An information icon is shown.
30 \value Warning A standard warning icon is shown.
31 \value Critical A critical warning icon is shown.
32
33 \sa updateIcon(), showMessage(), QMessageBox
34*/
35
36/*!
37 \enum QPlatformSystemTrayIcon::ActivationReason
38
39 This enum describes the reason the system tray was activated.
40
41 \value Unknown Unknown reason
42 \value Context The context menu for the system tray entry was requested
43 \value DoubleClick The system tray entry was double clicked
44 \value Trigger The system tray entry was clicked
45 \value MiddleClick The system tray entry was clicked with the middle mouse button
46
47 \sa activated()
48*/
49
50QPlatformSystemTrayIcon::QPlatformSystemTrayIcon()
51{
52}
53
54QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon()
55{
56}
57
58/*!
59 \fn void QPlatformSystemTrayIcon::init()
60 This method is called to initialize the platform dependent implementation.
61*/
62
63/*!
64 \fn void QPlatformSystemTrayIcon::cleanup()
65 This method is called to cleanup the platform dependent implementation.
66*/
67
68/*!
69 \fn void QPlatformSystemTrayIcon::updateIcon(const QIcon &icon)
70 This method is called when the \a icon did change.
71*/
72
73/*!
74 \fn void QPlatformSystemTrayIcon::updateToolTip(const QString &tooltip)
75 This method is called when the \a tooltip text did change.
76*/
77
78/*!
79 \fn void QPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu)
80 This method is called when the system tray \a menu did change.
81*/
82
83/*!
84 \fn QRect QPlatformSystemTrayIcon::geometry() const
85 This method returns the geometry of the platform dependent system tray icon on the screen.
86*/
87
88/*!
89 \fn void QPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg,
90 const QIcon &icon, MessageIcon iconType, int msecs)
91 Shows a balloon message for the entry with the given \a title, message \a msg and \a icon for
92 the time specified in \a msecs. \a iconType is used as a hint for the implementing platform.
93 \sa QSystemTrayIcon::showMessage()
94*/
95
96/*!
97 \fn bool QPlatformSystemTrayIcon::isSystemTrayAvailable() const
98 Returns \c true if the system tray is available on the platform.
99*/
100
101/*!
102 \fn bool QPlatformSystemTrayIcon::supportsMessages() const
103 Returns \c true if the system tray supports messages on the platform.
104*/
105
106/*!
107 \fn void QPlatformSystemTrayIcon::contextMenuRequested(QPoint globalPos, const QPlatformScreen *screen)
108 This signal is emitted when the context menu is requested.
109 In particular, on platforms where createMenu() returns nullptr,
110 its emission will cause QSystemTrayIcon to show a QMenu-based menu.
111 \sa activated()
112 \since 5.10
113*/
114
115/*!
116 \fn void QPlatformSystemTrayIcon::activated(QPlatformSystemTrayIcon::ActivationReason reason)
117 This signal is emitted when the user activates the system tray icon.
118 \a reason specifies the reason for activation.
119 \sa QSystemTrayIcon::ActivationReason, contextMenuRequested()
120*/
121
122/*!
123 \fn void QPlatformSystemTrayIcon::messageClicked()
124
125 This signal is emitted when the message displayed using showMessage()
126 was clicked by the user.
127
128 \sa activated()
129*/
130
131/*!
132 This method allows platforms to use a different QPlatformMenu for system
133 tray menus than what would normally be used for e.g. menu bars. The default
134 implementation falls back to a platform menu created by the platform theme,
135 which may be null on platforms without native menus.
136
137 \sa updateMenu()
138 \since 5.3
139 */
140
141QPlatformMenu *QPlatformSystemTrayIcon::createMenu() const
142{
143 return QGuiApplicationPrivate::platformTheme()->createPlatformMenu();
144}
145
146QT_END_NAMESPACE
147
148#include "moc_qplatformsystemtrayicon.cpp"
149
150#endif // QT_NO_SYSTEMTRAYICON
151

source code of qtbase/src/gui/kernel/qplatformsystemtrayicon.cpp