Commit 1ff6a227 authored by Volker Krause's avatar Volker Krause

Add unique application behavior on non-Android too

This makes use from KMail a lot more convenient, as we are now updating
the data in an already running application when importing multiple data
elements.
parent bc565b3b
......@@ -44,6 +44,7 @@ if (ANDROID)
find_package(OpenSSL REQUIRED)
else()
find_package(Qt5 REQUIRED COMPONENTS Widgets Positioning)
find_package(KF5 REQUIRED COMPONENTS DBusAddons)
endif()
add_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_TO_ASCII -DQT_NO_URL_CAST_FROM_STRING)
......
......@@ -78,7 +78,11 @@ if (ANDROID)
weather-storm
)
else ()
target_link_libraries(itinerary-app PRIVATE Qt5::Positioning Qt5::Widgets)
target_link_libraries(itinerary-app PRIVATE
KF5::DBusAddons
Qt5::Positioning
Qt5::Widgets
)
set_target_properties(itinerary-app PROPERTIES OUTPUT_NAME "itinerary")
endif()
......
......@@ -36,6 +36,10 @@
#include <KPkPass/Field>
#include <KPkPass/Barcode>
#ifndef Q_OS_ANDROID
#include <KDBusService>
#endif
#include <KLocalizedContext>
#include <KLocalizedString>
......@@ -51,8 +55,10 @@
#include <QCommandLineParser>
#include <QDebug>
#include <QDir>
#include <QGuiApplication>
#include <QIcon>
#include <QWindow>
void handleViewIntent(ApplicationController *appController)
{
......@@ -96,6 +102,10 @@ int main(int argc, char **argv)
parser.addPositionalArgument(QStringLiteral("file"), i18n("PkPass or JSON-LD file to import."));
parser.process(app);
#ifndef Q_OS_ANDROID
KDBusService service(KDBusService::Unique);
#endif
Settings settings;
PkPassManager passMgr;
ReservationManager resMgr;
......@@ -103,6 +113,24 @@ int main(int argc, char **argv)
ApplicationController appController;
appController.setReservationManager(&resMgr);
appController.setPkPassManager(&passMgr);
#ifndef Q_OS_ANDROID
QObject::connect(&service, &KDBusService::activateRequested, [&parser, &passMgr, &resMgr](const QStringList &args, const QString &workingDir) {
qCDebug(Log) << "remote activation" << args << workingDir;
if (!args.isEmpty()) {
QDir::setCurrent(workingDir);
parser.parse(args);
for (const auto &file : parser.positionalArguments()) {
if (file.endsWith(QLatin1String(".pkpass")))
passMgr.importPass(QUrl::fromLocalFile(file));
else
resMgr.importReservation(QUrl::fromLocalFile(file));
}
}
if (!QGuiApplication::allWindows().isEmpty()) {
QGuiApplication::allWindows().at(0)->requestActivate();
}
});
#endif
TimelineModel timelineModel;
timelineModel.setHomeCountryIsoCode(settings.homeCountryIsoCode());
......
Markdown is supported
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