Krita Source Code Documentation
Loading...
Searching...
No Matches
KisTextPropertiesManager Class Reference

The KisTextPropertyManager class. More...

#include <KisTextPropertiesManager.h>

+ Inheritance diagram for KisTextPropertiesManager:

Classes

struct  Private
 

Public Member Functions

 KisTextPropertiesManager (QObject *parent=nullptr)
 
void setCanvasResourceProvider (KisCanvasResourceProvider *provider)
 setCanvasResourceProvider set the canvas resource provider.
 
void setTextPropertiesInterface (KoSvgTextPropertiesInterface *interface)
 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.
 
 ~KisTextPropertiesManager ()
 

Private Slots

void slotInterfaceSelectionChanged ()
 
void slotTextPropertiesChanged ()
 

Private Attributes

QScopedPointer< Privated
 

Detailed Description

The KisTextPropertyManager class.

This class handles taking text property data from the currently selected text objects and then setting it on the resource provider.

Definition at line 22 of file KisTextPropertiesManager.h.

Constructor & Destructor Documentation

◆ KisTextPropertiesManager()

KisTextPropertiesManager::KisTextPropertiesManager ( QObject * parent = nullptr)

Definition at line 29 of file KisTextPropertiesManager.cpp.

30 : QObject(parent)
31 , d(new Private)
32{
33}
QScopedPointer< Private > d

◆ ~KisTextPropertiesManager()

KisTextPropertiesManager::~KisTextPropertiesManager ( )

Definition at line 35 of file KisTextPropertiesManager.cpp.

36{
37}

Member Function Documentation

◆ setCanvasResourceProvider()

void KisTextPropertiesManager::setCanvasResourceProvider ( KisCanvasResourceProvider * provider)

setCanvasResourceProvider set the canvas resource provider.

Parameters
provider

Definition at line 39 of file KisTextPropertiesManager.cpp.

40{
41 d->providerConnectionStore.clear();
42 d->provider = provider;
43 if (d->provider) {
44 d->providerConnectionStore.addUniqueConnection(d->provider, SIGNAL(sigTextPropertiesChanged()), this, SLOT(slotTextPropertiesChanged()));
45 }
46}

References d, and slotTextPropertiesChanged().

◆ setTextPropertiesInterface()

void KisTextPropertiesManager::setTextPropertiesInterface ( KoSvgTextPropertiesInterface * interface)

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.

Parameters
interface– the tool's text property interface.

Definition at line 48 of file KisTextPropertiesManager.cpp.

49{
50 d->interfaceConnectionStore.clear();
51 d->interface = interface;
52 if (d->interface) {
53 d->interfaceConnectionStore.addUniqueConnection(d->interface, SIGNAL(textSelectionChanged()), this, SLOT(slotInterfaceSelectionChanged()));
55 }
56}

References d, and slotInterfaceSelectionChanged().

◆ slotInterfaceSelectionChanged

void KisTextPropertiesManager::slotInterfaceSelectionChanged ( )
privateslot

Definition at line 79 of file KisTextPropertiesManager.cpp.

79 {
80 if (!d->interface || !d->provider) return;
81
82 QList<KoSvgTextProperties> props = d->interface->getSelectedProperties();
83 if (props.isEmpty()) return;
84
85 QSet<KoSvgTextProperties::PropertyId> propIds;
86
87 for (auto it = props.begin(); it != props.end(); it++) {
89 for (int i = 0; i < p.properties().size(); i++) {
90 propIds.insert(p.properties().at(i));
91 }
92 }
93
94 KoSvgTextPropertyData textData = textDataProperties(props, propIds);
95 textData.inheritedProperties = d->interface->getInheritedProperties();
96 textData.spanSelection = d->interface->spanSelection();
97
98 d->lastSetTextData = textData;
99 d->provider->setTextPropertyData(textData);
100
101}
const Params2D p
KoSvgTextPropertyData textDataProperties(QList< KoSvgTextProperties > props, QSet< KoSvgTextProperties::PropertyId > propIds)
The KoSvgTextPropertyData struct.
bool spanSelection
Whether we're currently selecting a span of text as opposed to editing the whole paragraph.
KoSvgTextProperties inheritedProperties
The properties that are inherited, so that widgets may be set correctly.

References d, KoSvgTextPropertyData::inheritedProperties, p, KoSvgTextPropertyData::spanSelection, and textDataProperties().

◆ slotTextPropertiesChanged

void KisTextPropertiesManager::slotTextPropertiesChanged ( )
privateslot

Definition at line 103 of file KisTextPropertiesManager.cpp.

104{
105 if (!d->interface || !d->provider) return;
106 if (d->lastSetTextData == d->provider->textPropertyData()) return;
107
108 KoSvgTextPropertyData textData = d->provider->textPropertyData();
109
110 KoSvgTextProperties newProps = textData.commonProperties.ownProperties(d->lastSetTextData.commonProperties);
111 QSet<KoSvgTextProperties::PropertyId> removeProperties;
112
113 QList<KoSvgTextProperties::PropertyId> oldPropIds = d->lastSetTextData.commonProperties.properties();
114 oldPropIds.append(d->lastSetTextData.tristate.values());
115 for (auto it = oldPropIds.begin(); it != oldPropIds.end(); it++) {
117 if (!textData.commonProperties.hasProperty(p) && !textData.tristate.contains(p)) {
118 removeProperties.insert(p);
119 }
120 }
121
122 if (newProps.isEmpty() && removeProperties.isEmpty()) return;
123 d->interface->setPropertiesOnSelected(newProps, removeProperties);
124}
bool hasProperty(PropertyId id) const
KoSvgTextProperties ownProperties(const KoSvgTextProperties &parentProperties, bool keepFontSize=false) const
KoSvgTextProperties commonProperties
The properties common between all the selected text.
QSet< KoSvgTextProperties::PropertyId > tristate
The properties that are not common (tri-state) between the selected text.

References KoSvgTextPropertyData::commonProperties, d, KoSvgTextProperties::hasProperty(), KoSvgTextProperties::isEmpty(), KoSvgTextProperties::ownProperties(), p, and KoSvgTextPropertyData::tristate.

Member Data Documentation

◆ d

QScopedPointer<Private> KisTextPropertiesManager::d
private

Definition at line 51 of file KisTextPropertiesManager.h.


The documentation for this class was generated from the following files: