[applets/digitalclock] Allow to launch Kalendar instead of KOrganizer

Currently this is hardcoded to KOrganizer, but Kalendar is a nice app and we should be able to launch that too.

Check for the default handler for calendar files and take that if it is KOrganizer or Kalendar. The check is to avoid launching an app that can technically open ics files but isn't a calendar app, e.g. Kate.

We can extend the logic with other known calendar apps
wilder-5.24
Nicolas Fella 4 years ago
parent cc9afb7af2
commit 9c5653269a
  1. 1
      applets/digital-clock/plugin/CMakeLists.txt
  2. 11
      applets/digital-clock/plugin/applicationintegration.cpp

@ -23,6 +23,7 @@ target_link_libraries(digitalclockplugin
Qt::Widgets # for QAction...
KF5::CoreAddons
KF5::KIOGui
KF5::Service
KF5::I18n)
install(TARGETS digitalclockplugin DESTINATION ${KDE_INSTALL_QMLDIR}/org/kde/plasma/private/digitalclock)

@ -2,12 +2,21 @@
// SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
#include "applicationintegration.h"
#include <KApplicationTrader>
#include <KIO/ApplicationLauncherJob>
ApplicationIntegration::ApplicationIntegration(QObject *parent)
: QObject(parent)
, m_calendarService(KService::serviceByDesktopName(QStringLiteral("org.kde.korganizer")))
{
const auto services = KApplicationTrader::queryByMimeType(QStringLiteral("text/calendar"));
if (!services.isEmpty()) {
const KService::Ptr app = services.first();
if (app->desktopEntryName() == QLatin1String("org.kde.korganizer") || app->desktopEntryName() == QLatin1String("org.kde.kalendar")) {
m_calendarService = app;
}
}
}
bool ApplicationIntegration::calendarInstalled() const

Loading…
Cancel
Save