File indexing completed on 2024-05-12 15:44:08
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "knotificationqmlplugin.h" 0008 0009 #include <KNotification> 0010 #include <KNotificationReplyAction> 0011 0012 class NotificationWrapper : public KNotification 0013 { 0014 Q_OBJECT 0015 Q_PROPERTY(KNotificationReplyAction *replyAction READ replyActionFactory CONSTANT) 0016 public: 0017 explicit NotificationWrapper(QObject *parent = nullptr) 0018 : KNotification(QString(), KNotification::CloseOnTimeout, parent) 0019 { 0020 setAutoDelete(false); 0021 } 0022 0023 KNotificationReplyAction *replyActionFactory() 0024 { 0025 if (!replyAction()) { 0026 setReplyAction(std::make_unique<KNotificationReplyAction>(QString())); 0027 } 0028 return replyAction(); 0029 } 0030 }; 0031 0032 void KNotificationQmlPlugin::registerTypes(const char *uri) 0033 { 0034 Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.notification")); 0035 qmlRegisterType<NotificationWrapper>(uri, 1, 0, "Notification"); 0036 qmlRegisterUncreatableType<KNotificationReplyAction>(uri, 1, 0, "NotificationReplyAction", {}); 0037 } 0038 0039 #include "knotificationqmlplugin.moc" 0040 #include "moc_knotificationqmlplugin.cpp"