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++
Handle flags for text decoration and hanging punctuation.
Wolthera van Hövell tot Westerflier5d28e0d83d2c
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cppindex 5e259b21f7..fef646a22f 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp@@ -63,6 +63,62 @@ auto tabSizeProperty = lager::lenses::getset(auto textTransformProperty = lager::lenses::getset([](const QVariant &value) -> KoSvgText::TextTransformInfo {return value.value<KoSvgText::TextTransformInfo>();},[](QVariant value, const KoSvgText::TextTransformInfo &val){value = QVariant::fromValue(val); return value;});+auto textDecorLineProp = [](KoSvgText::TextDecoration flag) {+ return lager::lenses::getset(+ [flag](const QVariant &value) -> bool {+ return value.value<KoSvgText::TextDecorations>().testFlag(flag);+ },+ [flag](QVariant value, const bool &val){+ KoSvgText::TextDecorations decor = value.value<KoSvgText::TextDecorations>();+ decor.setFlag(flag, val);+ value = QVariant::fromValue(decor);+ return value;+ }+ );+};+auto hangPunctuationProp = [](KoSvgText::HangingPunctuation flag) {+ return lager::lenses::getset(+ [flag](const QVariant &value) -> bool {+ return value.value<KoSvgText::HangingPunctuations>().testFlag(flag);+ },+ [flag](QVariant value, const bool &val){+ KoSvgText::HangingPunctuations hang = value.value<KoSvgText::HangingPunctuations>();+ hang.setFlag(flag, val);+ value = QVariant::fromValue(hang);+ return value;+ }+ );+};+auto hangingPunactuationCommaProp = lager::lenses::getset(+ [](const QVariant &value) -> KoSvgTextPropertiesModel::HangComma {+ KoSvgText::HangingPunctuations hang = value.value<KoSvgText::HangingPunctuations>();+ if (hang.testFlag(KoSvgText::HangEnd)) {+ return hang.testFlag(KoSvgText::HangForce)?+ KoSvgTextPropertiesModel::HangComma::ForceHang:+ KoSvgTextPropertiesModel::HangComma::AllowHang;+ }+ return KoSvgTextPropertiesModel::NoHang;+ },+ [](QVariant value, const KoSvgTextPropertiesModel::HangComma &val){+ KoSvgText::HangingPunctuations hang = value.value<KoSvgText::HangingPunctuations>();+ switch (val) {+ case KoSvgTextPropertiesModel::NoHang:+ hang.setFlag(KoSvgText::HangEnd, false);+ hang.setFlag(KoSvgText::HangForce, false);+ break;+ case KoSvgTextPropertiesModel::AllowHang:+ hang.setFlag(KoSvgText::HangEnd, true);+ hang.setFlag(KoSvgText::HangForce, false);+ break;+ case KoSvgTextPropertiesModel::ForceHang:+ hang.setFlag(KoSvgText::HangEnd, true);+ hang.setFlag(KoSvgText::HangForce, true);+ break;+ }+ value = QVariant::fromValue(hang);+ return value;+ }+ );}KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextPropertyData> _textData)@@ -92,6 +148,12 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(fontStyle) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(integerProperty)}, LAGER_QT(fontOpticalSizeLink) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontOpticalSizingId)).zoom(boolProperty)}, LAGER_QT(fontFamilies) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontFamiliesId)).zoom(stringListProperty)}+ , LAGER_QT(textDecorationUnderline){commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationUnderline))}+ , LAGER_QT(textDecorationOverline){commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationOverline))}+ , LAGER_QT(textDecorationLineThrough){commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationLineThrough))}+ , LAGER_QT(hangingPunctuationFirst){commonProperties.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangPunctuationProp(KoSvgText::HangFirst))}+ , LAGER_QT(hangingPunctuationComma){commonProperties.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangingPunactuationCommaProp)}+ , LAGER_QT(hangingPunctuationLast){commonProperties.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangPunctuationProp(KoSvgText::HangLast))}{lager::watch(textData, std::bind(&KoSvgTextPropertiesModel::textPropertyChanged, this));lager::watch(fontSizeData, std::bind(&KoSvgTextPropertiesModel::fontSizeChanged, this));diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.h b/libs/flake/text/lager/KoSvgTextPropertiesModel.hindex c6468ce6fc..38bbc07ec8 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h@@ -80,6 +80,20 @@ public:LAGER_QT_CURSOR(QStringList, fontFamilies);+ LAGER_QT_CURSOR(bool, textDecorationUnderline);+ LAGER_QT_CURSOR(bool, textDecorationOverline);+ LAGER_QT_CURSOR(bool, textDecorationLineThrough);++ enum HangComma {+ NoHang,+ AllowHang,+ ForceHang+ };+ Q_ENUM(HangComma)+ LAGER_QT_CURSOR(bool, hangingPunctuationFirst);+ LAGER_QT_CURSOR(HangComma, hangingPunctuationComma);+ LAGER_QT_CURSOR(bool, hangingPunctuationLast);+Q_SIGNALS:void textPropertyChanged();diff --git a/plugins/dockers/textproperties/qml/HangingPunctuation.qml b/plugins/dockers/textproperties/qml/HangingPunctuation.qmlindex 3b5a85e1f2..a827b3bc5c 100644--- a/plugins/dockers/textproperties/qml/HangingPunctuation.qml+++ b/plugins/dockers/textproperties/qml/HangingPunctuation.qml@@ -6,8 +6,13 @@import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12+import org.krita.flake.text 1.0TextPropertyBase {+ property alias hangStart: paragraphStartCbx.checked;+ property alias hangEnd: paragraphEndCbx.checked;+ property var hangComma;+ onHangCommaChanged: lineEndCmb.currentIndex = lineEndCmb.indexOfValue(hangComma)GridLayout {columns: 2;columnSpacing: columnSpacing;@@ -51,11 +56,15 @@ TextPropertyBase {}ComboBox {model: [- i18nc("@label:inlistbox", "No Hanging"),- i18nc("@label:inlistbox", "Allow hanging commas"),- i18nc("@label:inlistbox", "Force hanging commas")]+ {text: i18nc("@label:inlistbox", "No Hanging"), value: KoSvgTextPropertiesModel.NoHang},+ {text: i18nc("@label:inlistbox", "Allow hanging commas"), value: KoSvgTextPropertiesModel.AllowHang},+ {text: i18nc("@label:inlistbox", "Force hanging commas"), value: KoSvgTextPropertiesModel.ForceHang}+ ]Layout.fillWidth: true;id: lineEndCmb;+ textRole: "text";+ valueRole: "value";+ onActivated: hangComma = currentValue;}Item {diff --git a/plugins/dockers/textproperties/qml/TextDecoration.qml b/plugins/dockers/textproperties/qml/TextDecoration.qmlindex 05f3524eb9..891b5ac3fe 100644--- a/plugins/dockers/textproperties/qml/TextDecoration.qml+++ b/plugins/dockers/textproperties/qml/TextDecoration.qml@@ -8,6 +8,10 @@ import QtQuick.Controls 2.0import QtQuick.Layouts 1.12TextPropertyBase {++ property alias underline: underlineCbx.checked;+ property alias overline: overlineCbx.checked;+ property alias linethrough: linethroughCbx.checked;GridLayout {columns: 3;columnSpacing: columnSpacing;@@ -65,7 +69,7 @@ TextPropertyBase {CheckBox {Layout.columnSpan: 2;text: i18nc("@option:check", "Line-through")- id: linethoughCbx;+ id: linethroughCbx;}diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qmlindex 8e574c5104..eec9213fed 100644--- a/plugins/dockers/textproperties/qml/TextProperties.qml+++ b/plugins/dockers/textproperties/qml/TextProperties.qml@@ -110,6 +110,12 @@ Rectangle {}TextDecoration {width: characterProperties.width;+ underline: textPropertiesModel.textDecorationUnderline;+ onUnderlineChanged: textPropertiesModel.textDecorationUnderline = underline;+ overline: textPropertiesModel.textDecorationOverline;+ onOverlineChanged: textPropertiesModel.textDecorationOverline = overline;+ linethrough: textPropertiesModel.textDecorationLineThrough;+ onLinethroughChanged: textPropertiesModel.textDecorationLineThrough = linethrough;}OTLigatures {width: characterProperties.width;@@ -180,6 +186,12 @@ Rectangle {}HangingPunctuation {width: parent.width;+ hangStart: textPropertiesModel.hangingPunctuationFirst;+ onHangStartChanged: textPropertiesModel.hangingPunctuationFirst = hangStart;+ hangEnd: textPropertiesModel.hangingPunctuationLast;+ onHangEndChanged: textPropertiesModel.hangingPunctuationLast = hangEnd;+ hangComma: textPropertiesModel.hangingPunctuationComma;+ onHangCommaChanged: textPropertiesModel.hangingPunctuationComma = hangComma;}TabSize {width: parent.width;