File indexing completed on 2024-04-28 04:00:29

0001 /*
0002     SPDX-FileCopyrightText: 2010-2014 Sune Vuorela <sune@vuorela.dk>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #ifndef PRISON_BARCODEWIDGET_H
0008 #define PRISON_BARCODEWIDGET_H
0009 
0010 #include <QWidget>
0011 
0012 #include <Prison/Barcode>
0013 
0014 /**
0015  * QWidget with a barcode on
0016  */
0017 class BarcodeExampleWidget : public QWidget
0018 {
0019 public:
0020     BarcodeExampleWidget(std::optional<Prison::Barcode> barcode, QWidget *parent = nullptr);
0021     /**
0022      * Creates a barcode widget with 'barcode' as barcode generator
0023      * @param barcode The barcode generator for this widget. Takes ownership over the barcode generator
0024      * @param parent the parent in QWidget hierarchy
0025      */
0026     BarcodeExampleWidget(Prison::BarcodeType barcode, QWidget *parent = nullptr);
0027     ~BarcodeExampleWidget() override;
0028     /**
0029      * sets the data shown to data, and triggers a repaint and resize if needed
0030      * @param data QString holding the data to be shown
0031      */
0032     void setData(const QString &data);
0033     /**
0034      * Reimplementation
0035      * @return minimumSizeHint for this widget
0036      */
0037     QSize minimumSizeHint() const override;
0038 
0039 protected:
0040     /**
0041      * paintEvent
0042      * @param event QPaintEvent
0043      */
0044     void paintEvent(QPaintEvent *event) override;
0045     /**
0046      * resizeEvent
0047      * @param event QResizeEvent
0048      */
0049     void resizeEvent(QResizeEvent *event) override;
0050     /**
0051      * enables drag from the barcodewidget
0052      * @param event QMouseEvent
0053      */
0054     void mousePressEvent(QMouseEvent *event) override;
0055 
0056 private:
0057     std::optional<Prison::Barcode> m_barcode;
0058 };
0059 
0060 #endif // PRISON_BARCODEWIDGET_H