Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Simplify the KoShapeQuickLabel and SvgTextLabel related code to speed it up.

Wolthera van Hövell tot Westerflier57d1c89b3c56
diff --git a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
index dc2d95ba5c..e695c4a34e 100644
--- a/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
+++ b/plugins/dockers/textproperties/KoShapeQtQuickLabel.cpp
@@ -96,14 +96,13 @@ KoShapeQtQuickLabel::~KoShapeQtQuickLabel()
void KoShapeQtQuickLabel::paint(QPainter *painter)
{
- KIS_SAFE_ASSERT_RECOVER_RETURN(d->shapePainter);
+ if (!d->shapePainter) return;
if (!painter->isActive()) return;
const QRectF bbox = d->documentRect.isValid()? d->documentRect: d->shapePainter->contentRect();
const QRectF bounds = QRectF(0, 0, width(), height());
- painter->save();
+
if (d->shapes.isEmpty()) {
- painter->restore();
return;
}
@@ -111,8 +110,6 @@ void KoShapeQtQuickLabel::paint(QPainter *painter)
bounds.toAlignedRect(),
d->adjustBBoxToScaling(bbox, bounds));
- painter->restore();
-
}
QString KoShapeQtQuickLabel::svgData() const
@@ -243,7 +240,7 @@ void KoShapeQtQuickLabel::updateShapes()
void KoShapeQtQuickLabel::callUpdateIfComplete()
{
- if (isComponentComplete()) {
+ if (isComponentComplete() && isVisible()) {
update(boundingRect().toAlignedRect());
}
}
diff --git a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
index 750aa0ef73..7e984f9cdd 100644
--- a/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
+++ b/plugins/dockers/textproperties/qml/FontResourceDropdown.qml
@@ -44,7 +44,6 @@ Button {
/// When updating the model wrapper, the "model" doesn't always update on the delegate, so we need to manually load
/// the metadata from the modelwrapper.
width: fontResourceView.listWidth;
- height: implicitContentHeight;
highlighted: familyCmb.highlightedIndex === model.index;
Component.onCompleted: {
@@ -70,7 +69,7 @@ Button {
svgData: fontDelegateItem.sample;
foregroundColor: highlighted? palette.highlightedText: palette.text;
fullColor: colorBitmap || colorCLRV0 || colorCLRV1 || colorSVG;
- implicitHeight: padding*5;
+ implicitHeight: padding*4;
Label {
id: nameLabel;
diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml
index a3531c3cd1..17462befc5 100644
--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml
+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
Control {
id: root;
- height: visible? implicitHeight: 0;
+ height: implicitHeight;
implicitHeight: layout.height + padding*2;
clip: true;
property string display;
diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
index e932fb5841..245c722553 100644
--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
@@ -117,8 +117,8 @@ TextPropertyBase {
ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval;
delegate: OpenTypeFeatureDelegate {
+ width: ListView.view.width;
display: modelData.display;
- width: activeFeatureControl.width;
toolTip: display;
sample: activeFeatureDelegate.sample;
tag: activeFeatureDelegate.tag;
@@ -177,8 +177,8 @@ TextPropertyBase {
display: model.display;
toolTip: model.toolTip;
sample: model.sample;
+ width: ListView.view.width;
tag: model.tag;
- width: cmbAvailableFeatures.width;
fontFamilies: properties.fontFamilies;
fontWeight: properties.fontWeight;
fontStyle: properties.fontStyle.style;
@@ -245,8 +245,9 @@ TextPropertyBase {
property string highlightedTag;
contentItem: ListView {
model: featureTxtEdit.filterModel;
- implicitHeight: contentHeight;
clip: true;
+ implicitHeight: contentHeight;
+ width: completerPopup.width;
ScrollBar.vertical: ScrollBar {
}
@@ -257,9 +258,8 @@ TextPropertyBase {
display: model.display;
toolTip: model.toolTip;
sample: model.sample;
+ width: ListView.view.width;
tag: model.tag;
- height: implicitHeight;
- width: featureTxtEdit.width;
fontFamilies: properties.fontFamilies;
fontWeight: properties.fontWeight;
fontStyle: properties.fontStyle.style;
diff --git a/qmlmodules/components/SvgTextLabel.cpp b/qmlmodules/components/SvgTextLabel.cpp
index ab830c3a35..c82519f024 100644
--- a/qmlmodules/components/SvgTextLabel.cpp
+++ b/qmlmodules/components/SvgTextLabel.cpp
@@ -240,7 +240,7 @@ void SvgTextLabel::setTextColor(QColor textColor)
d->shape->setBackground(QSharedPointer<KoColorBackground>(new KoColorBackground(textColor)));
d->props.setProperty(KoSvgTextProperties::FillId, d->shape->textProperties().property(KoSvgTextProperties::FillId));
emit textColorChanged(textColor);
- if (!opaquePainting() && isComponentComplete()) {
+ if (!opaquePainting() && isComponentComplete() && isVisible()) {
update(boundingRect().toAlignedRect());
}
}
@@ -330,6 +330,8 @@ void SvgTextLabel::updateShape()
d->shapePainter->setShapes({d->shape.data()});
d->addedShapeToPainter = true;
}
- update(boundingRect().toAlignedRect());
+ if (isVisible()) {
+ update(boundingRect().toAlignedRect());
+ }
emit minimumRectChanged();
}