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

0001 /*
0002     SPDX-FileCopyrightText: 2010-2016 Sune Vuorela <sune@vuorela.dk>
0003 
0004     SPDX-License-Identifier: MIT
0005 */
0006 
0007 #include "prisontest.h"
0008 
0009 #include "barcodeexamplewidget.h"
0010 // Prison
0011 #include <Prison/Barcode>
0012 // Qt
0013 #include <QDebug>
0014 #include <QHBoxLayout>
0015 #include <QLineEdit>
0016 #include <QPushButton>
0017 #include <QSplitter>
0018 
0019 void main_window::data_changed()
0020 {
0021     QString result = m_lineedit->text();
0022     m_dmw->setData(result);
0023     m_qrw->setData(result);
0024     m_39w->setData(result);
0025     m_93w->setData(result);
0026     m_dmcolor->setData(result);
0027     m_qrcolor->setData(result);
0028     m_39color->setData(result);
0029     m_93color->setData(result);
0030     m_nullw->setData(result);
0031 }
0032 
0033 main_window::main_window()
0034 {
0035     QHBoxLayout *lay = new QHBoxLayout();
0036     m_lineedit = new QLineEdit(this);
0037     QPushButton *but = new QPushButton(this);
0038     connect(but, &QPushButton::clicked, this, &main_window::data_changed);
0039     lay->addWidget(m_lineedit);
0040     lay->addWidget(but);
0041 
0042     QVBoxLayout *mainlay = new QVBoxLayout(this);
0043 
0044     m_dmw = new BarcodeExampleWidget(Prison::DataMatrix, this);
0045     m_qrw = new BarcodeExampleWidget(Prison::QRCode, this);
0046     m_39w = new BarcodeExampleWidget(Prison::Code39, this);
0047     m_93w = new BarcodeExampleWidget(Prison::Code93, this);
0048     {
0049         auto dmcolorcode = Prison::Barcode::create(Prison::DataMatrix);
0050         if (dmcolorcode) {
0051             dmcolorcode->setForegroundColor(Qt::red);
0052             dmcolorcode->setBackgroundColor(Qt::darkBlue);
0053             m_dmcolor = new BarcodeExampleWidget(std::move(dmcolorcode), this);
0054         }
0055     }
0056     {
0057         auto qrcolorcode = Prison::Barcode::create(Prison::QRCode);
0058         if (qrcolorcode) {
0059             qrcolorcode->setForegroundColor(Qt::red);
0060             qrcolorcode->setBackgroundColor(Qt::darkBlue);
0061         }
0062         m_qrcolor = new BarcodeExampleWidget(std::move(qrcolorcode), this);
0063     }
0064     {
0065         auto c39colorcode = Prison::Barcode::create(Prison::Code39);
0066         if (c39colorcode) {
0067             c39colorcode->setForegroundColor(Qt::red);
0068             c39colorcode->setBackgroundColor(Qt::darkBlue);
0069         }
0070         m_39color = new BarcodeExampleWidget(std::move(c39colorcode), this);
0071     }
0072     {
0073         auto c93colorcode = Prison::Barcode::create(Prison::Code93);
0074         if (c93colorcode) {
0075             c93colorcode->setForegroundColor(Qt::red);
0076             c93colorcode->setBackgroundColor(Qt::darkBlue);
0077         }
0078         m_93color = new BarcodeExampleWidget(std::move(c93colorcode), this);
0079     }
0080 
0081     m_nullw = new BarcodeExampleWidget(std::nullopt, this);
0082 
0083     QSplitter *splitter = new QSplitter(Qt::Vertical);
0084     splitter->addWidget(m_dmw);
0085     splitter->addWidget(m_qrw);
0086     splitter->addWidget(m_39w);
0087     splitter->addWidget(m_93w);
0088     splitter->addWidget(m_dmcolor);
0089     splitter->addWidget(m_qrcolor);
0090     splitter->addWidget(m_39color);
0091     splitter->addWidget(m_93color);
0092     splitter->addWidget(m_nullw);
0093 
0094     mainlay->addLayout(lay);
0095     mainlay->addWidget(splitter);
0096 
0097     m_lineedit->setText(QStringLiteral("AOEUIAOEUIAOEUI"));
0098     data_changed();
0099 }
0100 
0101 #include "moc_prisontest.cpp"