File indexing completed on 2024-05-05 03:56:59

0001 /*
0002    SPDX-FileCopyrightText: 2023 Nicolas Fella <nicolas.fella@gmx.de>
0003 
0004    SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #include <KNotification>
0008 
0009 #include <QGuiApplication>
0010 
0011 int main(int argc, char **argv)
0012 {
0013     QGuiApplication app(argc, argv);
0014 
0015     KNotification *notification = new KNotification(QStringLiteral("notification"));
0016     notification->setComponentName(QStringLiteral("plasma_workspace"));
0017     notification->setText(QStringLiteral("Hello!"));
0018     notification->setTitle(QStringLiteral("Yo"));
0019 
0020     KNotificationAction *action = notification->addAction(QStringLiteral("Open it"));
0021     QObject::connect(action, &KNotificationAction::activated, &app, [notification] {
0022         qWarning() << "action activated" << notification->xdgActivationToken();
0023     });
0024 
0025     KNotificationAction *defaultAction = notification->addDefaultAction(QStringLiteral("Aaaa"));
0026     QObject::connect(defaultAction, &KNotificationAction::activated, &app, [notification] {
0027         qWarning() << "default action activated" << notification->xdgActivationToken();
0028     });
0029 
0030     notification->sendEvent();
0031 
0032     return app.exec();
0033 }