Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsystemtrayicon_qpa.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 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#include "qsystemtrayicon_p.h"
5
6#include <QtGui/qpa/qplatformsystemtrayicon.h>
7#include <qpa/qplatformtheme.h>
8#include <private/qguiapplication_p.h>
9#include <private/qhighdpiscaling_p.h>
10
11#include <QApplication>
12#include <QStyle>
13
14#ifndef QT_NO_SYSTEMTRAYICON
15
17
19 : qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon())
20 , visible(false), trayWatcher(nullptr)
21{
22}
23
28
30{
31 if (qpa_sys)
32 install_sys_qpa();
33}
34
36{
37 if (qpa_sys)
38 remove_sys_qpa();
39}
40
42{
43 if (!qpa_sys)
44 return QRect();
46#if QT_CONFIG(menu)
47 if (menu)
48 screen = menu->screen();
49#endif
51}
52
58
60{
61#if QT_CONFIG(menu)
62 if (qpa_sys) {
63 if (menu) {
64 addPlatformMenu(menu);
66 } else {
67 qpa_sys->updateMenu(nullptr);
68 }
69 }
70#endif
71}
72
78
80{
81 QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());
82 if (sys)
83 return sys->isSystemTrayAvailable();
84 else
85 return false;
86}
87
89{
90 QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());
91 if (sys)
92 return sys->supportsMessages();
93 else
94 return false;
95}
96
98 const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
99{
100 if (qpa_sys)
102 static_cast<QPlatformSystemTrayIcon::MessageIcon>(msgIcon), msecs);
103}
104
106
107#endif // QT_NO_SYSTEMTRAYICON
static QPlatformTheme * platformTheme()
QScreen * primaryScreen
the primary (or default) screen of the application.
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
QPlatformMenu * platformMenu()
Definition qmenu.cpp:3710
MessageIcon
This enum describes the icon that is shown when a balloon message is displayed.
virtual void updateIcon(const QIcon &icon)=0
This method is called when the icon did change.
virtual void updateToolTip(const QString &tooltip)=0
This method is called when the tooltip text did change.
virtual void showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs)=0
Shows a balloon message for the entry with the given title, message msg and icon for the time specifi...
virtual QRect geometry() const =0
This method returns the geometry of the platform dependent system tray icon on the screen.
virtual void updateMenu(QPlatformMenu *menu)=0
This method is called when the system tray menu did change.
\inmodule QtCore\reentrant
Definition qrect.h:30
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QSystemTrayIconSys * sys
static bool isSystemTrayAvailable_sys()
QPlatformSystemTrayIcon * qpa_sys
void showMessage_sys(const QString &title, const QString &msg, const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
MessageIcon
This enum describes the icon that is shown when a balloon message is displayed.
QScreen * screen() const
Returns the screen the widget is on.
Definition qwidget.cpp:2496
T fromNativePixels(const T &value, const C *context)
Combined button and popup list for selecting options.
GLuint GLsizei const GLchar * message
QScreen * screen
[1]
Definition main.cpp:29
QObject::connect nullptr
QString title
[35]