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,9 @@
|
||||
ecm_add_qml_module(prisonquickplugin URI org.kde.prison VERSION 1.0 DEPENDENCIES QtQuick GENERATE_PLUGIN_SOURCE)
|
||||
|
||||
target_sources(prisonquickplugin PRIVATE
|
||||
barcodequickitem.cpp
|
||||
barcodequickitem.h
|
||||
)
|
||||
target_link_libraries(prisonquickplugin PRIVATE Qt6::Quick KF6::Prison)
|
||||
|
||||
ecm_finalize_qml_module(prisonquickplugin)
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "barcodequickitem.h"
|
||||
|
||||
#include <QGuiApplication>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
|
||||
using namespace Prison;
|
||||
|
||||
BarcodeQuickItem::BarcodeQuickItem(QQuickItem *parent)
|
||||
: QQuickPaintedItem(parent)
|
||||
{
|
||||
}
|
||||
|
||||
BarcodeQuickItem::~BarcodeQuickItem() = default;
|
||||
|
||||
QVariant BarcodeQuickItem::content() const
|
||||
{
|
||||
return m_content;
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::setContent(const QVariant &content)
|
||||
{
|
||||
if (m_content == content) {
|
||||
return;
|
||||
}
|
||||
m_content = content;
|
||||
Q_EMIT contentChanged();
|
||||
updateBarcode();
|
||||
}
|
||||
|
||||
QJSValue BarcodeQuickItem::barcodeType() const
|
||||
{
|
||||
if (m_type) {
|
||||
return static_cast<BarcodeType>(m_type.value());
|
||||
}
|
||||
return QJSValue();
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::setBarcodeType(const QJSValue &type)
|
||||
{
|
||||
if (!type.isNumber()) {
|
||||
if (m_type) {
|
||||
m_type.reset();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
auto enumType = static_cast<Prison::BarcodeType>(type.toInt());
|
||||
if (enumType == m_type) {
|
||||
return;
|
||||
}
|
||||
m_type = enumType;
|
||||
}
|
||||
Q_EMIT barcodeTypeChanged();
|
||||
m_barcode.reset();
|
||||
updateBarcode();
|
||||
}
|
||||
|
||||
QColor BarcodeQuickItem::foregroundColor() const
|
||||
{
|
||||
return m_fgColor;
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::setForegroundColor(const QColor &color)
|
||||
{
|
||||
if (m_fgColor == color) {
|
||||
return;
|
||||
}
|
||||
m_fgColor = color;
|
||||
Q_EMIT foregroundColorChanged();
|
||||
updateBarcode();
|
||||
}
|
||||
|
||||
QColor BarcodeQuickItem::backgroundColor() const
|
||||
{
|
||||
return m_bgColor;
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::setBackgroundColor(const QColor &color)
|
||||
{
|
||||
if (m_bgColor == color) {
|
||||
return;
|
||||
}
|
||||
m_bgColor = color;
|
||||
Q_EMIT backgroundColorChanged();
|
||||
updateBarcode();
|
||||
}
|
||||
|
||||
BarcodeQuickItem::Dimensions Prison::BarcodeQuickItem::dimensions() const
|
||||
{
|
||||
if (m_barcode)
|
||||
return static_cast<BarcodeQuickItem::Dimensions>(m_barcode->dimensions());
|
||||
return BarcodeQuickItem::Dimensions::NoDimensions;
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::paint(QPainter *painter)
|
||||
{
|
||||
if (!m_barcode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto w_max = std::max(minimumWidth(), width());
|
||||
const auto h_max = std::max(minimumHeight(), height());
|
||||
const auto img = m_barcode->toImage(QSizeF(w_max, h_max));
|
||||
const auto x = (w_max - img.width()) / 2;
|
||||
const auto y = (h_max - img.height()) / 2;
|
||||
painter->setRenderHint(QPainter::SmoothPixmapTransform, false);
|
||||
painter->drawImage(QRectF(x, y, img.width(), img.height()), img, img.rect());
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::componentComplete()
|
||||
{
|
||||
QQuickPaintedItem::componentComplete();
|
||||
updateBarcode();
|
||||
}
|
||||
|
||||
qreal BarcodeQuickItem::minimumHeight() const
|
||||
{
|
||||
return m_barcode ? m_barcode->minimumSize().height() : 0;
|
||||
}
|
||||
|
||||
qreal BarcodeQuickItem::minimumWidth() const
|
||||
{
|
||||
return m_barcode ? m_barcode->minimumSize().width() : 0;
|
||||
}
|
||||
|
||||
bool BarcodeQuickItem::isEmpty() const
|
||||
{
|
||||
switch (m_content.userType()) {
|
||||
case QMetaType::QString:
|
||||
return m_content.toString().isEmpty();
|
||||
case QMetaType::QByteArray:
|
||||
return m_content.toByteArray().isEmpty();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void BarcodeQuickItem::updateBarcode()
|
||||
{
|
||||
if (!isComponentComplete()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isEmpty() || !m_type) {
|
||||
m_barcode.reset();
|
||||
update();
|
||||
Q_EMIT dimensionsChanged();
|
||||
return;
|
||||
}
|
||||
if (!m_barcode) {
|
||||
m_barcode = Prison::Barcode::create(m_type.value());
|
||||
}
|
||||
if (!m_barcode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_content.userType() == QMetaType::QString) {
|
||||
m_barcode->setData(m_content.toString());
|
||||
} else {
|
||||
m_barcode->setData(m_content.toByteArray());
|
||||
}
|
||||
m_barcode->setForegroundColor(m_fgColor);
|
||||
m_barcode->setBackgroundColor(m_bgColor);
|
||||
const auto size = m_barcode->preferredSize(QGuiApplication::primaryScreen()->devicePixelRatio());
|
||||
setImplicitSize(size.width(), size.height());
|
||||
|
||||
update();
|
||||
Q_EMIT dimensionsChanged();
|
||||
}
|
||||
|
||||
#include "moc_barcodequickitem.cpp"
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org>
|
||||
|
||||
SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef PRISON_BARCODEQUICKITEM_H
|
||||
#define PRISON_BARCODEQUICKITEM_H
|
||||
|
||||
#include <Prison/Barcode>
|
||||
|
||||
#include <QColor>
|
||||
#include <QQuickPaintedItem>
|
||||
|
||||
#include <qqmlregistration.h>
|
||||
|
||||
namespace Prison
|
||||
{
|
||||
|
||||
class BarcodeQuickItem : public QQuickPaintedItem
|
||||
{
|
||||
Q_OBJECT
|
||||
QML_ELEMENT
|
||||
QML_NAMED_ELEMENT(Barcode)
|
||||
Q_PROPERTY(QVariant content READ content WRITE setContent NOTIFY contentChanged)
|
||||
Q_PROPERTY(QJSValue barcodeType READ barcodeType WRITE setBarcodeType NOTIFY barcodeTypeChanged)
|
||||
Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor NOTIFY foregroundColorChanged)
|
||||
Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor NOTIFY backgroundColorChanged)
|
||||
Q_PROPERTY(Dimensions dimensions READ dimensions NOTIFY dimensionsChanged)
|
||||
/**
|
||||
* @see Prison::Barcode::minimumSize()
|
||||
* @since 5.69
|
||||
*/
|
||||
Q_PROPERTY(qreal minimumHeight READ minimumHeight NOTIFY implicitHeightChanged)
|
||||
/**
|
||||
* @see Prison::Barcode::minimumSize()
|
||||
* @since 5.69
|
||||
*/
|
||||
Q_PROPERTY(qreal minimumWidth READ minimumWidth NOTIFY implicitWidthChanged)
|
||||
|
||||
public:
|
||||
enum BarcodeType {
|
||||
QRCode = Prison::QRCode,
|
||||
DataMatrix = Prison::DataMatrix,
|
||||
Aztec = Prison::Aztec,
|
||||
Code39 = Prison::Code39,
|
||||
Code93 = Prison::Code93,
|
||||
Code128 = Prison::Code128,
|
||||
PDF417 = Prison::PDF417,
|
||||
EAN13 = Prison::EAN13,
|
||||
};
|
||||
Q_ENUM(BarcodeType)
|
||||
explicit BarcodeQuickItem(QQuickItem *parent = nullptr);
|
||||
~BarcodeQuickItem() override;
|
||||
|
||||
QVariant content() const;
|
||||
void setContent(const QVariant &data);
|
||||
|
||||
QJSValue barcodeType() const;
|
||||
void setBarcodeType(const QJSValue &type);
|
||||
|
||||
QColor foregroundColor() const;
|
||||
void setForegroundColor(const QColor &color);
|
||||
QColor backgroundColor() const;
|
||||
void setBackgroundColor(const QColor &color);
|
||||
|
||||
enum Dimensions {
|
||||
NoDimensions,
|
||||
OneDimension,
|
||||
TwoDimensions,
|
||||
};
|
||||
Q_ENUM(Dimensions)
|
||||
Dimensions dimensions() const;
|
||||
|
||||
void paint(QPainter *painter) override;
|
||||
void componentComplete() override;
|
||||
|
||||
qreal minimumHeight() const;
|
||||
qreal minimumWidth() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void contentChanged();
|
||||
void barcodeTypeChanged();
|
||||
void foregroundColorChanged();
|
||||
void backgroundColorChanged();
|
||||
void dimensionsChanged();
|
||||
|
||||
private:
|
||||
bool isEmpty() const;
|
||||
void updateBarcode();
|
||||
|
||||
QVariant m_content;
|
||||
std::optional<Barcode> m_barcode;
|
||||
QColor m_fgColor = Qt::black;
|
||||
QColor m_bgColor = Qt::white;
|
||||
std::optional<Prison::BarcodeType> m_type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // PRISON_BARCODEQUICKITEM_H
|
||||
Reference in New Issue
Block a user