Prison

barcodequickitem.h
1/*
2 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: MIT
5*/
6
7#ifndef PRISON_BARCODEQUICKITEM_H
8#define PRISON_BARCODEQUICKITEM_H
9
10#include <Prison/Barcode>
11
12#include <QColor>
13#include <QQuickPaintedItem>
14
15#include <qqmlregistration.h>
16
17namespace Prison
18{
19
20class BarcodeQuickItem : public QQuickPaintedItem
21{
23 QML_ELEMENT
24 QML_NAMED_ELEMENT(Barcode)
25 Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged)
26 Q_PROPERTY(QJSValue barcodeType READ barcodeType WRITE setBarcodeType NOTIFY barcodeTypeChanged)
27 Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor NOTIFY foregroundColorChanged)
28 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
29 Q_PROPERTY(Dimensions dimensions READ dimensions NOTIFY dimensionsChanged)
30 /**
31 * @see Prison::Barcode::minimumSize()
32 * @since 5.69
33 */
34 Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY implicitHeightChanged)
35 /**
36 * @see Prison::Barcode::minimumSize()
37 * @since 5.69
38 */
39 Q_PROPERTY(qreal minimumWidth READ minimumWidth NOTIFY implicitWidthChanged)
40
41public:
42 enum BarcodeType {
43 QRCode = Prison::QRCode,
44 DataMatrix = Prison::DataMatrix,
45 Aztec = Prison::Aztec,
46 Code39 = Prison::Code39,
47 Code93 = Prison::Code93,
48 Code128 = Prison::Code128,
49 PDF417 = Prison::PDF417,
50 EAN13 = Prison::EAN13,
51 };
52 Q_ENUM(BarcodeType)
53 explicit BarcodeQuickItem(QQuickItem *parent = nullptr);
54 ~BarcodeQuickItem() override;
55
56 QVariant content() const;
57 void setContent(const QVariant &data);
58
59 QJSValue barcodeType() const;
60 void setBarcodeType(const QJSValue &type);
61
62 QColor foregroundColor() const;
63 void setForegroundColor(const QColor &color);
64 QColor backgroundColor() const;
65 void setBackgroundColor(const QColor &color);
66
67 enum Dimensions {
68 NoDimensions,
69 OneDimension,
70 TwoDimensions,
71 };
72 Q_ENUM(Dimensions)
73 Dimensions dimensions() const;
74
75 void paint(QPainter *painter) override;
76 void componentComplete() override;
77
78 qreal minimumHeight() const;
79 qreal minimumWidth() const;
80
82 void contentChanged();
83 void barcodeTypeChanged();
84 void foregroundColorChanged();
85 void backgroundColorChanged();
86 void dimensionsChanged();
87
88private:
89 bool isEmpty() const;
90 void updateBarcode();
91
92 QVariant m_content;
93 std::optional<Barcode> m_barcode;
94 QColor m_fgColor = Qt::black;
95 QColor m_bgColor = Qt::white;
96 std::optional<Prison::BarcodeType> m_type;
97};
98
99}
100
101#endif // PRISON_BARCODEQUICKITEM_H
Provides classes and methods for generating barcodes.
Definition barcode.h:24
@ PDF417
PDF417 barcode.
Definition prison.h:36
@ QRCode
QRCode 2d barcode.
Definition prison.h:24
@ Code39
Code39 barcode.
Definition prison.h:30
@ EAN13
EAN13 barcode.
Definition prison.h:38
@ DataMatrix
DataMatrix 2d barcode.
Definition prison.h:26
@ Aztec
Aztec 2d barcode.
Definition prison.h:28
@ Code128
Code 128 barcode.
Definition prison.h:34
@ Code93
Code93 barcode.
Definition prison.h:32
Q_ENUM(...)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
void implicitHeightChanged()
void implicitWidthChanged()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:12:17 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.