The KoShapeQtQuickLabel class.
More...
#include <KoShapeQtQuickLabel.h>
The KoShapeQtQuickLabel class.
A QQuickPaintedItem that will load SVG as KoShapes and paint them.
Definition at line 17 of file KoShapeQtQuickLabel.h.
◆ ScalingType
| Enumerator |
|---|
| Fit | Default koshapepainter behaviour, fit whole document into widget bounds.
|
| FitWidth | Scale document view to document width. Use alignment to position top or bottom on the document.
|
| FitHeight | Scale document view to document height. Use alignment to position left or right on the document.
|
Definition at line 34 of file KoShapeQtQuickLabel.h.
34 {
38 };
@ FitWidth
Scale document view to document width. Use alignment to position top or bottom on the document.
@ Fit
Default koshapepainter behaviour, fit whole document into widget bounds.
@ FitHeight
Scale document view to document height. Use alignment to position left or right on the document.
◆ KoShapeQtQuickLabel()
| KoShapeQtQuickLabel::KoShapeQtQuickLabel |
( |
QQuickItem * | parent = nullptr | ) |
|
◆ ~KoShapeQtQuickLabel()
| KoShapeQtQuickLabel::~KoShapeQtQuickLabel |
( |
| ) |
|
◆ alignment()
| Qt::Alignment KoShapeQtQuickLabel::alignment |
( |
| ) |
const |
alignment
- Returns
- how to align the document viewport when using FillWidth or FillHeight as the scaling type.
Definition at line 212 of file KoShapeQtQuickLabel.cpp.
References d.
◆ alignmentChanged
| void KoShapeQtQuickLabel::alignmentChanged |
( |
| ) |
|
|
signal |
◆ callUpdateIfComplete
| void KoShapeQtQuickLabel::callUpdateIfComplete |
( |
| ) |
|
|
privateslot |
Definition at line 242 of file KoShapeQtQuickLabel.cpp.
243{
244 if (isComponentComplete()) {
245 update(boundingRect().toAlignedRect());
246 }
247}
bool update(QSpinBox *spinBox)
◆ componentComplete()
| void KoShapeQtQuickLabel::componentComplete |
( |
| ) |
|
|
override |
◆ documentRect()
| QRectF KoShapeQtQuickLabel::documentRect |
( |
| ) |
const |
By default, this label will use the content rect as the document view. When this rectangle is valid, it will be used instead.
Definition at line 249 of file KoShapeQtQuickLabel.cpp.
250{
251 return d->documentRect;
252}
References d.
◆ documentRectChanged
| void KoShapeQtQuickLabel::documentRectChanged |
( |
| ) |
|
|
signal |
◆ fillColorChanged
| void KoShapeQtQuickLabel::fillColorChanged |
( |
| ) |
|
|
signal |
◆ foregroundColor()
| QColor KoShapeQtQuickLabel::foregroundColor |
( |
| ) |
const |
foregroundColor This is the color that is used as the fill for the KoShapes when fullColor is set false.
Definition at line 152 of file KoShapeQtQuickLabel.cpp.
References d.
◆ foregroundColorChanged
| void KoShapeQtQuickLabel::foregroundColorChanged |
( |
| ) |
|
|
signal |
◆ fullColor()
| bool KoShapeQtQuickLabel::fullColor |
( |
| ) |
const |
fullColor This controls whether the current shape background will be set to the foreground color or whether it will keep the color it received during parsing of SVG data.
Definition at line 186 of file KoShapeQtQuickLabel.cpp.
References d.
◆ fullColorChanged
| void KoShapeQtQuickLabel::fullColorChanged |
( |
| ) |
|
|
signal |
◆ minimumRect()
| QRectF KoShapeQtQuickLabel::minimumRect |
( |
| ) |
const |
minimumRect Minimum size rectangle, defined by either documentRect or loaded SVG contentRect, with padding attached. Use this when you want sensible minimum size. We cannot set this to implicitsize or the like, because implicit width and height need to be used when setting KoShapeQtQuickLabel as a content item to a QQuickControl.
Definition at line 262 of file KoShapeQtQuickLabel.cpp.
263{
264 const QRectF
bounds =
d->documentRect.isValid()?
d->documentRect:
d->shapePainter?
d->shapePainter->contentRect(): QRectF();
265 return d->addPaddingToBounds(
bounds);
266}
References bounds, and d.
◆ minimumRectChanged
| void KoShapeQtQuickLabel::minimumRectChanged |
( |
| ) |
|
|
signal |
◆ padding()
| int KoShapeQtQuickLabel::padding |
( |
| ) |
const |
Padding of the documentView to the borders. This will add extra padding to the sides. If there's still paintable shape data in that padding, it will be drawn as well.
Definition at line 167 of file KoShapeQtQuickLabel.cpp.
168{
169 return (
d->leftPadding +
d->rightPadding +
d->topPadding +
d->bottomPadding) / 4;
170}
References d.
◆ paddingChanged
| void KoShapeQtQuickLabel::paddingChanged |
( |
| ) |
|
|
signal |
◆ paint()
| void KoShapeQtQuickLabel::paint |
( |
QPainter * | painter | ) |
|
|
override |
Definition at line 97 of file KoShapeQtQuickLabel.cpp.
98{
99 if (!
d->shapePainter)
return;
100 if (!painter->isActive()) return;
101
102 const QRectF bbox =
d->documentRect.isValid()?
d->documentRect:
d->shapePainter->contentRect();
103 const QRectF
bounds = QRectF(0, 0, width(), height());
104
105 if (
d->shapes.isEmpty()) {
106 return;
107 }
108
109 d->shapePainter->paint(*painter,
111 d->adjustBBoxToScaling(bbox,
bounds));
112
113}
References bounds, and d.
◆ scalingType()
◆ scalingTypeChanged
| void KoShapeQtQuickLabel::scalingTypeChanged |
( |
| ) |
|
|
signal |
◆ setAlignment()
| void KoShapeQtQuickLabel::setAlignment |
( |
const Qt::Alignment | align | ) |
|
◆ setDocumentRect()
| void KoShapeQtQuickLabel::setDocumentRect |
( |
const QRectF & | rect | ) |
|
◆ setForegroundColor()
| void KoShapeQtQuickLabel::setForegroundColor |
( |
const QColor & | newForegroundColor | ) |
|
◆ setFullColor()
| void KoShapeQtQuickLabel::setFullColor |
( |
bool | newFullColor | ) |
|
◆ setPadding()
| void KoShapeQtQuickLabel::setPadding |
( |
int | newPadding | ) |
|
Definition at line 172 of file KoShapeQtQuickLabel.cpp.
173{
174 const int currentPadding = (
d->leftPadding +
d->rightPadding +
d->topPadding +
d->bottomPadding) / 4;
175 if (currentPadding == newPadding)
176 return;
177 d->leftPadding = newPadding;
178 d->rightPadding = newPadding;
179 d->topPadding = newPadding;
180 d->bottomPadding = newPadding;
181
184}
References d, minimumRectChanged(), and paddingChanged().
◆ setScalingType()
◆ setSvgData()
| void KoShapeQtQuickLabel::setSvgData |
( |
const QString & | newSvgData | ) |
|
Definition at line 120 of file KoShapeQtQuickLabel.cpp.
121{
122 if (
d->svgData == newSvgData)
123 return;
124 d->svgData = newSvgData;
125
129 QRectF bb = QRectF( 0, 0, 200, 200);
130 QSizeF sz = bb.size();
131 p.setResolution(bb, 72);
132 p.setFillStrokeInheritByDefault(
true);
133
135
136
138
139 if (!
d->shapes.isEmpty()) {
140 qDeleteAll(
d->shapes);
141 }
142
144 d->shapePainter->setShapes(
d->shapes);
145
147
150}
static QDomDocument createDocumentFromSvg(QIODevice *device, QString *errorMsg=0, int *errorLine=0, int *errorColumn=0)
References SvgParser::createDocumentFromSvg(), d, minimumRectChanged(), p, svgDataChanged(), and updateShapes().
◆ svgData()
| QString KoShapeQtQuickLabel::svgData |
( |
| ) |
const |
◆ svgDataChanged
| void KoShapeQtQuickLabel::svgDataChanged |
( |
| ) |
|
|
signal |
◆ updateShapes
| void KoShapeQtQuickLabel::updateShapes |
( |
| ) |
|
|
privateslot |
| const QScopedPointer<Private> KoShapeQtQuickLabel::d |
|
private |
◆ alignment
| Qt::Alignment KoShapeQtQuickLabel::alignment |
|
readwrite |
◆ documentRect
| QRectF KoShapeQtQuickLabel::documentRect |
|
readwrite |
◆ foregroundColor
| QColor KoShapeQtQuickLabel::foregroundColor |
|
readwrite |
◆ fullColor
| bool KoShapeQtQuickLabel::fullColor |
|
readwrite |
◆ minimumRect
| QRectF KoShapeQtQuickLabel::minimumRect |
|
read |
◆ padding
| int KoShapeQtQuickLabel::padding |
|
readwrite |
◆ scalingType
◆ svgData
| QString KoShapeQtQuickLabel::svgData |
|
readwrite |
The documentation for this class was generated from the following files: