KPkPass

barcode.cpp
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "barcode.h"
8#include "pass.h"
9#include "pass_p.h"
10
11#include <QJsonObject>
12
13using namespace KPkPass;
14
15namespace KPkPass
16{
17class BarcodePrivate
18{
19public:
20 const Pass *pass = nullptr;
21 QJsonObject obj;
22};
23}
24
25Barcode::Barcode()
26 : d(new BarcodePrivate)
27{
28}
29
30Barcode::Barcode(const QJsonObject &obj, const Pass *pass)
31 : d(new BarcodePrivate)
32{
33 d->pass = pass;
34 d->obj = obj;
35}
36
37Barcode::~Barcode() = default;
38
39QString Barcode::alternativeText() const
40{
41 if (d->pass) {
42 return d->pass->d->message(d->obj.value(QLatin1StringView("altText")).toString());
43 }
44 return {};
45}
46
47Barcode::Format KPkPass::Barcode::format() const
48{
49 const auto format = d->obj.value(QLatin1StringView("format")).toString();
50 if (format == QLatin1StringView("PKBarcodeFormatQR")) {
51 return QR;
52 } else if (format == QLatin1StringView("PKBarcodeFormatPDF417")) {
53 return PDF417;
54 } else if (format == QLatin1StringView("PKBarcodeFormatAztec")) {
55 return Aztec;
56 } else if (format == QLatin1StringView("PKBarcodeFormatCode128")) {
57 return Code128;
58 }
59 return Invalid;
60}
61
62QString Barcode::message() const
63{
64 return d->obj.value(QLatin1StringView("message")).toString();
65}
66
67QString Barcode::messageEncoding() const
68{
69 return d->obj.value(QLatin1StringView("messageEncoding")).toString();
70}
71
72#include "moc_barcode.cpp"
Base class for a pkpass file.
Definition pass.h:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:53:41 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.