File indexing completed on 2024-05-19 05:57:13
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 SPDX-License-Identifier: GPL-3.0-or-later 0004 */ 0005 0006 #ifndef QRCODECONTENT_H 0007 #define QRCODECONTENT_H 0008 0009 #include <QVariant> 0010 0011 #include <Prison/Format> 0012 0013 /** Result of a barcode scan. 0014 * Can contain either text or binary data. 0015 */ 0016 class QrCodeContent 0017 { 0018 Q_GADGET 0019 Q_PROPERTY(ContentType contentType READ contentType) 0020 Q_PROPERTY(QString text READ text) 0021 Q_PROPERTY(bool isPlainText READ isPlainText) 0022 public: 0023 QrCodeContent(); 0024 explicit QrCodeContent(const QByteArray &content, Prison::Format::BarcodeFormat format); 0025 explicit QrCodeContent(const QString &content, Prison::Format::BarcodeFormat format); 0026 ~QrCodeContent(); 0027 0028 enum ContentType { 0029 Url, 0030 VCard, 0031 OtpToken, 0032 TransportTicket, 0033 HealthCertificate, 0034 Text, 0035 Binary, 0036 ISBN, 0037 EAN, 0038 WifiSetting, 0039 }; 0040 Q_ENUM(ContentType) 0041 ContentType contentType() const; 0042 0043 /** @c true if the content consists only of plain text, which might also be the case for contentType() != Text. */ 0044 bool isPlainText() const; 0045 QString text() const; 0046 QByteArray binaryContent() const; 0047 0048 private: 0049 QVariant m_content; 0050 Prison::Format::BarcodeFormat m_format; 0051 }; 0052 0053 Q_DECLARE_METATYPE(QrCodeContent) 0054 0055 #endif