Skip to content

Add KNotificationReplyAction for using inline-reply Notification API

Kai Uwe Broulik requested to merge work/kbroulik/quickreply into master


Example use

KNotification *notification = new KNotification(QStringLiteral("notification"));
notification->setTitle(i18nc("@title:window", "Annoying chat group"));
notification->setText("<Max> What's up?");

auto replyAction = std::make_unique<KNotificationReplyAction>(i18nc("@action:button", "Reply"));
replyAction->setPlaceholderText(i18nc("@info:placeholder", "Reply to annoying chat group..."));
QObject::connect(replyAction.get(), &KNotificationReplyAction::replied, [](const QString &text) {
    qDebug() << "you replied with" << text;


Not entirely sure about this API with the unique_ptr. I definitely want to have it a separate object as to not add a dozen new setters and getters to the main KNotification class. But I also don't like Qt's usual approach of "setFoo (Note: Transfers ownership)" that you have to know, especially since KNotification already has a track-record of awful memory management with its self-deleting-class-that-isnt-a-job approach :)

I was considering a generic KNotificationAction class but whenever I touch this I end up rewriting everything and then never getting anywhere … so I'd rather not touch the existing action stuff at all.

  • TODO a way to influence which order the button will be when combined with regular actions? Currently it's always the first (so in Plasma the right-most one :D)

please also check some of the TODO/FIXME comments in the code for comment

@davidedmundson @dfaure @vonreth @piyushaggarwal @carlschwan @bshah @nicolasfella

Edited by Kai Uwe Broulik

Merge request reports