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 slotCharacterInterfaceSelectionChanged ()
 
void slotCharacterPropertiesChanged ()
 
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 30 of file KisTextPropertiesManager.cpp.

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

◆ ~KisTextPropertiesManager()

KisTextPropertiesManager::~KisTextPropertiesManager ( )

Definition at line 36 of file KisTextPropertiesManager.cpp.

37{
38}

Member Function Documentation

◆ setCanvasResourceProvider()

void KisTextPropertiesManager::setCanvasResourceProvider ( KisCanvasResourceProvider * provider)

setCanvasResourceProvider set the canvas resource provider.

Parameters
provider

Definition at line 40 of file KisTextPropertiesManager.cpp.

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

References d, slotCharacterPropertiesChanged(), 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 50 of file KisTextPropertiesManager.cpp.

51{
52 d->interfaceConnectionStore.clear();
53 d->interface = interface;
54 if (d->interface) {
55 d->interfaceConnectionStore.addUniqueConnection(d->interface, SIGNAL(textSelectionChanged()), this, SLOT(slotInterfaceSelectionChanged()));
56 d->interfaceConnectionStore.addUniqueConnection(d->interface, SIGNAL(textCharacterSelectionChanged()), this, SLOT(slotCharacterInterfaceSelectionChanged()));
59 }
60}

References d, slotCharacterInterfaceSelectionChanged(), and slotInterfaceSelectionChanged().

◆ slotCharacterInterfaceSelectionChanged

void KisTextPropertiesManager::slotCharacterInterfaceSelectionChanged ( )
privateslot

Definition at line 112 of file KisTextPropertiesManager.cpp.

113{
114 if (!d->interface || !d->provider) return;
115 KoSvgTextPropertyData charData;
116 if (d->interface->characterPropertiesEnabled()) {
117 QList<KoSvgTextProperties> charProps = d->interface->getCharacterProperties();
118 if (!charProps.isEmpty()) {
119 QSet<KoSvgTextProperties::PropertyId> charPropIds = getTristate(charProps);
120 charData = textDataProperties(charProps, charPropIds);
121 }
122 charData.inheritedProperties = d->interface->getInheritedProperties();
123 charData.spanSelection = d->interface->spanSelection();
124 charData.enabled = true;
125 }
126 d->lastSetCharacterData = charData;
127 d->provider->setCharacterPropertyData(charData);
128}
QSet< KoSvgTextProperties::PropertyId > getTristate(QList< KoSvgTextProperties > props)
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::enabled, getTristate(), KoSvgTextPropertyData::inheritedProperties, KoSvgTextPropertyData::spanSelection, and textDataProperties().

◆ slotCharacterPropertiesChanged

void KisTextPropertiesManager::slotCharacterPropertiesChanged ( )
privateslot

Definition at line 157 of file KisTextPropertiesManager.cpp.

158{
159 if (!d->interface || !d->provider) return;
160 if (!d->interface->characterPropertiesEnabled()) return;
161 KoSvgTextPropertyData textData = d->provider->characterTextPropertyData();
162 if (textData == d->lastSetCharacterData) return;
163
164 KoSvgTextProperties newProps = textData.commonProperties.ownProperties(d->lastSetCharacterData.commonProperties);
165 QSet<KoSvgTextProperties::PropertyId> removeProperties = removedProps(textData, d->lastSetCharacterData);
166
167 if (newProps.isEmpty() && removeProperties.isEmpty()) return;
168 d->interface->setCharacterPropertiesOnSelected(newProps, removeProperties);
169}
QSet< KoSvgTextProperties::PropertyId > removedProps(KoSvgTextPropertyData textData, KoSvgTextPropertyData oldProps)
KoSvgTextProperties ownProperties(const KoSvgTextProperties &parentProperties, bool keepFontSize=false) const
KoSvgTextProperties commonProperties
The properties common between all the selected text.

References KoSvgTextPropertyData::commonProperties, d, KoSvgTextProperties::isEmpty(), KoSvgTextProperties::ownProperties(), and removedProps().

◆ slotInterfaceSelectionChanged

void KisTextPropertiesManager::slotInterfaceSelectionChanged ( )
privateslot

Definition at line 95 of file KisTextPropertiesManager.cpp.

95 {
96 if (!d->interface || !d->provider) return;
97
98 QList<KoSvgTextProperties> props = d->interface->getSelectedProperties();
99 if (props.isEmpty()) return;
100
101 QSet<KoSvgTextProperties::PropertyId> propIds = getTristate(props);
102
103 KoSvgTextPropertyData textData = textDataProperties(props, propIds);
105 textData.enabled = true;
106
107 d->lastSetTextData = textData;
108 d->provider->setTextPropertyData(textData);
109
110}

References d, KoSvgTextPropertyData::enabled, getTristate(), KoSvgTextPropertyData::inheritedProperties, and textDataProperties().

◆ slotTextPropertiesChanged

void KisTextPropertiesManager::slotTextPropertiesChanged ( )
privateslot

Definition at line 143 of file KisTextPropertiesManager.cpp.

144{
145 if (!d->interface || !d->provider) return;
146 if (d->lastSetTextData == d->provider->textPropertyData()) return;
147
148 KoSvgTextPropertyData textData = d->provider->textPropertyData();
149
150 KoSvgTextProperties newProps = textData.commonProperties.ownProperties(d->lastSetTextData.commonProperties);
151 QSet<KoSvgTextProperties::PropertyId> removeProperties = removedProps(textData, d->lastSetTextData);
152
153 if (newProps.isEmpty() && removeProperties.isEmpty()) return;
154 d->interface->setPropertiesOnSelected(newProps, removeProperties);
155}

References KoSvgTextPropertyData::commonProperties, d, KoSvgTextProperties::isEmpty(), KoSvgTextProperties::ownProperties(), and removedProps().

Member Data Documentation

◆ d

QScopedPointer<Private> KisTextPropertiesManager::d
private

Definition at line 53 of file KisTextPropertiesManager.h.


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