Plasma5Support

devicenotificationsengine.cpp
1/*
2 SPDX-FileCopyrightText: 2010 Jacopo De Simoi <wilderkde@gmail.com>
3 SPDX-FileCopyrightText: 2014 Lukáš Tinkl <ltinkl@redhat.com>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#include "devicenotificationsengine.h"
9
10#include <Plasma5Support/DataContainer>
11
12DeviceNotificationsEngine::DeviceNotificationsEngine(QObject *parent)
13 : Plasma5Support::DataEngine(parent)
14 , m_solidNotify(new KSolidNotify(this))
15{
16 qWarning("DeviceNotificationsEngine is deprecated. Import KSolidNotify from org.kde.plasma.private.devicenotifier instead.");
17 connect(m_solidNotify, &KSolidNotify::notify, this, &DeviceNotificationsEngine::notify);
18 connect(m_solidNotify, &KSolidNotify::clearNotification, this, &DeviceNotificationsEngine::clearNotification);
19}
20
21DeviceNotificationsEngine::~DeviceNotificationsEngine()
22{
23}
24
25void DeviceNotificationsEngine::notify(Solid::ErrorType solidError, const QString &error, const QString &errorDetails, const QString &udi)
26{
27 const QString source = QStringLiteral("%1 notification").arg(udi);
28
29 Plasma5Support::DataEngine::Data notificationData;
30 notificationData.insert(QStringLiteral("solidError"), solidError);
31 notificationData.insert(QStringLiteral("error"), error);
32 notificationData.insert(QStringLiteral("errorDetails"), errorDetails);
33 notificationData.insert(QStringLiteral("udi"), udi);
34
35 setData(source, notificationData);
36}
37
38void DeviceNotificationsEngine::clearNotification(const QString &udi)
39{
40 removeSource(QStringLiteral("%1 notification").arg(udi));
41}
42
43K_PLUGIN_CLASS_WITH_JSON(DeviceNotificationsEngine, "plasma-dataengine-devicenotifications.json")
44
45#include "devicenotificationsengine.moc"
Engine which provides data sources for device notifications.
#define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile)
Class which triggers solid notifications.
void removeSource(const QString &source)
Removes a data source.
void setData(const QString &source, const QVariant &value)
Sets a value for a data source.
Namespace for everything in libplasma.
Definition datamodel.cpp:15
iterator insert(const Key &key, const T &value)
QString arg(Args &&... args) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:59:38 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.