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++
Add some of the enumValues as integers for now, hide/disable options to tackle later.
Wolthera van Hövell tot Westerflierd7ad511ba077
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cppindex fef646a22f..8987f081fa 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp@@ -119,6 +119,12 @@ auto hangingPunactuationCommaProp = lager::lenses::getset(return value;});+auto fontStyleProperty = lager::lenses::getset(+ [](const QVariant &value) -> KoSvgTextPropertiesModel::FontStyle {return KoSvgTextPropertiesModel::FontStyle(value.toInt());},+ [](QVariant value, const KoSvgTextPropertiesModel::FontStyle &val){value = QVariant::fromValue(val); return value;});+auto qColorProperty = lager::lenses::getset(+ [](const QVariant &value) -> QColor {return value.value<QColor>();},+ [](QVariant value, const QColor &val){value = QVariant::fromValue(val); return value;});}KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextPropertyData> _textData)@@ -143,17 +149,26 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper, LAGER_QT(writingMode) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::WritingModeId)).zoom(integerProperty)}, LAGER_QT(direction) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::DirectionId)).zoom(integerProperty)}, LAGER_QT(textAlignAll) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextAlignAllId)).zoom(integerProperty)}+ , LAGER_QT(textAlignLast) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextAlignLastId)).zoom(integerProperty)}+ , LAGER_QT(textAnchor) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextAnchorId)).zoom(integerProperty)}, LAGER_QT(fontWeight) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontWeightId)).zoom(integerProperty)}, LAGER_QT(fontWidth) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontStretchId)).zoom(integerProperty)}- , LAGER_QT(fontStyle) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(integerProperty)}+ , LAGER_QT(fontStyle) {commonProperties.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(fontStyleProperty)}, 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(textDecorationStyle){commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextDecorationStyleId)).zoom(integerProperty)}+ , LAGER_QT(textDecorationColor){commonProperties.zoom(createTextProperty(KoSvgTextProperties::TextDecorationColorId)).zoom(qColorProperty)}, 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_QT(alignmentBaseline){commonProperties.zoom(createTextProperty(KoSvgTextProperties::AlignmentBaselineId)).zoom(integerProperty)}+ , LAGER_QT(dominantBaseline){commonProperties.zoom(createTextProperty(KoSvgTextProperties::DominantBaselineId)).zoom(integerProperty)}+ , LAGER_QT(baselineShiftMode){commonProperties.zoom(createTextProperty(KoSvgTextProperties::BaselineShiftModeId)).zoom(integerProperty)}+ , LAGER_QT(wordBreak){commonProperties.zoom(createTextProperty(KoSvgTextProperties::WordBreakId)).zoom(integerProperty)}+ , LAGER_QT(lineBreak){commonProperties.zoom(createTextProperty(KoSvgTextProperties::LineBreakId)).zoom(integerProperty)}{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 38bbc07ec8..11c03d6a3c 100644--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h@@ -72,10 +72,21 @@ public:LAGER_QT_CURSOR(int, writingMode);LAGER_QT_CURSOR(int, direction);LAGER_QT_CURSOR(int, textAlignAll);+ LAGER_QT_CURSOR(int, textAlignLast);+ LAGER_QT_CURSOR(int, textAnchor);LAGER_QT_CURSOR(int, fontWeight);LAGER_QT_CURSOR(int, fontWidth);- LAGER_QT_CURSOR(int, fontStyle);++ // QFont::Style isn't exposed to qml.+ enum FontStyle {+ StyleNormal = QFont::StyleNormal,+ StyleItalic = QFont::StyleItalic,+ StyleOblique = QFont::StyleOblique+ };+ Q_ENUM(FontStyle);++ LAGER_QT_CURSOR(FontStyle, fontStyle);LAGER_QT_CURSOR(bool, fontOpticalSizeLink);LAGER_QT_CURSOR(QStringList, fontFamilies);@@ -84,6 +95,10 @@ public:LAGER_QT_CURSOR(bool, textDecorationOverline);LAGER_QT_CURSOR(bool, textDecorationLineThrough);+ LAGER_QT_CURSOR(int, textDecorationStyle);++ LAGER_QT_CURSOR(QColor, textDecorationColor);+enum HangComma {NoHang,AllowHang,@@ -94,6 +109,13 @@ public:LAGER_QT_CURSOR(HangComma, hangingPunctuationComma);LAGER_QT_CURSOR(bool, hangingPunctuationLast);+ LAGER_QT_CURSOR(int, alignmentBaseline);+ LAGER_QT_CURSOR(int, dominantBaseline);+ LAGER_QT_CURSOR(int, baselineShiftMode);++ LAGER_QT_CURSOR(int, wordBreak);+ LAGER_QT_CURSOR(int, lineBreak);+Q_SIGNALS:void textPropertyChanged();diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qmlindex 86b8bea1eb..67a03a1306 100644--- a/plugins/dockers/textproperties/qml/BaselineShift.qml+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml@@ -8,7 +8,13 @@ import QtQuick.Controls 2.0import QtQuick.Layouts 1.12TextPropertyBase {- property alias baselineShiftValue: baselineShiftSpn.value+ property alias baselineShiftValue: baselineShiftSpn.value;+ property int baselineShiftMode;+ onBaselineShiftModeChanged: {+ baselineShiftCmb.currentIndex = baselineShiftCmb.indexOfValue(baselineShiftMode);+ baselineShiftSpn.enabled = baselineShiftMode == 3;+ }+GridLayout {columns: 3;columnSpacing: columnSpacing;@@ -39,10 +45,16 @@ TextPropertyBase {ComboBox {Layout.columnSpan: 2;- model: [i18nc("@label:inlistbox", "Number"),- i18nc("@label:inlistbox", "Super"),- i18nc("@label:inlistbox", "Sub")]+ model: [+ { text: i18nc("@label:inlistbox", "None"), value: 0},+ { text: i18nc("@label:inlistbox", "Length"), value: 3},+ { text: i18nc("@label:inlistbox", "Super"), value: 2},+ { text: i18nc("@label:inlistbox", "Sub"), value: 1}+ ]id: baselineShiftCmb;+ textRole: "text";+ valueRole: "value";+ onActivated: baselineShiftMode = currentValue;}Item {diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex fb9816a060..8a0b1d00cd 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -6,13 +6,14 @@import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12+import org.krita.flake.text 1.0CollapsibleGroupProperty {propertyName: i18nc("@label", "Font Style");property alias fontWeight: fontWeightSpn.value;property alias fontWidth: fontStretchSpn.value;- property int fontSlant;+ property int fontSlant: KoSvgTextPropertiesModel.StyleNormal;onFontSlantChanged: fontSlantCmb.currentIndex = fontSlantCmb.indexOfValue(fontSlant)property alias fontOptical: opticalSizeCbx.checked;@@ -81,9 +82,9 @@ CollapsibleGroupProperty {ComboBox {id: fontSlantCmbmodel: [- {text: i18nc("@label:inlistbox", "Normal"), value: 0},- {text: i18nc("@label:inlistbox", "Italic"), value: 1},- {text: i18nc("@label:inlistbox", "Oblique"), value: 2}+ {text: i18nc("@label:inlistbox", "Normal"), value: KoSvgTextPropertiesModel.StyleNormal},+ {text: i18nc("@label:inlistbox", "Italic"), value: KoSvgTextPropertiesModel.StyleItalic},+ {text: i18nc("@label:inlistbox", "Oblique"), value: KoSvgTextPropertiesModel.StyleOblique}]Layout.fillWidth: truetextRole: "text";diff --git a/plugins/dockers/textproperties/qml/LineBreak.qml b/plugins/dockers/textproperties/qml/LineBreak.qmlindex a75cc14b45..c135fd020e 100644--- a/plugins/dockers/textproperties/qml/LineBreak.qml+++ b/plugins/dockers/textproperties/qml/LineBreak.qml@@ -8,6 +8,8 @@ import QtQuick.Controls 2.0import QtQuick.Layouts 1.12TextPropertyBase {+ property int breakType;+ onBreakTypeChanged: lineBreakCmb.currentIndex = lineBreakCmb.indexOfValue(breakType);RowLayout {spacing: columnSpacing;width: parent.width;@@ -31,13 +33,16 @@ TextPropertyBase {ComboBox {id: lineBreakCmbmodel: [- i18nc("@label:inlistbox", "Auto"),- i18nc("@label:inlistbox", "Loose"),- i18nc("@label:inlistbox", "Normal"),- i18nc("@label:inlistbox", "Strict"),- i18nc("@label:inlistbox", "Anywhere")+ { text: i18nc("@label:inlistbox", "Auto"), value: 0},+ { text: i18nc("@label:inlistbox", "Loose"), value: 1},+ { text: i18nc("@label:inlistbox", "Normal"), value: 2},+ { text: i18nc("@label:inlistbox", "Strict"), value: 3},+ { text: i18nc("@label:inlistbox", "Anywhere"), value: 4}]Layout.fillWidth: true;+ textRole: "text";+ valueRole: "value";+ onActivated: breakType = currentValue;}}}diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qmlindex 5e210a6777..cd357f7d80 100644--- a/plugins/dockers/textproperties/qml/LineHeight.qml+++ b/plugins/dockers/textproperties/qml/LineHeight.qml@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0TextPropertyBase {property alias isNormal: lineHeightNormalCbx.checked;property alias lineHeight: lineHeightSpn.value;- property var lineHeightUnit;+ property int lineHeightUnit: LineHeightModel.Lines;onLineHeightUnitChanged: lineHeightUnitCmb.currentIndex = lineHeightUnitCmb.indexOfValue(lineHeightUnit);GridLayout {diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qmlindex 6611bfbfe1..4f02ec498e 100644--- a/plugins/dockers/textproperties/qml/TabSize.qml+++ b/plugins/dockers/textproperties/qml/TabSize.qml@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0TextPropertyBase {property alias tabSize: tabSizeSpn.value;- property var tabSizeUnit;+ property int tabSizeUnit: TabSizeModel.Spaces;onTabSizeUnitChanged: tabSizeUnitCmb.currentIndex = tabSizeUnitCmb.indexOfValue(tabSizeUnit);GridLayout {diff --git a/plugins/dockers/textproperties/qml/TextAlign.qml b/plugins/dockers/textproperties/qml/TextAlign.qmlindex 52a95f2bec..18ba0bfa91 100644--- a/plugins/dockers/textproperties/qml/TextAlign.qml+++ b/plugins/dockers/textproperties/qml/TextAlign.qml@@ -10,6 +10,13 @@ import QtQuick.Layouts 1.12CollapsibleGroupProperty {propertyName: "Text Align";+ property int textAlignAll;+ onTextAlignAllChanged: textAlignAllCmb.currentIndex = textAlignAllCmb.indexOfValue(textAlignAll);+ property int textAlignLast;+ onTextAlignLastChanged: textAlignLastCmb.currentIndex = textAlignLastCmb.indexOfValue(textAlignLast);+ property int textAnchor;+ onTextAnchorChanged: textAnchorCmb.currentIndex = textAnchorCmb.indexOfValue(textAnchor);+contentItem: GridLayout {columns: 3anchors.left: parent.left@@ -30,14 +37,44 @@ CollapsibleGroupProperty {ComboBox {id: textAlignAllCmb;model: [- {text: i18nc("@label:inlistbox", "Left")},- {text: i18nc("@label:inlistbox", "Start")},- {text: i18nc("@label:inlistbox", "Center")},- {text: i18nc("@label:inlistbox", "End")},- {text: i18nc("@label:inlistbox", "Right")},- {text: i18nc("@label:inlistbox", "Justified")}+ {text: i18nc("@label:inlistbox", "Left"), value: 3},+ {text: i18nc("@label:inlistbox", "Start"), value: 1},+ {text: i18nc("@label:inlistbox", "Center"), value: 5},+ {text: i18nc("@label:inlistbox", "End"), value: 2},+ {text: i18nc("@label:inlistbox", "Right"), value: 4},+ {text: i18nc("@label:inlistbox", "Justified"), value: 6}+ ]+ Layout.fillWidth: true+ textRole: "text";+ valueRole: "value";+ onActivated: textAlignAll = currentValue;+ }++ ToolButton {+ width: firstColumnWidth;+ height: firstColumnWidth;+ display: AbstractButton.IconOnly+ icon.source: "qrc:///light_view-refresh.svg"+ }+ Label {+ text: i18nc("@label:listbox", "Align Last:")+ Layout.alignment: Qt.AlignRight | Qt.AlignVCenter+ }++ ComboBox {+ id: textAlignLastCmb;+ model: [+ {text: i18nc("@label:inlistbox", "Auto"), value: 0},+ {text: i18nc("@label:inlistbox", "Left"), value: 3},+ {text: i18nc("@label:inlistbox", "Start"), value: 1},+ {text: i18nc("@label:inlistbox", "Center"), value: 5},+ {text: i18nc("@label:inlistbox", "End"), value: 2},+ {text: i18nc("@label:inlistbox", "Right"), value: 4}]Layout.fillWidth: true+ textRole: "text";+ valueRole: "value";+ onActivated: textAlignLast = currentValue;}@@ -55,10 +92,13 @@ CollapsibleGroupProperty {ComboBox {id: textAnchorCmb;model: [- {text: i18nc("@label:inlistbox", "Start")},- {text: i18nc("@label:inlistbox", "Middle")},- {text: i18nc("@label:inlistbox", "End")}]+ {text: i18nc("@label:inlistbox", "Start"), value: 0},+ {text: i18nc("@label:inlistbox", "Middle"), value: 1},+ {text: i18nc("@label:inlistbox", "End"), value: 2}]Layout.fillWidth: true+ textRole: "text";+ valueRole: "value";+ onActivated: textAnchor = currentValue;}}diff --git a/plugins/dockers/textproperties/qml/TextDecoration.qml b/plugins/dockers/textproperties/qml/TextDecoration.qmlindex 891b5ac3fe..9919dc1337 100644--- a/plugins/dockers/textproperties/qml/TextDecoration.qml+++ b/plugins/dockers/textproperties/qml/TextDecoration.qml@@ -12,6 +12,9 @@ TextPropertyBase {property alias underline: underlineCbx.checked;property alias overline: overlineCbx.checked;property alias linethrough: linethroughCbx.checked;+ property int lineStyle;+ property color lineColor;+ onLineStyleChanged: lineStyleCmb.currentIndex = lineStyleCmb.indexOfValue(lineStyle)GridLayout {columns: 3;columnSpacing: columnSpacing;@@ -81,9 +84,11 @@ TextPropertyBase {CheckBox {text: i18nc("@label:chooser", "Color")id: colorCbx;+ enabled: false;}Rectangle {// replace with color picker?+ color: lineColor;Layout.fillWidth: true;Layout.fillHeight: true;}@@ -97,14 +102,18 @@ TextPropertyBase {}ComboBox {+ id: lineStyleCmb;model: [- i18nc("@label:inlistbox", "Solid"),- i18nc("@label:inlistbox", "Dotted"),- i18nc("@label:inlistbox", "Dashed"),- i18nc("@label:inlistbox", "Double"),- i18nc("@label:inlistbox", "Wavy")+ { text: i18nc("@label:inlistbox", "Solid"), value: 0},+ { text: i18nc("@label:inlistbox", "Dotted"), value: 2},+ { text: i18nc("@label:inlistbox", "Dashed"), value: 3},+ { text: i18nc("@label:inlistbox", "Double"), value: 1},+ { text: i18nc("@label:inlistbox", "Wavy"), value: 4},]Layout.fillWidth: true;+ textRole: "text";+ valueRole: "value";+ onActivated: lineStyle = currentValue;}}}diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qmlindex eec9213fed..7d92352130 100644--- a/plugins/dockers/textproperties/qml/TextProperties.qml+++ b/plugins/dockers/textproperties/qml/TextProperties.qml@@ -54,7 +54,7 @@ Rectangle {width: characterProperties.width;fontSize: textPropertiesModel.fontSize.value;- onFontSizeChanged: {textPropertiesModel.fontSize.value = fontSize; console.log(textPropertiesModel.fontSize.value);}+ onFontSizeChanged: {textPropertiesModel.fontSize.value = fontSize;}}FontFamily {@@ -95,9 +95,13 @@ Rectangle {}LineBreak {width: characterProperties.width;+ breakType: textPropertiesModel.lineBreak;+ onBreakTypeChanged: textPropertiesModel.lineBreak = breakType;}WordBreak {width: characterProperties.width;+ breakType: textPropertiesModel.wordBreak;+ onBreakTypeChanged: textPropertiesModel.wordBreak = breakType;}TextTransform {width: characterProperties.width;@@ -116,7 +120,11 @@ Rectangle {onOverlineChanged: textPropertiesModel.textDecorationOverline = overline;linethrough: textPropertiesModel.textDecorationLineThrough;onLinethroughChanged: textPropertiesModel.textDecorationLineThrough = linethrough;+ lineStyle: textPropertiesModel.textDecorationStyle;+ onLineStyleChanged: textPropertiesModel.textDecorationStyle = lineStyle;+ lineColor: textPropertiesModel.textDecorationColor;}+ /*OTLigatures {width: characterProperties.width;}@@ -131,14 +139,18 @@ Rectangle {}OTEastAsian {width: characterProperties.width;- }+ }*/BaselineShift {width: characterProperties.width;baselineShiftValue: textPropertiesModel.baselineShiftValue.value;onBaselineShiftValueChanged: textPropertiesModel.baselineShiftValue.value = baselineShiftValue;+ baselineShiftMode: textPropertiesModel.baselineShiftMode;+ onBaselineShiftModeChanged: textPropertiesModel.baselineShiftMode = baselineShiftMode;}AlignmentBaseline {width: characterProperties.width;+ baselineSelection: textPropertiesModel.alignmentBaseline;+ onBaselineSelectionChanged: textPropertiesModel.alignmentBaseline = baselineSelection;}}}@@ -174,16 +186,25 @@ Rectangle {}TextAlign{width: parent.width;+ textAlignAll: textPropertiesModel.textAlignAll;+ onTextAlignAllChanged: textPropertiesModel.textAlignAll = textAlignAll;+ textAlignLast: textPropertiesModel.textAlignLast;+ onTextAlignLastChanged: textPropertiesModel.textAlignLast = textAlignLast;+ textAnchor: textPropertiesModel.textAnchor;+ onTextAnchorChanged: textPropertiesModel.textAnchor = textAnchor;}DominantBaseline {width: parent.width;+ baselineSelection: textPropertiesModel.dominantBaseline;+ onBaselineSelectionChanged: textPropertiesModel.dominantBaseline = baselineSelection;}+ /*WhiteSpace {width: parent.width;}UnderlinePosition {width: parent.width;- }+ }*/HangingPunctuation {width: parent.width;hangStart: textPropertiesModel.hangingPunctuationFirst;diff --git a/plugins/dockers/textproperties/qml/WordBreak.qml b/plugins/dockers/textproperties/qml/WordBreak.qmlindex f3847e7346..0d3b4f5306 100644--- a/plugins/dockers/textproperties/qml/WordBreak.qml+++ b/plugins/dockers/textproperties/qml/WordBreak.qml@@ -8,6 +8,8 @@ import QtQuick.Controls 2.0import QtQuick.Layouts 1.12TextPropertyBase {+ property int breakType;+ onBreakTypeChanged: wordBreakCmb.currentIndex = wordBreakCmb.indexOfValue(breakType);RowLayout {spacing: columnSpacing;width: parent.width;@@ -32,11 +34,14 @@ TextPropertyBase {ComboBox {id: wordBreakCmbmodel: [- i18nc("@label:inlistbox", "Normal"),- i18nc("@label:inlistbox", "Keep-all"),- i18nc("@label:inlistbox", "Break-all")+ { text: i18nc("@label:inlistbox", "Normal"), value: 0},+ { text: i18nc("@label:inlistbox", "Keep-all"), value: 1},+ { text: i18nc("@label:inlistbox", "Break-all"), value: 2}]Layout.fillWidth: true;+ textRole: "text";+ valueRole: "value";+ onActivated: breakType = currentValue;}}}