Commit a9bfd527 authored by Volker Krause's avatar Volker Krause
Browse files

Add PDF417 barcode support for tickets

This is needed for example for MÁV train tickets.

Will need KF 5.88 to actually work though.

BUG: 444324
parent 1bda60dd
......@@ -57,15 +57,22 @@ ColumnLayout {
anchors.bottom: barcodeContainer.bottom
color: "white"
// aim at 50x50mm for 2d codes, and 25mm height for 1d codes, if we have the space for it
property bool is1dCode: currentTicket ? currentTicket.ticketTokenType == Ticket.Code128 : false
property bool is1dCode: barcode.dimensions == Prison.Barcode.OneDimension
property bool isNonSquare: is1dCode || barcode.barcodeType == 7 // Prison.Barcode.PDF417 TODO replace once we depend on KF 5.88
// if this gets too wide, we need to rotate by 90°
property bool showVertical: is1dCode && barcodeTargetWidth > root.width
property bool showVertical: isNonSquare && barcodeTargetWidth > root.width
// unrotated barcode sizes
property int barcodeTargetWidth: Math.max(
(is1dCode ? 2 * barcode.implicitWidth : barcode.implicitWidth) + 2 * barcode.anchors.margins,
Screen.pixelDensity * 50)
property int barcodeTargetHeight: is1dCode ? Screen.pixelDensity * 25 : barcodeTargetWidth
property int barcodeTargetWidth: Math.max(barcode.implicitWidth + 2 * barcode.anchors.margins, Screen.pixelDensity * 50)
property int barcodeTargetHeight: {
if (is1dCode) {
return Screen.pixelDensity * 25;
}
if (isNonSquare) {
return barcode.implicitHeight + 2 * barcode.anchors.margins;
}
return barcodeTargetWidth;
}
implicitWidth: (showVertical ? barcodeTargetHeight : barcodeTargetWidth) + 2 * Kirigami.Units.smallSpacing
implicitHeight: visible ? (showVertical ? barcodeTargetWidth : barcodeTargetHeight) + 2 * Kirigami.Units.smallSpacing : 0
......@@ -91,6 +98,7 @@ ColumnLayout {
case Ticket.AztecCode: return Prison.Barcode.Aztec;
case Ticket.Code128: return Prison.Barcode.Code128;
case Ticket.DataMatrix: return Prison.Barcode.DataMatrix;
case Ticket.PDF417: return 7; // Prison.Barcode.PDF417; TODO replace once we depend on KF 5.88
}
return Prison.Barcode.Null;
}
......
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