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++
Cleanup KisTextPropertiesManager removing unused functions, adding docs and simplifying singal connections.
Wolthera van Hövell tot Westerflier5d70fc4d898c
diff --git a/libs/ui/KisTextPropertiesManager.cpp b/libs/ui/KisTextPropertiesManager.cppindex b926616759..d29faadf2c 100644--- a/libs/ui/KisTextPropertiesManager.cpp+++ b/libs/ui/KisTextPropertiesManager.cpp@@ -13,15 +13,18 @@#include <KisView.h>#include <kis_canvas2.h>+#include <kis_signal_auto_connection.h>#include <QPointer>struct KisTextPropertiesManager::Private {KisCanvasResourceProvider *provider {nullptr};- QPointer<KisView> view {nullptr};KoSvgTextPropertiesInterface *interface {nullptr};KoSvgTextPropertyData lastSetTextData;++ KisSignalAutoConnectionsStore interfaceConnectionStore;+ KisSignalAutoConnectionsStore providerConnectionStore;};KisTextPropertiesManager::KisTextPropertiesManager(QObject *parent)@@ -34,37 +37,21 @@ KisTextPropertiesManager::~KisTextPropertiesManager(){}-void KisTextPropertiesManager::setView(QPointer<KisView> imageView)-{- //if (d->view) {- // disconnect(d->view->canvasBase()->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(slotShapeSelectionChanged()));- //}-- d->view = imageView;- //if (d->view) {- // connect(d->view->canvasBase()->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(slotShapeSelectionChanged()));- //}-}-void KisTextPropertiesManager::setCanvasResourceProvider(KisCanvasResourceProvider *provider){- if (d->provider) {- disconnect(d->provider, SIGNAL(sigTextPropertiesChanged()), this, SLOT(slotTextPropertiesChanged()));- }+ d->providerConnectionStore.clear();d->provider = provider;if (d->provider) {- connect(d->provider, SIGNAL(sigTextPropertiesChanged()), this, SLOT(slotTextPropertiesChanged()));+ d->providerConnectionStore.addUniqueConnection(d->provider, SIGNAL(sigTextPropertiesChanged()), this, SLOT(slotTextPropertiesChanged()));}}void KisTextPropertiesManager::setTextPropertiesInterface(KoSvgTextPropertiesInterface *interface){- if (d->interface) {- disconnect(d->interface, SIGNAL(textSelectionChanged()), this, SLOT(slotInterfaceSelectionChanged()));- }+ d->interfaceConnectionStore.clear();d->interface = interface;if (d->interface) {- connect(d->interface, SIGNAL(textSelectionChanged()), this, SLOT(slotInterfaceSelectionChanged()));+ d->interfaceConnectionStore.addUniqueConnection(d->interface, SIGNAL(textSelectionChanged()), this, SLOT(slotInterfaceSelectionChanged()));slotInterfaceSelectionChanged();}}@@ -90,39 +77,6 @@ KoSvgTextPropertyData textDataProperties(QList<KoSvgTextProperties> props, QSet<return textData;}-void KisTextPropertiesManager::slotShapeSelectionChanged()-{- if (!d->view- || !d->view->canvasBase()- || !d->view->canvasBase()->selectedShapesProxy()- || !d->view->canvasBase()->selectedShapesProxy()->selection()- || !d->provider) return;---- const QList<KoShape*> shapes = d->view->canvasBase()->selectedShapesProxy()->selection()->selectedEditableShapes();- QList<KoSvgTextProperties> props;- QSet<KoSvgTextProperties::PropertyId> propIds;-- for (auto it = shapes.begin(); it != shapes.end(); it++) {- KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape*>(*it);- if (!textShape) continue;- KoSvgTextProperties p = textShape->textProperties();- props.append(p);- for (int i = 0; i < p.properties().size(); i++) {- propIds.insert(p.properties().at(i));- }- }-- if (props.isEmpty()) return;-- // Find common properties, and mark all non-common properties as tristate.-- KoSvgTextPropertyData textData = textDataProperties(props, propIds);-- d->provider->setTextPropertyData(textData);-}-void KisTextPropertiesManager::slotInterfaceSelectionChanged() {if (!d->interface || !d->provider) return;diff --git a/libs/ui/KisTextPropertiesManager.h b/libs/ui/KisTextPropertiesManager.hindex 17e83b1d44..59f39ca654 100644--- a/libs/ui/KisTextPropertiesManager.h+++ b/libs/ui/KisTextPropertiesManager.h@@ -26,12 +26,23 @@ public:KisTextPropertiesManager(QObject *parent = nullptr);~KisTextPropertiesManager();- void setView(QPointer<KisView> imageView);+ /**+ * @brief setCanvasResourceProvider+ * set the canvas resource provider.+ * @param provider+ */void setCanvasResourceProvider(KisCanvasResourceProvider *provider);+ /**+ * @brief setTextPropertiesInterface+ * set the text properties interface. This should be done on tool activation.+ * On tool deactivation this should be set to a nullptr, so that signals+ * from the text properties manager don't get sent to the deactivated tool if+ * a tool that does not have a text properties interface is currently active.+ * @param interface -- the tool's text property interface.+ */void setTextPropertiesInterface(KoSvgTextPropertiesInterface *interface);private Q_SLOTS:- void slotShapeSelectionChanged();void slotInterfaceSelectionChanged();void slotTextPropertiesChanged();private:diff --git a/libs/ui/KisViewManager.cpp b/libs/ui/KisViewManager.cppindex 8e4b2c72d5..b4f13cebf9 100644--- a/libs/ui/KisViewManager.cpp+++ b/libs/ui/KisViewManager.cpp@@ -535,7 +535,6 @@ void KisViewManager::setCurrentView(KisView *view)d->statusBar.setView(imageView);d->paintingAssistantsManager.setView(imageView);d->mirrorManager.setView(imageView);- d->textPropertyManager.setView(imageView);if (d->currentImageView) {d->currentImageView->notifyCurrentStateChanged(true);