Commit 1021bb61 authored by Volker Krause's avatar Volker Krause
Browse files

Add support for displaying generic Apple Wallet passes

Found for example in some emails from DHL.

CCBUG: 422325
parent 52af473f
Pipeline #22731 passed with stage
in 49 minutes and 15 seconds
......@@ -86,7 +86,7 @@ set(KMAILTRANSPORT_LIB_VERSION "5.14.40")
set(AKONADICONTACT_LIB_VERSION "5.14.40")
set(IMPORTWIZARD_LIB_VERSION "5.14.40")
set(MAILIMPORTER_LIB_VERSION "5.14.40")
set(KPIMPKPASS_LIB_VERSION "5.14.40")
set(KPIMPKPASS_LIB_VERSION "5.14.41")
set(KPIMITINERARY_LIB_VERSION "5.14.41")
set(KONTACTINTERFACE_LIB_VERSION "5.14.40")
set(CALENDARSUPPORT_LIB_VERSION_LIB "5.14.40")
......
......@@ -109,6 +109,13 @@ public:
pass->setProperty("footerUrl", QUrl::fromLocalFile(fileName));
mp->nodeHelper()->addTempFile(fileName);
}
const auto thumbnail = pass->thumbnail();
if (!thumbnail.isNull()) {
const QString fileName = dir + QStringLiteral("/thumbnail.png");
thumbnail.save(fileName);
pass->setProperty("thumbnailUrl", QUrl::fromLocalFile(fileName));
mp->nodeHelper()->addTempFile(fileName);
}
const auto barcodes = pass->barcodes();
if (!barcodes.isEmpty()) {
......@@ -150,6 +157,8 @@ public:
t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral("org.kde.messageviewer/pkpass/boardingpass.html"));
} else if (pass->type() == KPkPass::Pass::EventTicket) {
t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral("org.kde.messageviewer/pkpass/eventticket.html"));
} else if (pass->type() == KPkPass::Pass::Generic) {
t = MessageViewer::MessagePartRendererManager::self()->loadByName(QStringLiteral("org.kde.messageviewer/pkpass/generic.html"));
} else {
// unknown pass type we have no template for
return false;
......
......@@ -3,5 +3,6 @@
<file alias="barcode.html">templates/barcode.html</file>
<file alias="boardingpass.html">templates/boardingpass.html</file>
<file alias="eventticket.html">templates/eventticket.html</file>
<file alias="generic.html">templates/generic.html</file>
</qresource>
</RCC>
<a name="att{{block.attachmentIndex}}"></a>
<div id="attachmentDiv{{block.attachmentIndex}}">
<div style="
background-color: {{ pass.backgroundColorName }};
color: {{ pass.foregroundColorName }};
padding:12px;
border-radius:10px;
margin-left: auto;
margin-right: auto;
margin-top: 10px;
margin-bottom: 10px;
width: 332px;
">
<!-- header -->
<div>
<table style="border-collapse: collapse;">
<tr>
<td rowspan="2" style="vertical-align:center;">
{% if pass.logoUrl %}
<img src="{{ pass.logoUrl }}" style="max-width:160px; max-height:50px;"/>
{% endif %}
</td>
<td rowspan="2" style="vertical-align:center; font-size:120%; font-weight:bold; width:100%;">{{ pass.logoText }}</td>
{% for field in pass.headerFields %}
<td style="white-space: nowrap; color: {{ pass.labelColorName }}; padding-bottom:0px;">{{ field.label }}</td>
{% endfor %}
</tr><tr>
{% for field in pass.headerFields %}
<td style="font-size: 120%; padding-top:0px;">{{ field.value }}</td>
{% endfor %}
</tr>
</table>
</div>
<hr/>
<div>
<table style="width:100%; border-collapse: collapse;">
<tr>
{% for field in pass.primaryFields%}
<td style="white-space: nowrap; color: {{ pass.labelColorName }}; padding-bottom:0px;">{{ field.label }}</td>
{% endfor %}
{% if pass.thumbnailUrl %}
<td rowspan="2"><img src="{{ pass.thumbnailUrl }}"/></td>
{% endif %}
</tr><tr style="font-size: 120%;">
{% for field in pass.primaryFields %}
<td style="vertical-align:top; padding-top:0px;">{{ field.value }}</td>
{% endfor %}
</tr>
</table>
</div>
<!-- secondary fields -->
<div style="padding-top:4px;">
<table style="width:100%; border-collapse: collapse;">
<tr>
{% for field in pass.secondaryFields %}
<td style="white-space: nowrap; color: {{ pass.labelColorName }}; padding-bottom:0px;">{{ field.label }}</td>
{% endfor %}
</tr><tr style="font-size: 120%;">
{% for field in pass.secondaryFields %}
<td style="vertical-align:top; padding-top:0px;">{{ field.value }}</td>
{% endfor %}
</tr>
</table>
</div>
<!-- auxiliaryFields fields -->
<div style="padding-top:4px;">
<table style="width:100%; border-collapse: collapse;">
<tr>
{% for field in pass.auxiliaryFields %}
<td style="white-space: nowrap; color: {{ pass.labelColorName }}; padding-bottom:0px;">{{ field.label }}</td>
{% endfor %}
</tr><tr style="font-size: 120%;">
{% for field in pass.auxiliaryFields %}
<td style="vertical-align:top; padding-top:0px;">{{ field.value }}</td>
{% endfor %}
</tr>
</table>
</div>
<!-- barcode -->
{% include "org.kde.messageviewer/pkpass/barcode.html" %}
<!-- footer -->
{% if pass.footerUrl %}
<div style="margin-top: 10px;">
<center><img src="{{ pass.footerUrl }}"/></center>
</div>
{% endif %}
<!-- back fields -->
<hr/>
{% for field in pass.backFields %}
<div style="color: {{ pass.labelColorName }};">{{ field.label }}</div>
<div>{{ field.value|safe|linebreaksbr }}</div>
{% endfor %}
</div> <!-- pass background -->
</div> <!-- attachment container -->
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