Commit b09fb854 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Use ApplicationLauncherJob to open KOrganizer

Instead of PimUniqueApplication::activateApplication

It does everything we need

It even magically handles activating Kontact if running

This fixes window activation on Wayland
parent 69641696
Pipeline #180529 passed with stage
in 22 minutes and 14 seconds
......@@ -30,7 +30,6 @@ Dependencies:
'pim/kidentitymanagement' : '@same'
'pim/kimap' : '@same'
'pim/kmailtransport' : '@same'
'pim/kontactinterface' : '@same'
'pim/kpimtextedit' : '@same'
'pim/ktnef' : '@same'
'pim/libgravatar' : '@same'
......
......@@ -95,7 +95,6 @@ set(IMPORTWIZARD_LIB_VERSION "5.20.40")
set(MAILIMPORTER_LIB_VERSION "5.20.40")
set(KPIMPKPASS_LIB_VERSION "5.20.40")
set(KPIMITINERARY_LIB_VERSION "5.20.40")
set(KONTACTINTERFACE_LIB_VERSION "5.20.40")
set(AKONADINOTES_LIB_VERSION "5.20.40")
find_package(KF5AkonadiNotes ${AKONADINOTES_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5CalendarCore ${KF5_MIN_VERSION} CONFIG REQUIRED)
......@@ -131,7 +130,6 @@ find_package(KPimImportWizard ${IMPORTWIZARD_LIB_VERSION} CONFIG)
find_package(KF5MailImporterAkonadi ${MAILIMPORTER_LIB_VERSION} CONFIG REQUIRED)
find_package(KPimPkPass ${KPIMPKPASS_LIB_VERSION} CONFIG REQUIRED)
find_package(KPimItinerary ${KPIMITINERARY_LIB_VERSION} CONFIG REQUIRED)
find_package(KF5KontactInterface ${KONTACTINTERFACE_LIB_VERSION} CONFIG REQUIRED)
if (QT_MAJOR_VERSION STREQUAL "5")
find_package(Grantlee5 "5.2" CONFIG REQUIRED)
......
......@@ -30,7 +30,6 @@ if (COMPILE_WITH_UNITY_CMAKE_SUPPORT)
endif()
target_link_libraries(messageviewer_bodypartformatter_text_calendar
KF5::KontactInterface
KF5::Codecs
Qt${QT_MAJOR_VERSION}::Core
KF5::CalendarCore
......
......@@ -42,8 +42,6 @@ using namespace KCalendarCore;
#include <MailTransport/TransportManager>
#include <MailTransportAkonadi/MessageQueueJob>
#include <KontactInterface/PimUniqueApplication>
#include "text_calendar_debug.h"
#include <KIO/FileCopyJob>
......@@ -1105,8 +1103,21 @@ public:
void showCalendar(QDate date) const
{
// If korganizer or kontact is running, bring it to the front. Otherwise start korganizer.
if (KontactInterface::PimUniqueApplication::activateApplication(QStringLiteral("korganizer"))) {
// Start or activate KOrganizer. When Kontact is running it will switch to KOrganizer view
const auto korgaService = KService::serviceByDesktopName(QStringLiteral("org.kde.korganizer"));
if (!korgaService) {
qCWarning(TEXT_CALENDAR_LOG) << "Could not find KOrganizer";
return;
}
auto *job = new KIO::ApplicationLauncherJob(korgaService);
QObject::connect(job, &KJob::finished, job, [date](KJob *job) {
if (job->error()) {
qCWarning(TEXT_CALENDAR_LOG) << "failed to run korganizer" << job->errorString();
return;
}
OrgKdeKorganizerCalendarInterface iface(QStringLiteral("org.kde.korganizer"), QStringLiteral("/Calendar"), QDBusConnection::sessionBus(), nullptr);
if (!iface.isValid()) {
qCDebug(TEXT_CALENDAR_LOG) << "Calendar interface is not valid! " << iface.lastError().message();
......@@ -1114,7 +1125,9 @@ public:
}
iface.showEventView();
iface.showDate(date);
}
});
job->start();
}
bool handleIgnore(Viewer *viewerInstance) const
......
......@@ -28,7 +28,7 @@ endif()
target_compile_definitions(messageviewer_bodypartformatter_semantic PRIVATE -DTRANSLATION_DOMAIN=\"messageviewer_semantic_plugin\")
target_link_libraries(messageviewer_bodypartformatter_semantic
KF5::KontactInterface
KF5::KIOGui
KF5::MessageViewer
KF5::CalendarSupport
KF5::I18n
......
......@@ -30,7 +30,6 @@
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KService>
#include <KontactInterface/PimUniqueApplication>
#include <QDBusInterface>
#include <QDate>
......@@ -163,8 +162,23 @@ ItineraryMemento *ItineraryUrlHandler::memento(MimeTreeParser::Interface::BodyPa
void ItineraryUrlHandler::showCalendar(QDate date) const
{
// ensure KOrganizer or Kontact are running
if (KontactInterface::PimUniqueApplication::activateApplication(QStringLiteral("korganizer"))) {
// Start or activate KOrganizer. When Kontact is running it will switch to KOrganizer view
const auto korgaService = KService::serviceByDesktopName(QStringLiteral("org.kde.korganizer"));
if (!korgaService) {
qCWarning(ITINERARY_LOG) << "Could not find KOrganizer";
return;
}
// Open or activate KOrganizer. This will also activate Kontact if running
auto *job = new KIO::ApplicationLauncherJob(korgaService);
connect(job, &KJob::finished, this, [date](KJob *job) {
if (job->error()) {
qCWarning(ITINERARY_LOG) << "failed to run korganizer" << job->errorString();
return;
}
// select the date of the reservation
QDBusInterface korgIface(QStringLiteral("org.kde.korganizer"),
QStringLiteral("/Calendar"),
......@@ -176,7 +190,9 @@ void ItineraryUrlHandler::showCalendar(QDate date) const
}
korgIface.call(QStringLiteral("showEventView"));
korgIface.call(QStringLiteral("showDate"), date);
}
});
job->start();
}
static void attachPass(const KCalendarCore::Event::Ptr &event, const QVector<QVariant> &reservations, ItineraryMemento *memento)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment