/* SPDX-FileCopyrightText: 2021 Volker Krause SPDX-License-Identifier: LGPL-2.0-or-later */ #include "knotificationqmlplugin.h" NotificationWrapper::NotificationWrapper(QObject *parent) : KNotification(QString(), KNotification::CloseOnTimeout, parent) { setAutoDelete(false); m_actionsProperty = QQmlListProperty(this, nullptr, &NotificationWrapper::appendAction, &NotificationWrapper::actionsCount, &NotificationWrapper::actionAt, &NotificationWrapper::clearActions); } KNotificationReplyAction *NotificationWrapper::replyActionFactory() { if (!replyAction()) { setReplyAction(std::make_unique(QString())); } return replyAction(); } int NotificationWrapper::actionCount() const { return actions().count(); } KNotificationAction *NotificationWrapper::actionAt(qsizetype index) { return actions().at(index); } QQmlListProperty NotificationWrapper::actionsProperty() const { return m_actionsProperty; } qsizetype NotificationWrapper::actionsCount(QQmlListProperty *list) { return static_cast(list->object)->actionCount(); } void NotificationWrapper::appendAction(QQmlListProperty *list, KNotificationAction *value) { auto notification = static_cast(list->object); auto actions = notification->actions(); actions << value; notification->setActionsQml(actions); } KNotificationAction *NotificationWrapper::actionAt(QQmlListProperty *list, qsizetype index) { return static_cast(list->object)->actionAt(index); } void NotificationWrapper::clearActions(QQmlListProperty *list) { auto notification = static_cast(list->object); notification->clearActions(); } #include "moc_knotificationqmlplugin.cpp"