[pim/korganizer] src/kontactplugin/specialdates: sdsummarywidget.cpp - fix sending an email to a contact
Allen Winter <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit a36ea6502a365e6d191e0b9d4fcee92f9746e478 by Allen Winter.
Committed on 25/07/2026 at 20:19.
Pushed by winterz into branch 'master'.
sdsummarywidget.cpp - fix sending an email to a contact
Use a dbus call to KMail's openComposer to send email
rather than QDesktopServices::openUrl().
M +16 -2 src/kontactplugin/specialdates/sdsummarywidget.cpp
https://invent.kde.org/pim/korganizer/-/commit/a36ea6502a365e6d191e0b9d4fcee92f9746e478
diff --git a/src/kontactplugin/specialdates/sdsummarywidget.cpp b/src/kontactplugin/specialdates/sdsummarywidget.cpp
index cf44ad8fb..ebb3bd864 100644
--- a/src/kontactplugin/specialdates/sdsummarywidget.cpp
+++ b/src/kontactplugin/specialdates/sdsummarywidget.cpp
@@ -32,8 +32,9 @@
#include <KLocalizedString>
#include <KUrlLabel>
+#include <QDBusConnection>
+#include <QDBusMessage>
#include <QDate>
-#include <QDesktopServices>
#include <QEvent>
#include <QGridLayout>
#include <QLabel>
@@ -654,7 +655,20 @@ void SDSummaryWidget::slotItemFetchJobDone(KJob *job)
}
const auto contact = lst.first().payload<KContacts::Addressee>();
- QDesktopServices::openUrl(QUrl(contact.fullEmail()));
+ const QString to = contact.preferredEmail();
+ const QString name = contact.realName();
+ const QString subject = i18nc("@info/plain default subject line for a new mail message", "New Message to %1", name);
+
+ mPlugin->core()->selectPlugin(QStringLiteral("kontact_kmailplugin")); // ensure loaded
+
+ QDBusMessage message = QDBusMessage::createMethodCall(QStringLiteral("org.kde.kmail"),
+ QStringLiteral("/KMail"),
+ QStringLiteral("org.kde.kmail.kmail"),
+ QStringLiteral("openComposer"));
+
+ // see PREFIX/share/dbus-1/interfaces/org.kde.kmail.kmail.xml for more openComposer variants
+ message.setArguments(QList<QVariant>() << to << QString() << QString() << subject << QString() << false);
+ QDBusConnection::sessionBus().send(message);
}
void SDSummaryWidget::viewContact(const QString &url)