|
Krita Source Code Documentation
|
The CssQmlUnitConverter class. More...
#include <CssQmlUnitConverter.h>
Inheritance diagram for CssQmlUnitConverter:Classes | |
| struct | Private |
Public Types | |
| enum | UserUnits { Px , Pt , Mm , Cm , Inch , Percentage , Em , Ex , Cap , Ch , Ic , Lh , Lines , Spaces } |
Signals | |
| void | dataMultiplierChanged () |
| void | dataUnitChanged () |
| void | dataValueChanged () |
| void | dpiChanged () |
| void | percentageReferenceChanged () |
| void | userUnitChanged () |
| void | userUnitModelChanged () |
| void | userValueChanged () |
Public Member Functions | |
| CssQmlUnitConverter (QObject *parent=nullptr) | |
| qreal | dataMultiplier () const |
| int | dataUnit () const |
| qreal | dataValue () const |
| qreal | dpi () const |
| qreal | percentageReference () const |
| void | setDataMultiplier (qreal newDataMultiplier) |
| void | setDataUnit (int newDataUnit) |
| Q_INVOKABLE void | setDataUnitMap (const QVariantList &unitMap) |
| setDataUnitMap | |
| void | setDataValue (qreal newDataValue) |
| Q_INVOKABLE void | setDataValueAndUnit (const qreal value, const int unit) |
| setDataValueAndUnit set data unit and value in one go. | |
| void | setDpi (qreal newDpi) |
| Q_INVOKABLE void | setFontMetricsFromTextPropertiesModel (KoSvgTextPropertiesModel *textPropertiesModel, bool isFontSize=false, bool isLineHeight=false) |
| setFontMetricsFromTextPropertiesModel Set the current font metrics from the text properties model. | |
| Q_INVOKABLE void | setFromNormalLineHeight () |
| setFromNormalLineHeight set the current value from line-height:normal metrics. | |
| void | setPercentageReference (qreal newPercentageReference) |
| void | setUserUnit (int newUserUnit) |
| void | setUserValue (qreal newUserValue) |
| QString | symbol () const |
| int | userUnit () const |
| QVariantList | userUnitModel () const |
| qreal | userValue () const |
| ~CssQmlUnitConverter () | |
Properties | |
| qreal | dataMultiplier |
| Data multiplier is used if for some reason the user-value needs to be multiplied by a certain factor. | |
| int | dataUnit |
| qreal | dataValue |
| dataValue and dataUnit represent the data as used by the text properties. | |
| qreal | dpi |
| The DPI used to calculate pixel to physical properties. | |
| qreal | percentageReference |
| value to represent 100% | |
| QString | symbol |
| The symbol. | |
| int | userUnit |
| QVariantList | userUnitModel |
| A model for the available user units. | |
| qreal | userValue |
| userValue and userUnit represent the user-visible data. This can include synthetic units like px and mm from pt. | |
Private Member Functions | |
| qreal | convertFromRelativeValue (const qreal value, const UserUnits type) const |
| qreal | convertToRelativeValue (const qreal value, const UserUnits type) const |
Private Attributes | |
| const QScopedPointer< Private > | d |
The CssQmlUnitConverter class.
This handles converter to and from various units. For the absolute units, KoUnit is used internally. For the font-relative units, it will use the fontMetrics;
Definition at line 19 of file CssQmlUnitConverter.h.
Definition at line 51 of file CssQmlUnitConverter.h.
| CssQmlUnitConverter::CssQmlUnitConverter | ( | QObject * | parent = nullptr | ) |
Definition at line 44 of file CssQmlUnitConverter.cpp.
References KoSvgTextProperties::cssFontInfo(), d, KoSvgTextProperties::defaultProperties(), KoSvgTextProperties::metrics(), and KoUnit::Point.
| CssQmlUnitConverter::~CssQmlUnitConverter | ( | ) |
Definition at line 53 of file CssQmlUnitConverter.cpp.
|
private |
Definition at line 365 of file CssQmlUnitConverter.cpp.
References d, metricsMultiplier(), and value().
|
private |
Definition at line 360 of file CssQmlUnitConverter.cpp.
References d, metricsMultiplier(), and value().
| qreal CssQmlUnitConverter::dataMultiplier | ( | ) | const |
Definition at line 155 of file CssQmlUnitConverter.cpp.
References d.
|
signal |
| int CssQmlUnitConverter::dataUnit | ( | ) | const |
Definition at line 182 of file CssQmlUnitConverter.cpp.
References d.
|
signal |
| qreal CssQmlUnitConverter::dataValue | ( | ) | const |
Definition at line 168 of file CssQmlUnitConverter.cpp.
References d.
|
signal |
| qreal CssQmlUnitConverter::dpi | ( | ) | const |
|
signal |
| qreal CssQmlUnitConverter::percentageReference | ( | ) | const |
Definition at line 323 of file CssQmlUnitConverter.cpp.
References d.
|
signal |
| void CssQmlUnitConverter::setDataMultiplier | ( | qreal | newDataMultiplier | ) |
Definition at line 160 of file CssQmlUnitConverter.cpp.
References d, dataMultiplierChanged(), and qFuzzyCompare().
| void CssQmlUnitConverter::setDataUnit | ( | int | newDataUnit | ) |
Definition at line 187 of file CssQmlUnitConverter.cpp.
References d, and setUserUnit().
| void CssQmlUnitConverter::setDataUnitMap | ( | const QVariantList & | unitMap | ) |
setDataUnitMap
| map | – variant list of VariantMaps, where "data" is an int representing a dataUnit, and "user" is an int representing a value in the UserUnits enum. |
Definition at line 57 of file CssQmlUnitConverter.cpp.
References d, and userUnitModelChanged().
| void CssQmlUnitConverter::setDataValue | ( | qreal | newDataValue | ) |
Definition at line 173 of file CssQmlUnitConverter.cpp.
References d, dataValueChanged(), qFuzzyCompare(), and userValueChanged().
| void CssQmlUnitConverter::setDataValueAndUnit | ( | const qreal | value, |
| const int | unit ) |
setDataValueAndUnit set data unit and value in one go.
Definition at line 119 of file CssQmlUnitConverter.cpp.
References d, dataUnitChanged(), dataValueChanged(), koUnitFactor, koUnitMap, Pt, qFuzzyCompare(), userUnitChanged(), userValueChanged(), and value().
| void CssQmlUnitConverter::setDpi | ( | qreal | newDpi | ) |
Definition at line 145 of file CssQmlUnitConverter.cpp.
References d, dpiChanged(), koUnitFactor, qFuzzyCompare(), and userValueChanged().
| void CssQmlUnitConverter::setFontMetricsFromTextPropertiesModel | ( | KoSvgTextPropertiesModel * | textPropertiesModel, |
| bool | isFontSize = false, | ||
| bool | isLineHeight = false ) |
setFontMetricsFromTextPropertiesModel Set the current font metrics from the text properties model.
| textPropertiesModel |
Definition at line 78 of file CssQmlUnitConverter.cpp.
References KoSvgText::FontMetrics::ascender, KoSvgTextPropertyData::commonProperties, d, KoSvgTextProperties::defaultProperties(), KoSvgText::FontMetrics::descender, KoSvgTextPropertyData::inheritedProperties, KoSvgTextProperties::inheritFrom(), KoSvgText::FontMetrics::lineGap, main(), KoCSSFontInfo::size, and KoSvgTextPropertiesModel::textData.
| void CssQmlUnitConverter::setFromNormalLineHeight | ( | ) |
setFromNormalLineHeight set the current value from line-height:normal metrics.
Definition at line 112 of file CssQmlUnitConverter.cpp.
References convertToRelativeValue(), d, setDataValue(), and KoCSSFontInfo::size.
| void CssQmlUnitConverter::setPercentageReference | ( | qreal | newPercentageReference | ) |
Definition at line 328 of file CssQmlUnitConverter.cpp.
References d, percentageReferenceChanged(), and qFuzzyCompare().
| void CssQmlUnitConverter::setUserUnit | ( | int | newUserUnit | ) |
Definition at line 217 of file CssQmlUnitConverter.cpp.
References convertFromRelativeValue(), convertToRelativeValue(), d, dataUnitChanged(), koUnitFactor, koUnitMap, Pt, setDataValue(), userUnitChanged(), and userValueChanged().
| void CssQmlUnitConverter::setUserValue | ( | qreal | newUserValue | ) |
Definition at line 202 of file CssQmlUnitConverter.cpp.
References d, dataValueChanged(), koUnitMap, qFuzzyCompare(), userValue, and userValueChanged().
| QString CssQmlUnitConverter::symbol | ( | ) | const |
Definition at line 294 of file CssQmlUnitConverter.cpp.
References Cap, Ch, d, Em, Ex, Ic, koUnitMap, Lh, Lines, Percentage, and Spaces.
| int CssQmlUnitConverter::userUnit | ( | ) | const |
Definition at line 212 of file CssQmlUnitConverter.cpp.
References d.
|
signal |
| QVariantList CssQmlUnitConverter::userUnitModel | ( | ) | const |
Definition at line 249 of file CssQmlUnitConverter.cpp.
References Cap, Ch, d, Em, Ex, Ic, koUnitMap, Lh, Lines, Percentage, Pt, Spaces, KoUnit::unitDescription(), and userUnitModel.
|
signal |
| qreal CssQmlUnitConverter::userValue | ( | ) | const |
Definition at line 196 of file CssQmlUnitConverter.cpp.
|
signal |
|
private |
Definition at line 148 of file CssQmlUnitConverter.h.
|
readwrite |
Data multiplier is used if for some reason the user-value needs to be multiplied by a certain factor.
Definition at line 27 of file CssQmlUnitConverter.h.
|
readwrite |
Definition at line 31 of file CssQmlUnitConverter.h.
|
readwrite |
dataValue and dataUnit represent the data as used by the text properties.
Definition at line 30 of file CssQmlUnitConverter.h.
|
readwrite |
The DPI used to calculate pixel to physical properties.
Definition at line 24 of file CssQmlUnitConverter.h.
|
readwrite |
value to represent 100%
Definition at line 44 of file CssQmlUnitConverter.h.
|
read |
The symbol.
Definition at line 41 of file CssQmlUnitConverter.h.
|
readwrite |
Definition at line 35 of file CssQmlUnitConverter.h.
|
read |
A model for the available user units.
Definition at line 38 of file CssQmlUnitConverter.h.
|
readwrite |
userValue and userUnit represent the user-visible data. This can include synthetic units like px and mm from pt.
Definition at line 34 of file CssQmlUnitConverter.h.