6#ifndef QT_NO_SYSTEMTRAYICON
11#include <QLoggingCategory>
12#include <QStandardPaths>
17#include <QDBusConnectionInterface>
18#include <QDBusArgument>
19#include <QDBusMetaType>
20#include <QDBusServiceWatcher>
22#include <qpa/qplatformmenu.h>
23#include <qpa/qplatformintegration.h>
24#include <qpa/qplatformservices.h>
26#include <private/qdbusmenuconnection_p.h>
27#include <private/qstatusnotifieritemadaptor_p.h>
28#include <private/qdbusmenuadaptor_p.h>
29#include <private/qdbusplatformmenu_p.h>
30#include <private/qxdgnotificationproxy_p.h>
31#include <private/qlockfile_p.h>
32#include <private/qguiapplication_p.h>
49 tempPath +=
"/app/"_L1 + flatpakId;
56 QDir tempDir(tempPath);
62 if (
QFile(tempPath).setPermissions(permissions))
80 return TempFileTemplate;
97 , m_status(m_defaultStatus)
100 , m_registered(
false)
105 qDBusRegisterMetaType<QXdgDBusImageStruct>();
106 qDBusRegisterMetaType<QXdgDBusImageVector>();
107 qDBusRegisterMetaType<QXdgDBusToolTipStruct>();
125 qCDebug(qLcTray) <<
"registering" << m_instanceId;
128 this, &QDBusTrayIcon::watcherServiceRegistered);
133 qCDebug(qLcTray) <<
"unregistering" << m_instanceId;
136 delete m_dbusConnection;
137 m_dbusConnection =
nullptr;
139 m_notifier =
nullptr;
140 m_registered =
false;
143void QDBusTrayIcon::watcherServiceRegistered(
const QString &serviceName)
152void QDBusTrayIcon::attentionTimerExpired()
156 m_attentionIcon =
QIcon();
159 setStatus(m_defaultStatus);
162void QDBusTrayIcon::setStatus(
const QString &status)
171QTemporaryFile *QDBusTrayIcon::tempIcon(
const QIcon &
icon)
175 static bool necessity_checked =
false;
176 static bool necessary =
false;
177 if (!necessity_checked) {
181 necessary = processName.endsWith(
"indicator-application-service"_L1);
194 necessary =
services->desktopEnvironment().split(
':').contains(
"UNITY");
196 necessity_checked =
true;
212 if (!m_dbusConnection) {
219 return m_dbusConnection;
229 m_tempIcon = tempIcon(
icon);
231 m_iconName = m_tempIcon->fileName();
253 if (m_menu != newMenu) {
256 delete m_menuAdaptor;
264 m_menuAdaptor,
SIGNAL(LayoutUpdated(
uint,
int)));
273 m_messageTitle =
title;
275 m_attentionIcon =
icon;
292 m_attentionIconName.
clear();
295 if (m_attentionIconName.
isEmpty()) {
296 if (m_tempAttentionIcon)
297 delete m_tempAttentionIcon;
298 m_tempAttentionIcon = tempIcon(
icon);
299 if (m_tempAttentionIcon)
300 m_attentionIconName = m_tempAttentionIcon->fileName();
303 QPlatformSystemTrayIcon::metaObject()->enumerator(
304 QPlatformSystemTrayIcon::staticMetaObject.indexOfEnumerator(
"MessageIcon")).valueToKey(iconType)
305 << m_attentionIconName << msecs;
307 m_attentionTimer.
start(msecs);
315 int urgency =
static_cast<int>(iconType) - 1;
320 m_attentionIconName,
title, msg, notificationActions, hints, msecs);
323void QDBusTrayIcon::actionInvoked(
uint id,
const QString &action)
325 qCDebug(qLcTray) <<
id << action;
329void QDBusTrayIcon::notificationClosed(
uint id,
uint reason)
331 qCDebug(qLcTray) <<
id << reason;
346#include "moc_qdbustrayicon_p.cpp"
std::vector< ObjCStrongReference< CBMutableService > > services
QString applicationName
the name of this application
QDBusReply< bool > isServiceRegistered(const QString &serviceName) const
Returns true if the service name serviceName has is currently registered.
QDBusReply< uint > servicePid(const QString &serviceName) const
Returns the Unix Process ID (PID) for the process currently holding the bus service serviceName.
QDBusConnectionInterface * interface() const
Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connecti...
static QDBusConnection sessionBus()
Returns a QDBusConnection object opened with the session bus.
void serviceRegistered(const QString &service)
This signal is emitted whenever this object detects that the service serviceName became available on ...
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 statusChanged(QString arg)
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...
QDBusMenuConnection * dBusConnection()
void cleanup() override
This method is called to cleanup the platform dependent implementation.
void updateIcon(const QIcon &icon) override
This method is called when the icon did change.
void updateToolTip(const QString &tooltip) override
This method is called when the tooltip text did change.
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...
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
bool exists() const
Returns true if the file system entry this QFileInfo refers to exists; otherwise returns false.
static QPlatformIntegration * platformIntegration()
static bool desktopSettingsAware()
Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false.
The QIcon class provides scalable icons in different modes and states.
QList< QSize > availableSizes(Mode mode=Normal, State state=Off) const
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
static Q_CORE_EXPORT QString processNameByPid(qint64 pid)
iterator insert(const Key &key, const T &value)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
bool save(const QString &fileName, const char *format=nullptr, int quality=-1) const
Saves the pixmap to the file with the given fileName using the specified image file format and qualit...
static QString writableLocation(StandardLocation type)
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
void clear()
Clears the contents of the string and makes it null.
void setSingleShot(bool singleShot)
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
QDBusPendingReply< uint > notify(const QString &appName, uint replacesId, const QString &appIcon, const QString &summary, const QString &body, const QStringList &actions, const QVariantMap &hints, int timeout)
Combined button and popup list for selecting options.
static const QString DefaultAction
static const QString KDEWatcherService
static const QString XdgNotificationService
static const QString XdgNotificationPath
static QString tempFileTemplate()
static QString iconTempPath()
static const QString KDEItemFormat
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
GLbitfield GLuint64 timeout
[4]
#define QStringLiteral(str)
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)