Qt 6.x
The Qt SDK
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
25{
26 delete qpa_sys;
27}
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
54{
55 if (qpa_sys)
57}
58
60{
61#if QT_CONFIG(menu)
62 if (qpa_sys && menu) {
63 addPlatformMenu(menu);
65 }
66#endif
67}
68
70{
71 if (qpa_sys)
73}
74
76{
78 if (sys)
79 return sys->isSystemTrayAvailable();
80 else
81 return false;
82}
83
85{
87 if (sys)
88 return sys->supportsMessages();
89 else
90 return false;
91}
92
94 const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
95{
96 if (qpa_sys)
98 static_cast<QPlatformSystemTrayIcon::MessageIcon>(msgIcon), msecs);
99}
100
102
103#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:3682
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
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
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:2503
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]