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)
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;
209 if (!m_dbusConnection) {
216 return m_dbusConnection;
226 m_tempIcon = tempIcon(
icon);
228 m_iconName = m_tempIcon->
fileName();
250 if (m_menu != newMenu) {
253 delete m_menuAdaptor;
261 m_menuAdaptor,
SIGNAL(LayoutUpdated(
uint,
int)));
270 m_messageTitle =
title;
272 m_attentionIcon =
icon;
289 m_attentionIconName.
clear();
292 if (m_attentionIconName.
isEmpty()) {
293 if (m_tempAttentionIcon)
294 delete m_tempAttentionIcon;
295 m_tempAttentionIcon = tempIcon(
icon);
296 if (m_tempAttentionIcon)
297 m_attentionIconName = m_tempAttentionIcon->
fileName();
300 QPlatformSystemTrayIcon::metaObject()->enumerator(
301 QPlatformSystemTrayIcon::staticMetaObject.indexOfEnumerator(
"MessageIcon")).valueToKey(iconType)
302 << m_attentionIconName << msecs;
304 m_attentionTimer.
start(msecs);
312 int urgency =
static_cast<int>(iconType) - 1;
317 m_attentionIconName,
title, msg, notificationActions, hints, msecs);
320void QDBusTrayIcon::actionInvoked(
uint id,
const QString &action)
322 qCDebug(qLcTray) <<
id << action;
326void QDBusTrayIcon::notificationClosed(
uint id,
uint reason)
328 qCDebug(qLcTray) <<
id << reason;
343#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...
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool mkpath(const QString &dirPath) const
Creates the directory path dirPath.
static QString tempPath()
Returns the absolute canonical path of the system's temporary directory.
bool exists() const
Returns true if the file 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
void clear()
Clears the contents of the string and makes it null.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
\inmodule QtCore \reentrant
QString fileName() const override
Returns the complete unique filename backing the QTemporaryFile object.
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)