| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
|---|
| 4 | ** Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com> | 
|---|
| 5 | ** Contact: https://www.qt.io/licensing/ | 
|---|
| 6 | ** | 
|---|
| 7 | ** This file is part of the QtGui module of the Qt Toolkit. | 
|---|
| 8 | ** | 
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 10 | ** Commercial License Usage | 
|---|
| 11 | ** Licensees holding valid commercial Qt licenses may use this file in | 
|---|
| 12 | ** accordance with the commercial license agreement provided with the | 
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 14 | ** a written agreement between you and The Qt Company. For licensing terms | 
|---|
| 15 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
|---|
| 16 | ** information use the contact form at https://www.qt.io/contact-us. | 
|---|
| 17 | ** | 
|---|
| 18 | ** GNU Lesser General Public License Usage | 
|---|
| 19 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 20 | ** General Public License version 3 as published by the Free Software | 
|---|
| 21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
|---|
| 22 | ** packaging of this file. Please review the following information to | 
|---|
| 23 | ** ensure the GNU Lesser General Public License version 3 requirements | 
|---|
| 24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
|---|
| 25 | ** | 
|---|
| 26 | ** GNU General Public License Usage | 
|---|
| 27 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 28 | ** General Public License version 2.0 or (at your option) the GNU General | 
|---|
| 29 | ** Public license version 3 or any later version approved by the KDE Free | 
|---|
| 30 | ** Qt Foundation. The licenses are as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
|---|
| 32 | ** included in the packaging of this file. Please review the following | 
|---|
| 33 | ** information to ensure the GNU General Public License requirements will | 
|---|
| 34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
|---|
| 35 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
|---|
| 36 | ** | 
|---|
| 37 | ** $QT_END_LICENSE$ | 
|---|
| 38 | ** | 
|---|
| 39 | ****************************************************************************/ | 
|---|
| 40 |  | 
|---|
| 41 | #include "qplatformsystemtrayicon.h" | 
|---|
| 42 |  | 
|---|
| 43 | #include <QtGui/private/qguiapplication_p.h> | 
|---|
| 44 | #include <QtGui/qpa/qplatformtheme.h> | 
|---|
| 45 |  | 
|---|
| 46 | #ifndef QT_NO_SYSTEMTRAYICON | 
|---|
| 47 |  | 
|---|
| 48 | QT_BEGIN_NAMESPACE | 
|---|
| 49 |  | 
|---|
| 50 | /*! | 
|---|
| 51 | \class QPlatformSystemTrayIcon | 
|---|
| 52 | \inmodule QtGui | 
|---|
| 53 | \brief The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction. | 
|---|
| 54 |  | 
|---|
| 55 | \internal | 
|---|
| 56 | \sa QSystemTrayIcon | 
|---|
| 57 | */ | 
|---|
| 58 |  | 
|---|
| 59 | /*! | 
|---|
| 60 | \enum QPlatformSystemTrayIcon::MessageIcon | 
|---|
| 61 |  | 
|---|
| 62 | This enum describes the icon that is shown when a balloon message is displayed. | 
|---|
| 63 |  | 
|---|
| 64 | \value NoIcon      No icon is shown. | 
|---|
| 65 | \value Information An information icon is shown. | 
|---|
| 66 | \value Warning     A standard warning icon is shown. | 
|---|
| 67 | \value Critical    A critical warning icon is shown. | 
|---|
| 68 |  | 
|---|
| 69 | \sa updateIcon(), showMessage(), QMessageBox | 
|---|
| 70 | */ | 
|---|
| 71 |  | 
|---|
| 72 | /*! | 
|---|
| 73 | \enum QPlatformSystemTrayIcon::ActivationReason | 
|---|
| 74 |  | 
|---|
| 75 | This enum describes the reason the system tray was activated. | 
|---|
| 76 |  | 
|---|
| 77 | \value Unknown     Unknown reason | 
|---|
| 78 | \value Context     The context menu for the system tray entry was requested | 
|---|
| 79 | \value DoubleClick The system tray entry was double clicked | 
|---|
| 80 | \value Trigger     The system tray entry was clicked | 
|---|
| 81 | \value MiddleClick The system tray entry was clicked with the middle mouse button | 
|---|
| 82 |  | 
|---|
| 83 | \sa activated() | 
|---|
| 84 | */ | 
|---|
| 85 |  | 
|---|
| 86 | QPlatformSystemTrayIcon::QPlatformSystemTrayIcon() | 
|---|
| 87 | { | 
|---|
| 88 | } | 
|---|
| 89 |  | 
|---|
| 90 | QPlatformSystemTrayIcon::~QPlatformSystemTrayIcon() | 
|---|
| 91 | { | 
|---|
| 92 | } | 
|---|
| 93 |  | 
|---|
| 94 | /*! | 
|---|
| 95 | \fn void QPlatformSystemTrayIcon::init() | 
|---|
| 96 | This method is called to initialize the platform dependent implementation. | 
|---|
| 97 | */ | 
|---|
| 98 |  | 
|---|
| 99 | /*! | 
|---|
| 100 | \fn void QPlatformSystemTrayIcon::cleanup() | 
|---|
| 101 | This method is called to cleanup the platform dependent implementation. | 
|---|
| 102 | */ | 
|---|
| 103 |  | 
|---|
| 104 | /*! | 
|---|
| 105 | \fn void QPlatformSystemTrayIcon::updateIcon(const QIcon &icon) | 
|---|
| 106 | This method is called when the \a icon did change. | 
|---|
| 107 | */ | 
|---|
| 108 |  | 
|---|
| 109 | /*! | 
|---|
| 110 | \fn void QPlatformSystemTrayIcon::updateToolTip(const QString &tooltip) | 
|---|
| 111 | This method is called when the \a tooltip text did change. | 
|---|
| 112 | */ | 
|---|
| 113 |  | 
|---|
| 114 | /*! | 
|---|
| 115 | \fn void QPlatformSystemTrayIcon::updateMenu(QPlatformMenu *menu) | 
|---|
| 116 | This method is called when the system tray \a menu did change. | 
|---|
| 117 | */ | 
|---|
| 118 |  | 
|---|
| 119 | /*! | 
|---|
| 120 | \fn QRect QPlatformSystemTrayIcon::geometry() const | 
|---|
| 121 | This method returns the geometry of the platform dependent system tray icon on the screen. | 
|---|
| 122 | */ | 
|---|
| 123 |  | 
|---|
| 124 | /*! | 
|---|
| 125 | \fn void QPlatformSystemTrayIcon::showMessage(const QString &title, const QString &msg, | 
|---|
| 126 | const QIcon &icon, MessageIcon iconType, int msecs) | 
|---|
| 127 | Shows a balloon message for the entry with the given \a title, message \a msg and \a icon for | 
|---|
| 128 | the time specified in \a msecs. \a iconType is used as a hint for the implementing platform. | 
|---|
| 129 | \sa QSystemTrayIcon::showMessage() | 
|---|
| 130 | */ | 
|---|
| 131 |  | 
|---|
| 132 | /*! | 
|---|
| 133 | \fn bool QPlatformSystemTrayIcon::isSystemTrayAvailable() const | 
|---|
| 134 | Returns \c true if the system tray is available on the platform. | 
|---|
| 135 | */ | 
|---|
| 136 |  | 
|---|
| 137 | /*! | 
|---|
| 138 | \fn bool QPlatformSystemTrayIcon::supportsMessages() const | 
|---|
| 139 | Returns \c true if the system tray supports messages on the platform. | 
|---|
| 140 | */ | 
|---|
| 141 |  | 
|---|
| 142 | /*! | 
|---|
| 143 | \fn void QPlatformSystemTrayIcon::contextMenuRequested(QPoint globalPos, const QPlatformScreen *screen) | 
|---|
| 144 | This signal is emitted when the context menu is requested. | 
|---|
| 145 | In particular, on platforms where createMenu() returns nullptr, | 
|---|
| 146 | its emission will cause QSystemTrayIcon to show a QMenu-based menu. | 
|---|
| 147 | \sa activated() | 
|---|
| 148 | \since 5.10 | 
|---|
| 149 | */ | 
|---|
| 150 |  | 
|---|
| 151 | /*! | 
|---|
| 152 | \fn void QPlatformSystemTrayIcon::activated(QPlatformSystemTrayIcon::ActivationReason reason) | 
|---|
| 153 | This signal is emitted when the user activates the system tray icon. | 
|---|
| 154 | \a reason specifies the reason for activation. | 
|---|
| 155 | \sa QSystemTrayIcon::ActivationReason, contextMenuRequested() | 
|---|
| 156 | */ | 
|---|
| 157 |  | 
|---|
| 158 | /*! | 
|---|
| 159 | \fn void QPlatformSystemTrayIcon::messageClicked() | 
|---|
| 160 |  | 
|---|
| 161 | This signal is emitted when the message displayed using showMessage() | 
|---|
| 162 | was clicked by the user. | 
|---|
| 163 |  | 
|---|
| 164 | \sa activated() | 
|---|
| 165 | */ | 
|---|
| 166 |  | 
|---|
| 167 | /*! | 
|---|
| 168 | This method allows platforms to use a different QPlatformMenu for system | 
|---|
| 169 | tray menus than what would normally be used for e.g. menu bars. The default | 
|---|
| 170 | implementation falls back to a platform menu created by the platform theme, | 
|---|
| 171 | which may be null on platforms without native menus. | 
|---|
| 172 |  | 
|---|
| 173 | \sa updateMenu() | 
|---|
| 174 | \since 5.3 | 
|---|
| 175 | */ | 
|---|
| 176 |  | 
|---|
| 177 | QPlatformMenu *QPlatformSystemTrayIcon::() const | 
|---|
| 178 | { | 
|---|
| 179 | return QGuiApplicationPrivate::platformTheme()->createPlatformMenu(); | 
|---|
| 180 | } | 
|---|
| 181 |  | 
|---|
| 182 | QT_END_NAMESPACE | 
|---|
| 183 |  | 
|---|
| 184 | #include "moc_qplatformsystemtrayicon.cpp" | 
|---|
| 185 |  | 
|---|
| 186 | #endif // QT_NO_SYSTEMTRAYICON | 
|---|
| 187 |  | 
|---|