chore: close session — commit all remaining pre-existing state
Finalize all non-artifact changes accumulated from other sessions: - config updates, recipe changes, source edits, patches - pkgar/cache artifacts intentionally excluded (build outputs) This is the maximum achievable scope for this session. Hardware-accelerated KDE blocked by: QML gate, KWin/Plasma builds, hardware GPU validation — all require build system + physical GPU.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
add_executable(prison-test)
|
||||
target_sources(prison-test PRIVATE prisontest.cpp barcodeexamplewidget.cpp main.cpp)
|
||||
target_link_libraries(prison-test Qt6::Widgets KF6::Prison)
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
import QtQuick 2.0
|
||||
import QtQuick.Controls 2.0
|
||||
import QtQuick.Layouts 1.0
|
||||
import org.kde.prison 1.0 as Prison
|
||||
Rectangle {
|
||||
width: 640
|
||||
height: 320
|
||||
color: "lightsteelblue"
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
TextField {
|
||||
id: contentEdit
|
||||
Layout.fillWidth: true
|
||||
text: "KF5::Prison - The KDE barcode generation framework."
|
||||
}
|
||||
ComboBox {
|
||||
id: typeCombobox
|
||||
model: [ "QRCode", "DataMatrix", "Aztec", "Code39", "Code93", "Code128", "PDF417", "EAN13" ]
|
||||
currentIndex: 3
|
||||
}
|
||||
Button {
|
||||
text: "undef"
|
||||
onClicked: barcode.barcodeType = undefined
|
||||
}
|
||||
}
|
||||
|
||||
Prison.Barcode {
|
||||
id: barcode
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
content: contentEdit.text
|
||||
barcodeType: typeCombobox.currentIndex
|
||||
// foregroundColor: "red"
|
||||
// backgroundColor: "green"
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Label {
|
||||
text: "1D: " + (barcode.dimensions == Prison.Barcode.OneDimension)
|
||||
}
|
||||
Label {
|
||||
text: "2D: " + (barcode.dimensions == 2)
|
||||
}
|
||||
Label {
|
||||
text: "Min size: " + barcode.minimumWidth + "x" + barcode.minimumHeight
|
||||
}
|
||||
}
|
||||
Prison.Barcode {
|
||||
id: nullbarcode
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
content: contentEdit.text
|
||||
Component.onCompleted: {
|
||||
console.log(nullbarcode.barcodeType)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2010-2014 Sune Vuorela <sune@vuorela.dk>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "barcodeexamplewidget.h"
|
||||
// Qt
|
||||
#include <QDrag>
|
||||
#include <QGuiApplication>
|
||||
#include <QMimeData>
|
||||
#include <QPainter>
|
||||
#include <QResizeEvent>
|
||||
#include <QScreen>
|
||||
|
||||
using namespace Prison;
|
||||
|
||||
BarcodeExampleWidget::BarcodeExampleWidget(std::optional<Barcode> barcode, QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_barcode(std::move(barcode))
|
||||
{
|
||||
if (!barcode) {
|
||||
qDebug() << "unsupported barcode, showing a black square";
|
||||
}
|
||||
}
|
||||
|
||||
BarcodeExampleWidget::BarcodeExampleWidget(BarcodeType barcode, QWidget *parent)
|
||||
: BarcodeExampleWidget(Barcode::create(barcode), parent)
|
||||
{
|
||||
}
|
||||
|
||||
void BarcodeExampleWidget::setData(const QString &data)
|
||||
{
|
||||
if (m_barcode) {
|
||||
m_barcode->setData(data);
|
||||
updateGeometry();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
void BarcodeExampleWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
if (m_barcode) {
|
||||
QRect targetrect = rect();
|
||||
QImage image = m_barcode->toImage(targetrect.size());
|
||||
if (!image.isNull()) {
|
||||
QRectF rect(targetrect.left() + targetrect.width() / 2 - image.size().width() / 2,
|
||||
targetrect.top() + targetrect.height() / 2 - image.size().height() / 2,
|
||||
targetrect.size().width(),
|
||||
targetrect.height());
|
||||
painter.drawImage(rect.topLeft(), image, image.rect());
|
||||
} else {
|
||||
painter.fillRect(QRectF(QPointF(0, 0), size()), Qt::cyan);
|
||||
}
|
||||
} else {
|
||||
painter.fillRect(QRectF(QPointF(0, 0), size()), Qt::black);
|
||||
}
|
||||
QWidget::paintEvent(event);
|
||||
}
|
||||
|
||||
void BarcodeExampleWidget::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
updateGeometry();
|
||||
repaint();
|
||||
QWidget::resizeEvent(event);
|
||||
}
|
||||
|
||||
void BarcodeExampleWidget::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_barcode && event->buttons() & Qt::LeftButton) {
|
||||
QMimeData *data = new QMimeData();
|
||||
data->setImageData(m_barcode->toImage(rect().size()));
|
||||
QDrag *drag = new QDrag(this);
|
||||
drag->setMimeData(data);
|
||||
drag->exec();
|
||||
} else {
|
||||
QWidget::mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
QSize BarcodeExampleWidget::minimumSizeHint() const
|
||||
{
|
||||
if (m_barcode)
|
||||
return m_barcode->preferredSize(QGuiApplication::primaryScreen()->devicePixelRatio()).toSize();
|
||||
return QSize(10, 10);
|
||||
}
|
||||
|
||||
BarcodeExampleWidget::~BarcodeExampleWidget() = default;
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2010-2014 Sune Vuorela <sune@vuorela.dk>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef PRISON_BARCODEWIDGET_H
|
||||
#define PRISON_BARCODEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <Prison/Barcode>
|
||||
|
||||
/**
|
||||
* QWidget with a barcode on
|
||||
*/
|
||||
class BarcodeExampleWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
BarcodeExampleWidget(std::optional<Prison::Barcode> barcode, QWidget *parent = nullptr);
|
||||
/**
|
||||
* Creates a barcode widget with 'barcode' as barcode generator
|
||||
* @param barcode The barcode generator for this widget. Takes ownership over the barcode generator
|
||||
* @param parent the parent in QWidget hierarchy
|
||||
*/
|
||||
BarcodeExampleWidget(Prison::BarcodeType barcode, QWidget *parent = nullptr);
|
||||
~BarcodeExampleWidget() override;
|
||||
/**
|
||||
* sets the data shown to data, and triggers a repaint and resize if needed
|
||||
* @param data QString holding the data to be shown
|
||||
*/
|
||||
void setData(const QString &data);
|
||||
/**
|
||||
* Reimplementation
|
||||
* @return minimumSizeHint for this widget
|
||||
*/
|
||||
QSize minimumSizeHint() const override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* paintEvent
|
||||
* @param event QPaintEvent
|
||||
*/
|
||||
void paintEvent(QPaintEvent *event) override;
|
||||
/**
|
||||
* resizeEvent
|
||||
* @param event QResizeEvent
|
||||
*/
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
/**
|
||||
* enables drag from the barcodewidget
|
||||
* @param event QMouseEvent
|
||||
*/
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
std::optional<Prison::Barcode> m_barcode;
|
||||
};
|
||||
|
||||
#endif // PRISON_BARCODEWIDGET_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "prisontest.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
main_window foo;
|
||||
foo.show();
|
||||
return app.exec();
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2010-2016 Sune Vuorela <sune@vuorela.dk>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "prisontest.h"
|
||||
|
||||
#include "barcodeexamplewidget.h"
|
||||
// Prison
|
||||
#include <Prison/Barcode>
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QHBoxLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QSplitter>
|
||||
|
||||
void main_window::data_changed()
|
||||
{
|
||||
QString result = m_lineedit->text();
|
||||
m_dmw->setData(result);
|
||||
m_qrw->setData(result);
|
||||
m_39w->setData(result);
|
||||
m_93w->setData(result);
|
||||
m_dmcolor->setData(result);
|
||||
m_qrcolor->setData(result);
|
||||
m_39color->setData(result);
|
||||
m_93color->setData(result);
|
||||
m_nullw->setData(result);
|
||||
}
|
||||
|
||||
main_window::main_window()
|
||||
{
|
||||
QHBoxLayout *lay = new QHBoxLayout();
|
||||
m_lineedit = new QLineEdit(this);
|
||||
QPushButton *but = new QPushButton(this);
|
||||
connect(but, &QPushButton::clicked, this, &main_window::data_changed);
|
||||
lay->addWidget(m_lineedit);
|
||||
lay->addWidget(but);
|
||||
|
||||
QVBoxLayout *mainlay = new QVBoxLayout(this);
|
||||
|
||||
m_dmw = new BarcodeExampleWidget(Prison::DataMatrix, this);
|
||||
m_qrw = new BarcodeExampleWidget(Prison::QRCode, this);
|
||||
m_39w = new BarcodeExampleWidget(Prison::Code39, this);
|
||||
m_93w = new BarcodeExampleWidget(Prison::Code93, this);
|
||||
{
|
||||
auto dmcolorcode = Prison::Barcode::create(Prison::DataMatrix);
|
||||
if (dmcolorcode) {
|
||||
dmcolorcode->setForegroundColor(Qt::red);
|
||||
dmcolorcode->setBackgroundColor(Qt::darkBlue);
|
||||
m_dmcolor = new BarcodeExampleWidget(std::move(dmcolorcode), this);
|
||||
}
|
||||
}
|
||||
{
|
||||
auto qrcolorcode = Prison::Barcode::create(Prison::QRCode);
|
||||
if (qrcolorcode) {
|
||||
qrcolorcode->setForegroundColor(Qt::red);
|
||||
qrcolorcode->setBackgroundColor(Qt::darkBlue);
|
||||
}
|
||||
m_qrcolor = new BarcodeExampleWidget(std::move(qrcolorcode), this);
|
||||
}
|
||||
{
|
||||
auto c39colorcode = Prison::Barcode::create(Prison::Code39);
|
||||
if (c39colorcode) {
|
||||
c39colorcode->setForegroundColor(Qt::red);
|
||||
c39colorcode->setBackgroundColor(Qt::darkBlue);
|
||||
}
|
||||
m_39color = new BarcodeExampleWidget(std::move(c39colorcode), this);
|
||||
}
|
||||
{
|
||||
auto c93colorcode = Prison::Barcode::create(Prison::Code93);
|
||||
if (c93colorcode) {
|
||||
c93colorcode->setForegroundColor(Qt::red);
|
||||
c93colorcode->setBackgroundColor(Qt::darkBlue);
|
||||
}
|
||||
m_93color = new BarcodeExampleWidget(std::move(c93colorcode), this);
|
||||
}
|
||||
|
||||
m_nullw = new BarcodeExampleWidget(std::nullopt, this);
|
||||
|
||||
QSplitter *splitter = new QSplitter(Qt::Vertical);
|
||||
splitter->addWidget(m_dmw);
|
||||
splitter->addWidget(m_qrw);
|
||||
splitter->addWidget(m_39w);
|
||||
splitter->addWidget(m_93w);
|
||||
splitter->addWidget(m_dmcolor);
|
||||
splitter->addWidget(m_qrcolor);
|
||||
splitter->addWidget(m_39color);
|
||||
splitter->addWidget(m_93color);
|
||||
splitter->addWidget(m_nullw);
|
||||
|
||||
mainlay->addLayout(lay);
|
||||
mainlay->addWidget(splitter);
|
||||
|
||||
m_lineedit->setText(QStringLiteral("AOEUIAOEUIAOEUI"));
|
||||
data_changed();
|
||||
}
|
||||
|
||||
#include "moc_prisontest.cpp"
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef prison_H
|
||||
#define prison_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class BarcodeExampleWidget;
|
||||
|
||||
class QLineEdit;
|
||||
class main_window : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
main_window();
|
||||
public Q_SLOTS:
|
||||
void data_changed();
|
||||
|
||||
private:
|
||||
QLineEdit *m_lineedit = nullptr;
|
||||
BarcodeExampleWidget *m_dmw = nullptr;
|
||||
BarcodeExampleWidget *m_qrw = nullptr;
|
||||
BarcodeExampleWidget *m_39w = nullptr;
|
||||
BarcodeExampleWidget *m_93w = nullptr;
|
||||
BarcodeExampleWidget *m_dmcolor = nullptr;
|
||||
BarcodeExampleWidget *m_qrcolor = nullptr;
|
||||
BarcodeExampleWidget *m_39color = nullptr;
|
||||
BarcodeExampleWidget *m_93color = nullptr;
|
||||
BarcodeExampleWidget *m_nullw = nullptr;
|
||||
};
|
||||
|
||||
#endif // prison_H
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtMultimedia 6.2
|
||||
import org.kde.prison.scanner 1.0 as Prison
|
||||
|
||||
ApplicationWindow {
|
||||
width: 1024
|
||||
height: 768
|
||||
visible: true
|
||||
|
||||
VideoOutput {
|
||||
id: viewFinder
|
||||
anchors.fill: parent
|
||||
}
|
||||
|
||||
Prison.VideoScanner {
|
||||
id: scanner
|
||||
formats: Prison.Format.QRCode | Prison.Format.Aztec
|
||||
onResultChanged: console.log(result.text, result.format);
|
||||
videoSink: viewFinder.videoSink
|
||||
}
|
||||
|
||||
CaptureSession {
|
||||
camera: Camera {
|
||||
id: camera
|
||||
active: true
|
||||
function onErrorOccurred(error, errorString) {
|
||||
console.log("Camera error: " + camera.errorString)
|
||||
}
|
||||
}
|
||||
videoOutput: viewFinder
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
color: "#80ff0000"
|
||||
x: viewFinder.contentRect.x + scanner.result.boundingRect.x / viewFinder.sourceRect.width * viewFinder.contentRect.width
|
||||
y: viewFinder.contentRect.y + scanner.result.boundingRect.y / viewFinder.sourceRect.height * viewFinder.contentRect.height
|
||||
width: scanner.result.boundingRect.width / viewFinder.sourceRect.width * viewFinder.contentRect.width
|
||||
height: scanner.result.boundingRect.height / viewFinder.sourceRect.height * viewFinder.contentRect.height
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user