File indexing completed on 2024-05-12 05:21:34

0001 /*
0002     SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kpkpass_export.h"
0010 
0011 #include <QMetaType>
0012 #include <QString>
0013 
0014 #include <memory>
0015 
0016 class QJsonObject;
0017 
0018 namespace KPkPass
0019 {
0020 class BarcodePrivate;
0021 class Pass;
0022 
0023 /** A pass barcode element.
0024  *  @see https://developer.apple.com/library/content/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/LowerLevel.html
0025  */
0026 class KPKPASS_EXPORT Barcode
0027 {
0028     Q_GADGET
0029     Q_PROPERTY(QString alternativeText READ alternativeText CONSTANT)
0030     Q_PROPERTY(Format format READ format CONSTANT)
0031     Q_PROPERTY(QString message READ message CONSTANT)
0032     Q_PROPERTY(QString messageEncoding READ messageEncoding CONSTANT)
0033 
0034 public:
0035     enum Format { Invalid, QR, PDF417, Aztec, Code128 };
0036     Q_ENUM(Format)
0037 
0038     Barcode();
0039     ~Barcode();
0040 
0041     /** A human readable version of the barcode data. */
0042     [[nodiscard]] QString alternativeText() const;
0043     /** The barcode type. */
0044     [[nodiscard]] Format format() const;
0045     /** The message encoded in the barcode. */
0046     [[nodiscard]] QString message() const;
0047     /** Encoding used for the message() content. */
0048     [[nodiscard]] QString messageEncoding() const;
0049 
0050 private:
0051     friend class Pass;
0052     explicit Barcode(const QJsonObject &obj, const Pass *file);
0053     std::shared_ptr<BarcodePrivate> d;
0054 };
0055 
0056 }