11#include <QQuickWindow>
20 shape->setResolution(72, 72);
21 shape->setRelayoutBlocked(
true);
22 shape->setFontMatchingDisabled(
true);
26 QScopedPointer<KoSvgTextShape>
shape;
37 int bottomPadding = 2;
41 bool addedShapeToPainter =
false;
45 : QQuickPaintedItem(parent)
48 setImplicitSize(10, 10);
49 setAntialiasing(
true);
50 setOpaquePainting(
true);
64 if (width() == 0 || height() == 0)
return;
65 if (!painter->isActive())
return;
67 if (
d->shape->boundingRect().isEmpty()) {
72 QRectF bbox =
d->shape->selectionBoxes(0,
d->shape->posForIndex(
d->shape->plainText().size())).boundingRect();
73 bbox = bbox.isEmpty()?
d->shape->boundingRect(): bbox;
76 const double newWidth = width()-(
d->leftPadding+
d->rightPadding);
77 const double newLeftPadding = (
d->leftPadding / newWidth) * bbox.width();
78 const double newRightPadding = (
d->rightPadding / newWidth) * bbox.width();
79 const double newHeight = height()-(
d->topPadding+
d->bottomPadding);
80 const double newTopPadding = (
d->topPadding / newHeight) * bbox.height();
81 const double newBottomPadding = (
d->bottomPadding / newHeight) * bbox.height();
83 d->shapePainter->paint(*painter,
84 QRectF(0, 0, width(), height()).toAlignedRect(),
85 bbox.adjusted(-newLeftPadding, -newTopPadding, newRightPadding, newBottomPadding));
141 return d->shape->plainText();
146 return (
d->leftPadding+
d->rightPadding+
d->topPadding+
d->bottomPadding)/4;
243 if (!opaquePainting() && isComponentComplete()) {
244 update(boundingRect().toAlignedRect());
260 if (
d->shape->plainText() ==
text)
263 int length =
d->shape->plainText().size();
265 d->shape->removeText(start,
length);
266 d->shape->insertText(0,
text);
272 const int currentPadding = (
d->leftPadding+
d->rightPadding+
d->topPadding+
d->bottomPadding)/4;
296 QQuickPaintedItem::componentComplete();
298 if (this->window()) {
299 const qreal pixelRatio = this->window()->effectiveDevicePixelRatio();
300 d->shape->setResolution(pixelRatio*72, pixelRatio*72);
302 setOpaquePainting(fillColor().alpha() == 255);
303 if (!
d->shapePainter) {
305 if (!
d->shape->boundingRect().isEmpty()) {
306 d->shapePainter->setShapes({
d->shape.data()});
307 d->addedShapeToPainter =
true;
316 const QRectF bbox =
d->shape->selectionBoxes(0,
d->shape->posForIndex(
d->shape->plainText().size())).boundingRect();
317 return bbox.adjusted(-
d->leftPadding, -
d->topPadding,
d->rightPadding,
d->bottomPadding);
324 if (
d->shape->textProperties() ==
d->props) {
327 d->shape->setPropertiesAtPos(-1,
d->props);
328 d->shape->relayout();
329 if (!
d->addedShapeToPainter &&
d->shapePainter && !
d->shape->boundingRect().isEmpty()) {
330 d->shapePainter->setShapes({
d->shape.data()});
331 d->addedShapeToPainter =
true;
334 update(boundingRect().toAlignedRect());
qreal length(const QPointF &vec)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
A simple solid color shape background.
QColor color() const
Returns the background color.
@ FontFamiliesId
QStringList.
@ FillId
KoSvgText::BackgroundProperty.
@ FontStyleId
KoSvgText::CssSlantData.
@ FontFeatureSettingsId
QStringList.
@ FontVariationSettingsId
QStringList.
@ TextLanguage
a language string.
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
When style is oblique, a custom slant value can be specified for variable fonts.
KoSvgText::AutoValue slantValue
SvgTextLabel(QQuickItem *parent=nullptr)
QScopedPointer< KoSvgTextShape > shape
void setFontSize(qreal fontSize)
void setFontStyle(QFont::Style fontStyle)
void fontWidthChanged(qreal fontWidth)
void languageChanged(QString language)
void fontFamiliesChanged(QStringList)
void setFontWeight(qreal fontWeight)
void fontWeightChanged(qreal fontWeight)
void minimumRectChanged()
QVariantMap fontAxesValues
void setLanguage(QString language)
void setOpenTypeFeatures(QVariantMap openTypeFeatures)
void setFontFamilies(QStringList fontFamilies)
QScopedPointer< KoShapePainter > shapePainter
KoSvgTextProperties props
void setTextColor(QColor textColor)
void fontSlantChanged(qreal fontSlant)
void fontStyleChanged(QFont::Style fontStyle)
void textColorChanged(QColor textColor)
QML_ELEMENTQStringList fontFamilies
void setPadding(int padding)
void setFontAxesValues(QVariantMap fontAxesValues)
const QScopedPointer< Private > d
void fontAxesValuesChanged(QVariantMap fontAxesValues)
void paint(QPainter *painter) override
void setText(QString text)
void fontSizeChanged(qreal fontSize)
void textChanged(QString text)
void componentComplete() override
componentComplete called when all properties have been set. used to avoid relayout being called time ...
void setFontSlant(qreal fontSlant)
QVariantMap openTypeFeatures
void openTypeFeaturesChanged(QVariantMap openTypeFeatures)
void setFontWidth(qreal fontWidth)
void paddingChanged(int padding)