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++

Implement signal compressor in text property interfaces to reduce signals being sent to the text property manager.

Wolthera van Hövell tot Westerflierd7086df6522b
diff --git a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
index 6937f111b7..2420893ec3 100644
--- a/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
+++ b/plugins/tools/defaulttool/defaulttool/DefaultTool.cpp
@@ -50,6 +50,7 @@
#include "kis_canvas2.h"
#include "kis_canvas_resource_provider.h"
#include "KisTextPropertiesManager.h"
+#include <kis_signal_compressor.h>
#include <KoInteractionStrategyFactory.h>
#include "kis_document_aware_spin_box_unit_manager.h"
@@ -1933,17 +1934,20 @@ void DefaultTool::explicitUserStrokeEndRequest()
struct Q_DECL_HIDDEN DefaultToolTextPropertiesInterface::Private {
- Private(DefaultTool *parent): parent(parent) {}
+ Private(DefaultTool *parent)
+ : parent(parent)
+ , compressor(10, KisSignalCompressor::POSTPONE){}
DefaultTool *parent;
QList<KoShape*> shapes;
+ KisSignalCompressor compressor;
};
DefaultToolTextPropertiesInterface::DefaultToolTextPropertiesInterface(DefaultTool *parent)
: KoSvgTextPropertiesInterface(parent)
, d(new Private(parent))
{
-
+ connect(&d->compressor, SIGNAL(timeout()), this, SIGNAL(textSelectionChanged()));
}
DefaultToolTextPropertiesInterface::~DefaultToolTextPropertiesInterface()
@@ -1989,19 +1993,19 @@ void DefaultToolTextPropertiesInterface::notifyCursorPosChanged(int pos, int anc
{
Q_UNUSED(pos)
Q_UNUSED(anchor)
- emit textSelectionChanged();
+ d->compressor.start();
}
void DefaultToolTextPropertiesInterface::notifyMarkupChanged()
{
- emit textSelectionChanged();
+ d->compressor.start();
}
void DefaultToolTextPropertiesInterface::notifyShapeChanged(KoShape::ChangeType type, KoShape *shape)
{
Q_UNUSED(type)
Q_UNUSED(shape)
- emit textSelectionChanged();
+ d->compressor.start();
}
void DefaultToolTextPropertiesInterface::clearSelection()
@@ -2023,5 +2027,5 @@ void DefaultToolTextPropertiesInterface::slotSelectionChanged()
Q_FOREACH(KoShape *shape, d->shapes) {
shape->addShapeChangeListener(this);
}
- emit textSelectionChanged();
+ d->compressor.start();
}
diff --git a/plugins/tools/svgtexttool/SvgTextCursor.cpp b/plugins/tools/svgtexttool/SvgTextCursor.cpp
index 1bc54a4462..2933bc27a7 100644
--- a/plugins/tools/svgtexttool/SvgTextCursor.cpp
+++ b/plugins/tools/svgtexttool/SvgTextCursor.cpp
@@ -23,6 +23,7 @@
#include "kis_painting_tweaks.h"
#include "KoCanvasController.h"
#include "KoCanvasResourceProvider.h"
+#include <kis_signal_compressor.h>
#include "kundo2command.h"
#include <QTimer>
@@ -1433,14 +1434,17 @@ void SvgTextCursor::updateCanvasResources()
}
struct SvgTextCursorPropertyInterface::Private {
- Private(SvgTextCursor *parent): parent(parent) {}
+ Private(SvgTextCursor *parent)
+ : parent(parent)
+ , compressor(10, KisSignalCompressor::POSTPONE){}
SvgTextCursor *parent{nullptr};
+ KisSignalCompressor compressor;
};
SvgTextCursorPropertyInterface::SvgTextCursorPropertyInterface(SvgTextCursor *parent)
: KoSvgTextPropertiesInterface(parent), d(new Private(parent))
{
-
+ connect(&d->compressor, SIGNAL(timeout()), this, SIGNAL(textSelectionChanged()));
}
SvgTextCursorPropertyInterface::~SvgTextCursorPropertyInterface()
@@ -1471,5 +1475,5 @@ bool SvgTextCursorPropertyInterface::spanSelection()
void SvgTextCursorPropertyInterface::emitSelectionChange()
{
- emit textSelectionChanged();
+ d->compressor.start();
}