blob: e156cb1e572a974f65c5433d24f495dbbf57a367 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qsystemtrayicon_p.h"
#include <QtGui/qpa/qplatformsystemtrayicon.h>
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
#include <QApplication>
#include <QStyle>
#ifndef QT_NO_SYSTEMTRAYICON
QT_BEGIN_NAMESPACE
QSystemTrayIconPrivate::QSystemTrayIconPrivate()
: qpa_sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon())
, visible(false), trayWatcher(nullptr)
{
}
QSystemTrayIconPrivate::~QSystemTrayIconPrivate()
{
delete qpa_sys;
}
void QSystemTrayIconPrivate::install_sys()
{
if (qpa_sys)
install_sys_qpa();
}
void QSystemTrayIconPrivate::remove_sys()
{
if (qpa_sys)
remove_sys_qpa();
}
QRect QSystemTrayIconPrivate::geometry_sys() const
{
if (!qpa_sys)
return QRect();
auto screen = QGuiApplication::primaryScreen();
#if QT_CONFIG(menu)
if (menu)
screen = menu->screen();
#endif
return QHighDpi::fromNativePixels(qpa_sys->geometry(), screen);
}
void QSystemTrayIconPrivate::updateIcon_sys()
{
if (qpa_sys)
qpa_sys->updateIcon(icon);
}
void QSystemTrayIconPrivate::updateMenu_sys()
{
#if QT_CONFIG(menu)
if (qpa_sys && menu) {
addPlatformMenu(menu);
qpa_sys->updateMenu(menu->platformMenu());
}
#endif
}
void QSystemTrayIconPrivate::updateToolTip_sys()
{
if (qpa_sys)
qpa_sys->updateToolTip(toolTip);
}
bool QSystemTrayIconPrivate::isSystemTrayAvailable_sys()
{
QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());
if (sys)
return sys->isSystemTrayAvailable();
else
return false;
}
bool QSystemTrayIconPrivate::supportsMessages_sys()
{
QScopedPointer<QPlatformSystemTrayIcon> sys(QGuiApplicationPrivate::platformTheme()->createPlatformSystemTrayIcon());
if (sys)
return sys->supportsMessages();
else
return false;
}
void QSystemTrayIconPrivate::showMessage_sys(const QString &title, const QString &message,
const QIcon &icon, QSystemTrayIcon::MessageIcon msgIcon, int msecs)
{
if (qpa_sys)
qpa_sys->showMessage(title, message, icon,
static_cast<QPlatformSystemTrayIcon::MessageIcon>(msgIcon), msecs);
}
QT_END_NAMESPACE
#endif // QT_NO_SYSTEMTRAYICON
|