Commit f9bbdcf1 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Add jump list actions for Statistics and Health Certificates

parent 0f768fd5
......@@ -148,6 +148,11 @@ ApplicationController* ApplicationController::instance()
return s_instance;
}
void ApplicationController::requestOpenPage(const QString &page)
{
Q_EMIT openPageRequested(page);
}
void ApplicationController::setReservationManager(ReservationManager* resMgr)
{
m_resMgr = resMgr;
......
......@@ -42,6 +42,8 @@ public:
explicit ApplicationController(QObject *parent = nullptr);
~ApplicationController() override;
void requestOpenPage(const QString &page);
void setReservationManager(ReservationManager *resMgr);
void setPkPassManager(PkPassManager *pkPassMgr);
void setDocumentManager(DocumentManager *docMgr);
......@@ -81,6 +83,8 @@ Q_SIGNALS:
/** Human readable information message to be shown as passive notification. */
void infoMessage(const QString &msg);
void openPageRequested(const QString &page);
private:
bool hasClipboardContent() const;
......
......@@ -180,7 +180,7 @@ void registerApplicationSingletons()
#undef REGISTER_SINGLETON_INSTANCE
void handlePositionalArguments(ApplicationController *appController, const QStringList &args, bool isTemporary)
void handleCommandLineArguments(ApplicationController *appController, const QStringList &args, bool isTemporary, const QString &page)
{
for (const auto &file : args) {
const auto localUrl = QUrl::fromLocalFile(file);
......@@ -193,6 +193,10 @@ void handlePositionalArguments(ApplicationController *appController, const QStri
appController->importFromUrl(QUrl::fromUserInput(file));
}
}
if (!page.isEmpty()) {
appController->requestOpenPage(page);
}
}
#ifdef Q_OS_ANDROID
......@@ -233,6 +237,8 @@ int main(int argc, char **argv)
QCommandLineParser parser;
QCommandLineOption isTemporaryOpt(QStringLiteral("tempfile"), QStringLiteral("Input file is a temporary file and will be deleted after importing."));
parser.addOption(isTemporaryOpt);
QCommandLineOption pageOpt(QStringLiteral("page"), i18n("Open Itinerary on the given page"), QStringLiteral("page"));
parser.addOption(pageOpt);
aboutData.setupCommandLine(&parser);
parser.addPositionalArgument(QStringLiteral("file"), i18n("PkPass or JSON-LD file to import."));
parser.process(app);
......@@ -328,7 +334,7 @@ int main(int argc, char **argv)
if (!args.isEmpty()) {
QDir::setCurrent(workingDir);
parser.parse(args);
handlePositionalArguments(&appController, parser.positionalArguments(), parser.isSet(isTemporaryOpt));
handleCommandLineArguments(&appController, parser.positionalArguments(), parser.isSet(isTemporaryOpt), parser.value(pageOpt));
}
if (!QGuiApplication::allWindows().isEmpty()) {
QGuiApplication::allWindows().at(0)->requestActivate();
......@@ -348,7 +354,8 @@ int main(int argc, char **argv)
engine.rootContext()->setContextObject(l10nContext);
engine.load(QStringLiteral("qrc:/main.qml"));
handlePositionalArguments(&appController, parser.positionalArguments(), parser.isSet(isTemporaryOpt));
handleCommandLineArguments(&appController, parser.positionalArguments(), parser.isSet(isTemporaryOpt), parser.value(pageOpt));
#ifdef Q_OS_ANDROID
using namespace KAndroidExtras;
appController.importFromIntent(Activity::getIntent());
......
......@@ -83,7 +83,7 @@ Kirigami.ApplicationWindow {
onTriggered: pageStack.layers.push(statisticsComponent)
},
Kirigami.Action {
id: healtCertAction
id: healthCertAction
text: i18n("Health Certificates")
iconName: "cross-shape"
onTriggered: {
......@@ -151,6 +151,18 @@ Kirigami.ApplicationWindow {
Connections {
target: ApplicationController
function onInfoMessage(msg) { showPassiveNotification(msg, "short"); }
function onOpenPageRequested(page) {
switch (page) {
case "stats":
statsAction.trigger();
break;
case "healthCert":
healthCertAction.trigger();
break;
default:
console.warn("Requested to open unknown page", page);
}
}
}
Connections {
......
......@@ -82,3 +82,14 @@ MimeType=application/vnd.apple.pkpass;application/ld+json;application/pdf;text/c
Categories=Qt;KDE;Utility;
X-KDE-HasTempFileOption=true
X-KDE-FormFactor=desktop;tablet;handset;
Actions=statistics;healthCert;
[Desktop Action statistics]
Name=Statistics
Icon=view-statistics
Exec=itinerary --page stats
[Desktop Action healthCert]
Name=Health Certificates
Icon=cross-shape
Exec=itinerary --page healthCert
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