|
Krita Source Code Documentation
|
The KoCssStylePreset class. More...
#include <KoCssStylePreset.h>
Inheritance diagram for KoCssStylePreset:Classes | |
| struct | Private |
Public Member Functions | |
| QString | afterText () const |
| The text displayed after the sample, only relevant when in character mode. | |
| Qt::Alignment | alignSample () const |
| QString | beforeText () const |
| The text displayed before the sample. Only relevant when in Character mode. | |
| KoResourceSP | clone () const override |
| QString | defaultFileExtension () const override |
| QString | description () const |
| The description associated with this style. | |
| KoShape * | generateSampleShape () const |
| generateSampleShape This generates the sample textshape from the properties and sample text(s). | |
| KoCssStylePreset (const KoCssStylePreset &rhs) | |
| KoCssStylePreset (const QString &filename) | |
| bool | loadFromDevice (QIODevice *dev, KisResourcesInterfaceSP resourcesInterface) override |
| KoCssStylePreset & | operator= (const KoCssStylePreset &rhs)=delete |
| QString | primaryFontFamily () const |
| primaryFontFamily If a style uses a FontFamily, it may not look as expected when that font family is missing. Typically, we'd use linked resources for this, however, embedding fonts is really complex. | |
| KoSvgTextProperties | properties (int ppi=72, bool removeKraProps=false) const |
| The actual text properties. | |
| QPair< QString, QString > | resourceType () const override |
| QString | sampleSvg () const |
| Returns the sample svg metadata. Use updateThumbnail to update it. | |
| QString | sampleText () const |
| The sample text that is being styled by this preset. | |
| bool | saveToDevice (QIODevice *dev) const override |
| void | setAfterText (const QString &text) |
| set the after text. Call updateThumbnail to update the sample. | |
| void | setBeforeText (const QString &text) |
| set the before text. Call updateThumbnail to update the sample. | |
| void | setDescription (const QString &desc) |
| void | setProperties (const KoSvgTextProperties &properties) |
| set the properties. Call updateThumbnail to update the sample. | |
| void | setSampleText (const QString &text) |
| set the sample. Call updateThumbnail to update the sample. | |
| void | setStoredPPIResolution (const int ppi) |
| void | setStyleType (const QString &type) |
| int | storedPPIResolution () const |
| QString | styleType () const |
| Set the style type, type is either "paragraph" or "character". | |
| void | updateAlignSample () |
| void | updateThumbnail () override |
| updateThumbnail updates the thumbnail for this resource. Reimplement if your thumbnail is something else than the image set with setImage. | |
| ~KoCssStylePreset () | |
Public Member Functions inherited from KoResource | |
| bool | active () const |
| void | addMetaData (QString key, QVariant value) |
| store the given key, value pair in the resource | |
| virtual void | clearSideLoadedResources () |
| virtual QList< KoResourceLoadResult > | embeddedResources (KisResourcesInterfaceSP globalResourcesInterface) const |
| QString | filename () const |
| QImage | image () const |
| bool | isDirty () const |
| virtual bool | isEphemeral () const |
| virtual bool | isSerializable () const |
| KoResource () | |
| KoResource (const KoResource &rhs) | |
| KoResource (const QString &filename) | |
| virtual QList< KoResourceLoadResult > | linkedResources (KisResourcesInterfaceSP globalResourcesInterface) const |
| bool | load (KisResourcesInterfaceSP resourcesInterface) |
| QString | md5Sum (bool generateIfEmpty=true) const |
| QMap< QString, QVariant > | metadata () const |
| get a map with all the metadata | |
| virtual QString | name () const |
| KoResource & | operator= (const KoResource &rhs)=delete |
| bool | permanent () const |
| virtual QList< int > | requiredCanvasResources () const |
| QList< KoResourceLoadResult > | requiredResources (KisResourcesInterfaceSP globalResourcesInterface) const |
| int | resourceId () const |
| bool | save () |
| void | setActive (bool active) |
| void | setDirty (bool value) |
| Mark the preset as modified but not saved. | |
| void | setFilename (const QString &filename) |
| void | setImage (const QImage &image) |
| void | setMD5Sum (const QString &md5sum) |
| Set the md5sum of this resource. It must be in hex-encoded string format. | |
| void | setName (const QString &name) |
| void | setPermanent (bool permanent) |
| void | setResourceId (int id) |
| void | setStorageLocation (const QString &location) |
| void | setValid (bool valid) |
| void | setVersion (int version) |
| virtual QList< KoResourceLoadResult > | sideLoadedResources (KisResourcesInterfaceSP globalResourcesInterface) const |
| KoResourceSignature | signature () const |
| QString | storageLocation () const |
| QList< KoResourceLoadResult > | takeSideLoadedResources (KisResourcesInterfaceSP globalResourcesInterface) |
| virtual QImage | thumbnail () const |
| thumbnail the thumbnail image to use in resource selectors | |
| virtual QString | thumbnailPath () const |
| thumbnailPath returns the path to a separate thumbnail image, outside the actual resource file itself. If the path is relative, it is supposed start in the same location as the resource itself. If it's absolute, that is, it starts with "/", it is from the root of the storage. | |
| bool | valid () const |
| int | version () const |
| Get the version of the resource. | |
| virtual | ~KoResource () |
Public Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| QScopedPointer< Private > | d |
Additional Inherited Members | |
Public Attributes inherited from KoResource | |
| bool | active {true} |
| QString | filename |
| QImage | image |
| QString | md5sum |
| QMap< QString, QVariant > | metadata |
| bool | modified {false} |
| QString | name |
| bool | permanent {false} |
| int | resourceId {-1} |
| QString | storageLocation |
| bool | valid {false} |
| int | version {-1} |
Public Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
The KoCssStylePreset class.
This is a Resource that represents style data. Internally, the style data is stored inside a text shape, allowing us to showcase the style data in context.
Definition at line 23 of file KoCssStylePreset.h.
| KoCssStylePreset::KoCssStylePreset | ( | const QString & | filename | ) |
Definition at line 48 of file KoCssStylePreset.cpp.
References defaultFileExtension(), KoResource::name, and KoResource::setName().
| KoCssStylePreset::KoCssStylePreset | ( | const KoCssStylePreset & | rhs | ) |
Definition at line 59 of file KoCssStylePreset.cpp.
References d, description(), setDescription(), KoResource::setValid(), and updateThumbnail().
| KoCssStylePreset::~KoCssStylePreset | ( | ) |
Definition at line 72 of file KoCssStylePreset.cpp.
| QString KoCssStylePreset::afterText | ( | ) | const |
The text displayed after the sample, only relevant when in character mode.
Definition at line 357 of file KoCssStylePreset.cpp.
References d.
| Qt::Alignment KoCssStylePreset::alignSample | ( | ) | const |
Determines the preferred sample alignment based on the text properties. It's set up so that the alignment anchor of the text is shown.
Definition at line 234 of file KoCssStylePreset.cpp.
References KoResource::metadata, SAMPLE_ALIGN, and v.
| QString KoCssStylePreset::beforeText | ( | ) | const |
The text displayed before the sample. Only relevant when in Character mode.
Definition at line 345 of file KoCssStylePreset.cpp.
References d.
|
overridevirtual |
Implements KoResource.
Definition at line 387 of file KoCssStylePreset.cpp.
References KoCssStylePreset().
|
overridevirtual |
Reimplemented from KoResource.
Definition at line 474 of file KoCssStylePreset.cpp.
| QString KoCssStylePreset::description | ( | ) | const |
The description associated with this style.
Definition at line 112 of file KoCssStylePreset.cpp.
References DESCRIPTION, and KoResource::metadata.
| KoShape * KoCssStylePreset::generateSampleShape | ( | ) | const |
generateSampleShape This generates the sample textshape from the properties and sample text(s).
For character the sample always needs to be set to be a child to ensure that the character property doesn't include the default props.
Definition at line 152 of file KoCssStylePreset.cpp.
References KoPathShape::close(), d, KoSvgTextProperties::defaultProperties(), KoSvgTextProperties::FillId, KoSvgTextProperties::InlineSizeId, KoSvgTextProperties::KraTextStyleResolution, KoSvgTextProperties::KraTextStyleType, KoPathShape::lineTo(), KoPathShape::moveTo(), KoResource::name, KoSvgTextProperties::Opacity, p, KoSvgTextProperties::PaintOrder, KoSvgText::Preserve, KoSvgTextProperties::properties(), KoSvgTextProperties::propertyIsBlockOnly(), KoSvgTextProperties::removeProperty(), SAMPLE_PLACEHOLDER, sampleText(), KoSvgTextProperties::setProperty(), storedPPIResolution(), KoSvgTextProperties::StrokeId, STYLE_TYPE_CHARACTER, STYLE_TYPE_PARAGRAPH, styleType(), KoSvgTextProperties::TextCollapseId, KoSvgTextProperties::TextOrientationId, KoSvgTextProperties::TextWrapId, KoSvgTextProperties::Visiblity, and KoSvgText::Wrap.
|
overridevirtual |
Implements KoResource.
Definition at line 392 of file KoCssStylePreset.cpp.
References KoShape::additionalAttribute(), KoResource::addMetaData(), SvgParser::createDocumentFromSvg(), d, DESC, DESCRIPTION, errorFlake, KoResource::filename, KoSvgTextShape::findNodeIndexForPropertyId(), KoSvgTextShape::findRangeForNodeIndex(), KoSvgTextProperties::FontFamiliesId, KoSvgTextProperties::hasProperty(), KoSvgTextShape::indexForPos(), KoSvgTextProperties::KraTextStyleResolution, KoSvgTextProperties::KraTextStyleType, SvgParser::parseSvg(), KoSvgTextShape::plainText, PRIMARY_FONT_FAMILY, KoSvgTextNodeIndex::properties(), KoSvgTextProperties::property(), KoResource::setName(), setProperties(), SvgParser::setResolution(), SvgParser::setResolveTextPropertiesForTopLevel(), KoResource::setValid(), STORED_PPI, STYLE_TYPE, STYLE_TYPE_PARAGRAPH, styleType(), TITLE, and updateThumbnail().
|
delete |
| QString KoCssStylePreset::primaryFontFamily | ( | ) | const |
primaryFontFamily If a style uses a FontFamily, it may not look as expected when that font family is missing. Typically, we'd use linked resources for this, however, embedding fonts is really complex.
Definition at line 241 of file KoCssStylePreset.cpp.
References KoResource::metadata, and PRIMARY_FONT_FAMILY.
| KoSvgTextProperties KoCssStylePreset::properties | ( | int | ppi = 72, |
| bool | removeKraProps = false ) const |
The actual text properties.
Definition at line 77 of file KoCssStylePreset.cpp.
References d, KoSvgTextProperties::FillId, KoSvgTextProperties::KraTextStyleResolution, KoSvgTextProperties::KraTextStyleType, KoSvgTextProperties::KraTextVersionId, KoSvgTextProperties::Opacity, KoSvgTextProperties::PaintOrder, KoSvgTextProperties::properties(), KoSvgTextProperties::removeProperty(), KoSvgTextProperties::scaleAbsoluteValues(), storedPPIResolution(), KoSvgTextProperties::StrokeId, KoSvgTextProperties::TextOrientationId, and KoSvgTextProperties::Visiblity.
|
overridevirtual |
Implements KoResource.
Definition at line 510 of file KoCssStylePreset.cpp.
References ResourceType::CssStyles.
| QString KoCssStylePreset::sampleSvg | ( | ) | const |
Returns the sample svg metadata. Use updateThumbnail to update it.
Definition at line 369 of file KoCssStylePreset.cpp.
References KoResource::metadata, and SAMPLE_SVG.
| QString KoCssStylePreset::sampleText | ( | ) | const |
The sample text that is being styled by this preset.
Definition at line 140 of file KoCssStylePreset.cpp.
References d.
|
overridevirtual |
Reimplemented from KoResource.
Definition at line 460 of file KoCssStylePreset.cpp.
References DESC, DESCRIPTION, generateSampleShape(), KoResource::metadata, KoResource::name, SvgWriter::save(), and TITLE.
| void KoCssStylePreset::setAfterText | ( | const QString & | text | ) |
set the after text. Call updateThumbnail to update the sample.
Definition at line 362 of file KoCssStylePreset.cpp.
References d, and KoResource::setDirty().
| void KoCssStylePreset::setBeforeText | ( | const QString & | text | ) |
set the before text. Call updateThumbnail to update the sample.
Definition at line 350 of file KoCssStylePreset.cpp.
References d, and KoResource::setDirty().
| void KoCssStylePreset::setDescription | ( | const QString & | desc | ) |
Definition at line 118 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), DESCRIPTION, KoResource::metadata, and KoResource::setDirty().
| void KoCssStylePreset::setProperties | ( | const KoSvgTextProperties & | properties | ) |
set the properties. Call updateThumbnail to update the sample.
Definition at line 100 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), d, KoSvgTextProperties::FontFamiliesId, PRIMARY_FONT_FAMILY, KoSvgTextProperties::properties(), properties(), KoResource::setDirty(), and KoResource::setValid().
| void KoCssStylePreset::setSampleText | ( | const QString & | text | ) |
set the sample. Call updateThumbnail to update the sample.
Definition at line 145 of file KoCssStylePreset.cpp.
References d, and KoResource::setDirty().
| void KoCssStylePreset::setStoredPPIResolution | ( | const int | ppi | ) |
Definition at line 381 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), and STORED_PPI.
| void KoCssStylePreset::setStyleType | ( | const QString & | type | ) |
Definition at line 132 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), KoResource::metadata, KoResource::setDirty(), and STYLE_TYPE.
| int KoCssStylePreset::storedPPIResolution | ( | ) | const |
The resolution that this style is tied to. if this is above 0, then the properties absolute values are scaled by to fit the document resolution. This allows for pixel-relative styles to be created.
Definition at line 375 of file KoCssStylePreset.cpp.
References KoResource::metadata, and STORED_PPI.
| QString KoCssStylePreset::styleType | ( | ) | const |
Set the style type, type is either "paragraph" or "character".
Definition at line 126 of file KoCssStylePreset.cpp.
References KoResource::metadata, STYLE_TYPE, and STYLE_TYPE_PARAGRAPH.
| void KoCssStylePreset::updateAlignSample | ( | ) |
Definition at line 247 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), KoSvgText::AlignEnd, KoSvgText::AlignLastAuto, KoSvgText::AlignLeft, KoSvgText::AlignRight, KoSvgText::AlignStart, KoSvgText::AnchorEnd, KoSvgText::AnchorStart, d, KoSvgTextProperties::DirectionId, KoSvgText::DirectionLeftToRight, KoSvgTextProperties::hasProperty(), KoSvgText::HorizontalTB, KoSvgTextProperties::KraTextStyleType, KoSvgTextProperties::properties(), KoSvgTextProperties::property(), KoSvgTextProperties::propertyOrDefault(), SAMPLE_ALIGN, STYLE_TYPE_PARAGRAPH, styleType(), KoSvgTextProperties::TextAlignAllId, KoSvgTextProperties::TextAlignLastId, KoSvgTextProperties::TextAnchorId, KoSvgText::VerticalRL, and KoSvgTextProperties::WritingModeId.
|
overridevirtual |
updateThumbnail updates the thumbnail for this resource. Reimplement if your thumbnail is something else than the image set with setImage.
generate SVG sample.
Reimplemented from KoResource.
Definition at line 490 of file KoCssStylePreset.cpp.
References KoResource::addMetaData(), generateSampleShape(), generateSVG(), KoShapePainter::paint(), SAMPLE_SVG, KoResource::setImage(), KoShapePainter::setShapes(), and updateAlignSample().
|
private |
Definition at line 108 of file KoCssStylePreset.h.