Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdbustrayicon_p.h
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// Qt-Security score:significant reason:default
4
5#ifndef QDBUSTRAYICON_H
6#define QDBUSTRAYICON_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
20
22
23#include <QIcon>
24#include <QTemporaryFile>
25#include <QTimer>
26#include <QSet>
27#include "QtGui/qpa/qplatformsystemtrayicon.h"
28#include "private/qdbusmenuconnection_p.h"
29
30QT_BEGIN_NAMESPACE
31
32class QStatusNotifierItemAdaptor;
33class QDBusMenuAdaptor;
36
38{
39 Q_OBJECT
40 Q_PROPERTY(QString category READ category NOTIFY categoryChanged)
52
53public:
55
56 virtual ~QDBusTrayIcon();
57
59
60 void init() override;
61 void cleanup() override;
62 void updateIcon(const QIcon &icon) override;
63 void updateToolTip(const QString &tooltip) override;
64 void updateMenu(QPlatformMenu *menu) override;
65 QPlatformMenu *createMenu() const override;
66 void showMessage(const QString &title, const QString &msg,
67 const QIcon &icon, MessageIcon iconType, int msecs) override;
68
70 bool supportsMessages() const override { return true; }
71 QRect geometry() const override { return QRect(); }
72
73 QString category() const { return m_category; }
74 QString status() const { return m_status; }
75 QString tooltip() const { return m_tooltip; }
76
77 QString iconName() const { return m_iconName; }
78 const QIcon & icon() const { return m_icon; }
79
80 bool isRequestingAttention() const { return m_attentionTimer.isActive(); }
81 QString attentionTitle() const { return m_messageTitle; }
82 QString attentionMessage() const { return m_message; }
83 QString attentionIconName() const { return m_attentionIconName; }
84 const QIcon & attentionIcon() const { return m_attentionIcon; }
85
86 QString instanceId() const { return m_instanceId; }
87
88 QDBusPlatformMenu *menu() { return m_menu; }
89
92 void statusChanged(QString arg);
95 void attention();
97
98private Q_SLOTS:
100 void actionInvoked(uint id, const QString &action);
101 void notificationClosed(uint id, uint reason);
102 void watcherServiceRegistered(const QString &serviceName);
103
104private:
105 void setStatus(const QString &status);
106 QTemporaryFile *tempIcon(const QIcon &icon);
107
108private:
109 QDBusMenuConnection* m_dbusConnection;
111 QDBusMenuAdaptor *m_menuAdaptor;
112 QDBusPlatformMenu *m_menu;
113 QXdgNotificationInterface *m_notifier;
114 QString m_instanceId;
115 QString m_category;
116 QString m_defaultStatus;
117 QString m_status;
118 QString m_tooltip;
119 QString m_messageTitle;
120 QString m_message;
121 QIcon m_icon;
122 QTemporaryFile *m_tempIcon;
123 QString m_iconName;
124 QIcon m_attentionIcon;
125 QTemporaryFile *m_tempAttentionIcon;
126 QString m_attentionIconName;
127 QTimer m_attentionTimer;
128 bool m_registered;
129 QSet<uint> m_ownMessageIDs;
130};
131
133{
136};
137
138
139QT_END_NAMESPACE
140
141Q_DECLARE_METATYPE(QDBusTrayImage)
142
143#endif // QDBUSTRAYICON_H
void init() override
This method is called to initialize the platform dependent implementation.
void updateMenu(QPlatformMenu *menu) override
This method is called when the system tray menu did change.
void menuChanged()
void statusChanged(QString arg)
bool isRequestingAttention() const
void showMessage(const QString &title, const QString &msg, const QIcon &icon, MessageIcon iconType, int msecs) override
Shows a balloon message for the entry with the given title, message msg and icon for the time specifi...
QString attentionIconName() const
QDBusMenuConnection * dBusConnection()
void cleanup() override
This method is called to cleanup the platform dependent implementation.
QString category() const
const QIcon & icon() const
QRect geometry() const override
This method returns the geometry of the platform dependent system tray icon on the screen.
virtual ~QDBusTrayIcon()
QString status() const
QString tooltip() const
void attention()
QString instanceId() const
void tooltipChanged()
void updateIcon(const QIcon &icon) override
This method is called when the icon did change.
void iconChanged()
void updateToolTip(const QString &tooltip) override
This method is called when the tooltip text did change.
QString attentionTitle() const
bool supportsMessages() const override
Returns true if the system tray supports messages on the platform.
QString iconName() const
QDBusPlatformMenu * menu()
bool isSystemTrayAvailable() const override
Returns true if the system tray is available on the platform.
QPlatformMenu * createMenu() const override
This method allows platforms to use a different QPlatformMenu for system tray menus than what would n...
QString attentionMessage() const
const QIcon & attentionIcon() const
QDBusArgument & operator<<(QDBusArgument &argument, const QDBusTrayImage &img)
static const QString KDEWatcherService
static int instanceCount
static const QString DefaultAction
static const QString KDEItemFormat
static QString tempFileTemplate()
const QDBusArgument & operator>>(const QDBusArgument &argument, QDBusTrayImage &)
static const QString XdgNotificationPath
static QString iconTempPath()
static const QString XdgNotificationService
QT_REQUIRE_CONFIG(systemtrayicon)
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")