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

Use KService and ApplicationLauncherJob for handling Itinerary

This fixes integration when Itinerary is from Flatpak and window activation on Wayland
parent d3fb2123
Pipeline #179649 passed with stage
in 16 minutes and 52 seconds
......@@ -27,7 +27,9 @@
#include <KCalendarCore/Event>
#include <KIO/ApplicationLauncherJob>
#include <KLocalizedString>
#include <KService>
#include <KontactInterface/PimUniqueApplication>
#include <QDBusInterface>
......@@ -43,13 +45,6 @@
using namespace KItinerary;
QString ItineraryUrlHandler::m_appPath;
ItineraryUrlHandler::ItineraryUrlHandler()
{
m_appPath = QStandardPaths::findExecutable(QStringLiteral("itinerary"));
}
QString ItineraryUrlHandler::name() const
{
return QString::fromUtf8(staticMetaObject.className());
......@@ -153,7 +148,7 @@ QString ItineraryUrlHandler::statusBarMessage(MimeTreeParser::Interface::BodyPar
bool ItineraryUrlHandler::hasItineraryApp()
{
return !m_appPath.isEmpty();
return KService::serviceByDesktopName(QStringLiteral("org.kde.itinerary"));
}
ItineraryMemento *ItineraryUrlHandler::memento(MimeTreeParser::Interface::BodyPart *part) const
......@@ -235,9 +230,9 @@ void ItineraryUrlHandler::addToCalendar(ItineraryMemento *memento) const
void ItineraryUrlHandler::openInApp(MimeTreeParser::Interface::BodyPart *part) const
{
const auto fileName = createItineraryFile(part);
if (m_appPath.isEmpty() || !QProcess::startDetached(m_appPath, {fileName})) {
qCWarning(ITINERARY_LOG) << "Could not find application in PATH." << m_appPath;
}
auto *job = new KIO::ApplicationLauncherJob(KService::serviceByDesktopName(QStringLiteral("org.kde.itinerary")));
job->setUrls({QUrl::fromLocalFile(fileName)});
job->start();
}
void ItineraryUrlHandler::openWithKDEConnect(MimeTreeParser::Interface::BodyPart *part, const QString &deviceId) const
......
......@@ -18,7 +18,6 @@ class ItineraryUrlHandler : public QObject, public MessageViewer::Interface::Bod
{
Q_OBJECT
public:
ItineraryUrlHandler();
~ItineraryUrlHandler() override = default;
void setKDEConnectHandler(ItineraryKDEConnectHandler *kdeConnect);
......@@ -38,6 +37,4 @@ private:
Q_REQUIRED_RESULT QString createItineraryFile(MimeTreeParser::Interface::BodyPart *part) const;
ItineraryKDEConnectHandler *m_kdeConnect = nullptr;
static QString m_appPath;
};
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