Skip to content

armgit / krita

Public Imported from GitHub
0

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++

Make text properties show or hide depending on an extra visibility state.

Wolthera van Hövell tot Westerflier11c5c8bff453
diff --git a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
index c84da37ca5..bfd6c23098 100644
--- a/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
+++ b/plugins/dockers/textproperties/TextPropertyConfigModel.cpp
@@ -28,7 +28,7 @@ const QMap<TextPropertyConfigModel::VisibilityState, QString> visibilityConfigNa
struct TextPropertyConfigModel::Private {
QStringList propertyNames;
QMap<QString, TextPropertyConfigModel::TextPropertyData> propertyData;
- TextPropertyConfigModel::VisibilityState defaultVisibilityState;
+ TextPropertyConfigModel::VisibilityState defaultVisibilityState: TextPropertyConfigModel::WhenRelevant;
};
TextPropertyConfigModel::TextPropertyConfigModel(QObject *parent)
@@ -73,9 +73,7 @@ QVariant TextPropertyConfigModel::data(const QModelIndex &index, int role) const
} else if (role == Qt::ToolTipRole) {
return data.toolTip;
} else if (role == Visibility) {
- return data.visibilityState != FollowDefault?
- int(data.visibilityState):
- d->defaultVisibilityState != FollowDefault? int(d->defaultVisibilityState): int(WhenRelevant);
+ return int(data.visibilityState);
} else if (role == Collapsed) {
return data.collapsed;
} else if (role == SearchTerms) {
diff --git a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
index 2e5aebbee0..8e4f9da231 100644
--- a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
+++ b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:listbox", "Alignment Baseline");
propertyName: "alignment-baseline";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Alignment Baseline allows controling how this range of text is aligned to the parent text.");
searchTerms: i18nc("comma separated search terms for the alignment-baseline property, matching is case-insensitive",
@@ -21,7 +21,8 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
baselineSelection = properties.alignmentBaseline;
- visible = properties.alignmentBaselineState !== KoSvgTextPropertiesModel.PropertyUnset
+ propertyState = [properties.alignmentBaselineState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qml
index be4740948e..ae15096084 100644
--- a/plugins/dockers/textproperties/qml/BaselineShift.qml
+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Baseline-Shift");
propertyName: "baseline-shift";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Baseline shift allows moving the text away from the baseline, either by predefined super and subscript values, or by a fixed amount.");
searchTerms: i18nc("comma separated search terms for the baseline-shift property, matching is case-insensitive",
@@ -28,7 +28,8 @@ TextPropertyBase {
baselineShiftUnitCmb.dpi = canvasDPI;
baselineShiftUnitCmb.setTextProperties(properties);
baselineShiftUnitCmb.setDataValueAndUnit(properties.baselineShiftValue.value, properties.baselineShiftValue.unitType)
- visible = properties.baselineShiftState !== KoSvgTextPropertiesModel.PropertyUnset
+ propertyState = [properties.baselineShiftState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
index 2cfbdc22a8..50e29fd1f1 100644
--- a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
+++ b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
@@ -45,13 +45,16 @@ TextPropertyBase {
Item {
id: titleItemContainer;
Layout.fillWidth: true;
- height: childrenRect.height;
+ implicitHeight: childrenRect.height;
+ height: implicitHeight;
}
}
Item {
id: contentItemContainer;
width: parent.width;
- height: visible? childrenRect.height: 0;
+ implicitHeight: childrenRect.height;
+ height: visible? implicitHeight: 0;
+ visible: false;
}
}
diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qml
index 07fc30ab4d..b778c1a71e 100644
--- a/plugins/dockers/textproperties/qml/Direction.qml
+++ b/plugins/dockers/textproperties/qml/Direction.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:listbox", "Direction");
propertyName: "direction";
- propertyType: TextPropertyBase.Mixed;
+ propertyType: TextPropertyConfigModel.Mixed;
toolTip: i18nc("@info:tooltip",
"Direction sets whether the text is left-to-right or right-to-left.");
searchTerms: i18nc("comma separated search terms for the direction property, matching is case-insensitive",
@@ -20,13 +20,15 @@ TextPropertyBase {
property int direction;
property int unicodeBidi;
+
+
onPropertiesUpdated: {
blockSignals = true;
direction = properties.direction;
unicodeBidi = properties.unicodeBidi;
- var set = properties.directionState !== KoSvgTextPropertiesModel.PropertyUnset;
enabled = parentPropertyType === TextPropertyBase.Paragraph? !properties.spanSelection: properties.spanSelection;
- visible = set;
+ propertyState = [properties.directionState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/DominantBaseline.qml b/plugins/dockers/textproperties/qml/DominantBaseline.qml
index bce6db6c39..32da514bfd 100644
--- a/plugins/dockers/textproperties/qml/DominantBaseline.qml
+++ b/plugins/dockers/textproperties/qml/DominantBaseline.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:listbox", "Dominant Baseline");
propertyName: "dominant-baseline";
- propertyType: TextPropertyBase.Mixed;
+ propertyType: TextPropertyConfigModel.Mixed;
toolTip: i18nc("@info:tooltip",
"Dominant Baseline specifies how stretches of text of different sizes are aligned, it is also the default for Alignment Baseline.");
searchTerms: i18nc("comma separated search terms for the dominant-baseline property, matching is case-insensitive",
@@ -21,7 +21,8 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
baselineSelection = properties.dominantBaseline;
- visible = properties.dominantBaselineState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.dominantBaselineState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qml
index acb209e758..a0637ff71d 100644
--- a/plugins/dockers/textproperties/qml/FontFamily.qml
+++ b/plugins/dockers/textproperties/qml/FontFamily.qml
@@ -11,7 +11,8 @@ import org.krita.flake.text 1.0
CollapsibleGroupProperty {
propertyTitle: i18nc("@label", "Font Family");
propertyName: "font-family";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
+ visibilityState: TextPropertyConfigModel.AlwaysVisible;
toolTip: i18nc("@info:tooltip",
"Font family allows selecting a list of fonts that should be used for the current text. The first font family is the primary font used, while each font family after that is used for fallback.");
searchTerms: i18nc("comma separated search terms for the font-family property, matching is case-insensitive",
@@ -22,7 +23,8 @@ CollapsibleGroupProperty {
onPropertiesUpdated: {
blockSignals = true;
fontFamilies = properties.fontFamilies;
- visible = properties.fontFamiliesState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.fontFamiliesState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/FontKerning.qml b/plugins/dockers/textproperties/qml/FontKerning.qml
index f0bd41651f..08f6c042f5 100644
--- a/plugins/dockers/textproperties/qml/FontKerning.qml
+++ b/plugins/dockers/textproperties/qml/FontKerning.qml
@@ -15,7 +15,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Font Kerning");
propertyName: "font-kerning";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Turn font kerning on or off. Font kerning enables per-glyph spacing adjustments.");
searchTerms: i18nc("comma separated search terms for the font-kerning property, matching is case-insensitive",
@@ -25,7 +25,8 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
kerning = properties.fontKerning;
- visible = properties.fontKerningState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.fontKerningState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qml
index 0d334c6b9c..d95f9a2a29 100644
--- a/plugins/dockers/textproperties/qml/FontSize.qml
+++ b/plugins/dockers/textproperties/qml/FontSize.qml
@@ -12,7 +12,8 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:spinbox", "Font Size");
propertyName: "font-size";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
+ visibilityState: TextPropertyConfigModel.AlwaysVisible;
toolTip: i18nc("@info:tooltip",
"Font size allows setting the size of the characters.");
searchTerms: i18nc("comma separated search terms for the fontsize property, matching is case-insensitive",
@@ -26,7 +27,8 @@ TextPropertyBase {
fontSizeUnitCmb.dpi = canvasDPI;
fontSizeUnitCmb.setTextProperties(properties);
fontSizeUnitCmb.setDataValueAndUnit(properties.fontSize.value, properties.fontSize.unitType);
- visible = properties.fontSizeState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.fontSizeState];
+ setVisibleFromProperty();
blockSignals = false;
}
onFontSizeChanged: {
diff --git a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
index 379f49289f..4ee7a24f11 100644
--- a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
+++ b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:spinbox", "Font Size Adjust");
propertyName: "font-size-adjust";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Font size adjust allows setting a ratio that the x-height must be matched by.");
searchTerms: i18nc("comma separated search terms for the fontsize adjust property, matching is case-insensitive",
@@ -23,7 +23,8 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
fontSizeAdjust = properties.fontSizeAdjust * fontSizeAdjustSpn.multiplier;
- visible = properties.fontSizeAdjustState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.fontSizeAdjustState];
+ setVisibleFromProperty();
blockSignals = false;
}
onFontSizeAdjustChanged: {
diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qml
index 553177a7f7..8fefc182e6 100644
--- a/plugins/dockers/textproperties/qml/FontStyle.qml
+++ b/plugins/dockers/textproperties/qml/FontStyle.qml
@@ -12,7 +12,8 @@ import org.krita.components 1.0
CollapsibleGroupProperty {
propertyTitle: i18nc("@label", "Font Style");
propertyName: "font-sub-style";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
+ visibilityState: TextPropertyConfigModel.AlwaysVisible;
toolTip: i18nc("@info:tooltip",
"Font style allows setting the sub style of the given font family, such as italics and bold");
searchTerms: i18nc("comma separated search terms for the fontsize property, matching is case-insensitive",
@@ -43,13 +44,17 @@ CollapsibleGroupProperty {
fontSynthesizeSlant = properties.fontSynthesisStyle;
fontSynthesizeWeight = properties.fontSynthesisWeight;
styleCmb.currentIndex = fontStylesModel.rowForStyle(properties.fontWeight, properties.fontWidth, properties.fontStyle.style, properties.fontStyle.value);
- visible = properties.fontWeightState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontStyleState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontWidthState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontOpticalSizeLinkState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.axisValueState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontSynthesisStyleState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.fontSynthesisWeightState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [
+ properties.fontWeightState,
+ properties.fontStyleState,
+ properties.fontWidthState,
+ properties.fontOpticalSizeLinkState,
+ properties.axisValueState,
+ properties.fontSynthesisStyleState,
+ properties.fontSynthesisWeightState
+ ]
+ setVisibleFromProperty();
blockSignals = false;
}
onFontWeightChanged: {
diff --git a/plugins/dockers/textproperties/qml/HangingPunctuation.qml b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
index 7868988be1..6965ea1fb3 100644
--- a/plugins/dockers/textproperties/qml/HangingPunctuation.qml
+++ b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Hanging Punctuation");
propertyName: "hanging-punctuation";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
toolTip: i18nc("@info:tooltip",
"Hanging punctuation allows hanging opening and closing punctuation as well as commas. This implementation only implements East-Asian style hanging punctuation.");
searchTerms: i18nc("comma separated search terms for the hanging-punctuation property, matching is case-insensitive",
@@ -25,7 +25,8 @@ TextPropertyBase {
hangStart = properties.hangingPunctuationFirst;
hangEnd = properties.hangingPunctuationLast;
hangComma = properties.hangingPunctuationComma;
- visible = properties.hangingPunctuationState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.hangingPunctuationState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/Language.qml b/plugins/dockers/textproperties/qml/Language.qml
index 4fa7fbedfa..b02f805491 100644
--- a/plugins/dockers/textproperties/qml/Language.qml
+++ b/plugins/dockers/textproperties/qml/Language.qml
@@ -12,7 +12,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Language");
propertyName: "locale";
- propertyType: TextPropertyBase.Mixed;
+ propertyType: TextPropertyConfigModel.Mixed;
toolTip: i18nc("@info:tooltip",
"The language of this text shape. Language affects a number of properties, like glyph shape, upper- and lowercase and line breaking");
searchTerms: i18nc("comma separated search terms for the language property, matching is case-insensitive",
@@ -33,7 +33,8 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
localeHandler.bcp47Tag = properties.language;
- visible = properties.languageState !== KoSvgTextPropertiesModel.PropertyUnset;
+ propertyState = [properties.languageState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qml
index e1f57e52f2..ea7c2e8a4e 100644
--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml
+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:spinbox", "Letter Spacing");
propertyName: "letter-spacing";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Letter spacing controls the spacing between visible clusters of characters.");
searchTerms: i18nc("comma separated search terms for the letter-spacing property, matching is case-insensitive",
@@ -25,7 +25,9 @@ TextPropertyBase {
letterSpacingUnitCmb.dpi = canvasDPI;
letterSpacingUnitCmb.setTextProperties(properties);
letterSpacingUnitCmb.setDataValueAndUnit(properties.letterSpacing.value, properties.letterSpacing.unitType);
- visible = properties.letterSpacingState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.letterSpacingState];
+ setVisibleFromProperty();
blockSignals = false;
}
onLetterSpacingChanged: {
diff --git a/plugins/dockers/textproperties/qml/LineBreak.qml b/plugins/dockers/textproperties/qml/LineBreak.qml
index dc37b0857c..5b256d76d7 100644
--- a/plugins/dockers/textproperties/qml/LineBreak.qml
+++ b/plugins/dockers/textproperties/qml/LineBreak.qml
@@ -17,12 +17,14 @@ TextPropertyBase {
"Line Break allows choosing a strictness for the line breaking algorithm. Mostly used for CJK scripts, requires language being set.");
searchTerms: i18nc("comma separated search terms for the line-break property, matching is case-insensitive",
"line-break, line breaking, strictness, kinsoku");
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
onPropertiesUpdated: {
blockSignals = true;
breakType = properties.lineBreak;
- visible = properties.lineBreakState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.lineBreakState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qml
index a06a15b9ca..0ff3b78b0c 100644
--- a/plugins/dockers/textproperties/qml/LineHeight.qml
+++ b/plugins/dockers/textproperties/qml/LineHeight.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Line Height");
propertyName: "line-height";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Line Height controls the line height used for the range of text.");
searchTerms: i18nc("comma separated search terms for the line-height property, matching is case-insensitive",
@@ -48,7 +48,9 @@ TextPropertyBase {
converter.setFontMetricsFromTextPropertiesModel(properties, false, true);
converter.percentageReference = properties.resolvedFontSize(false);
converter.setDataValueAndUnit(properties.lineHeight.value, properties.lineHeight.unit);
- visible = properties.lineHeightState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.lineHeightState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OTCaps.qml b/plugins/dockers/textproperties/qml/OTCaps.qml
index d55919a464..8f0d0aa927 100644
--- a/plugins/dockers/textproperties/qml/OTCaps.qml
+++ b/plugins/dockers/textproperties/qml/OTCaps.qml
@@ -11,17 +11,21 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Glyphs: Capitals");
propertyName: "ot-capitals";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Enable opentype features related to capitals");
searchTerms: i18nc("comma separated search terms for the font-variant-caps property, matching is case-insensitive",
"font-variant-caps, Small caps, Petite Caps, Unicase, Titling, Capitals");
property int capsType;
+
+
onPropertiesUpdated: {
blockSignals = true;
capsType = properties.fontVariantCaps;
- visible = properties.fontVariantCapsState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontVariantCapsState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OTEastAsian.qml b/plugins/dockers/textproperties/qml/OTEastAsian.qml
index 0881435052..a645a11f7d 100644
--- a/plugins/dockers/textproperties/qml/OTEastAsian.qml
+++ b/plugins/dockers/textproperties/qml/OTEastAsian.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Glyphs: East-Asian");
propertyName: "ot-east-asian";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Enable glyph forms related to East Asian text layout.");
searchTerms: i18nc("comma separated search terms for the font-variant-east-asian property, matching is case-insensitive",
@@ -26,7 +26,9 @@ TextPropertyBase {
ruby = properties.fontVariantEastAsian.ruby;
variantType = properties.fontVariantEastAsian.variant;
widthType = properties.fontVariantEastAsian.width;
- visible = properties.fontVariantEastAsianState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontVariantEastAsianState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OTLigatures.qml b/plugins/dockers/textproperties/qml/OTLigatures.qml
index 50998ffddd..0174be780b 100644
--- a/plugins/dockers/textproperties/qml/OTLigatures.qml
+++ b/plugins/dockers/textproperties/qml/OTLigatures.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Glyphs: Ligatures");
propertyName: "ot-ligatures";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Enable or disable ligatures and contextual alternates on the text.");
searchTerms: i18nc("comma separated search terms for the font-variant-ligatures property, matching is case-insensitive",
@@ -22,13 +22,16 @@ TextPropertyBase {
property alias historicalLigatures: historicalLigaCbx.checked;
property alias contextualAlternates: contextualLigaCbx.checked;
+
onPropertiesUpdated: {
blockSignals = true;
commonLigatures = properties.fontVariantLigatures.commonLigatures;
discretionaryLigatures = properties.fontVariantLigatures.discretionaryLigatures;
historicalLigatures = properties.fontVariantLigatures.historicalLigatures;
contextualAlternates = properties.fontVariantLigatures.contextualAlternates;
- visible = properties.fontVariantLigaturesState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontVariantLigaturesState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OTNumeric.qml b/plugins/dockers/textproperties/qml/OTNumeric.qml
index fce84ca876..0033cef5e7 100644
--- a/plugins/dockers/textproperties/qml/OTNumeric.qml
+++ b/plugins/dockers/textproperties/qml/OTNumeric.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Glyphs: Numeric");
propertyName: "ot-numeric";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Enable number-related glyph forms on the text.");
searchTerms: i18nc("comma separated search terms for the font-variant-numeric property, matching is case-insensitive",
@@ -30,7 +30,9 @@ TextPropertyBase {
fractionType = properties.fontVariantNumeric.fractions;
ordinals = properties.fontVariantNumeric.ordinals;
slashedZero = properties.fontVariantNumeric.slashedZero;
- visible = properties.fontVariantNumericState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontVariantNumericState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OTPosition.qml b/plugins/dockers/textproperties/qml/OTPosition.qml
index 167b9d55f7..615ffcbcc4 100644
--- a/plugins/dockers/textproperties/qml/OTPosition.qml
+++ b/plugins/dockers/textproperties/qml/OTPosition.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label", "Glyphs: Position");
propertyName: "ot-position";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Enable super or subscripts on the text.");
searchTerms: i18nc("comma separated search terms for the font-variant-position property, matching is case-insensitive",
@@ -19,10 +19,13 @@ TextPropertyBase {
property int positionType;
+
onPropertiesUpdated: {
blockSignals = true;
positionType = properties.fontVariantPosition;
- visible = properties.fontVariantPositionState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontVariantPositionState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
index 13bac76a38..b22b78b11f 100644
--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureSettings.qml
@@ -12,7 +12,7 @@ TextPropertyBase {
id: root;
propertyTitle: i18nc("@label", "OpenType Features");
propertyName: "ot-features";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Configure Open Type features.");
searchTerms: i18nc("comma separated search terms for the font-feature-settings property, matching is case-insensitive",
@@ -31,7 +31,9 @@ TextPropertyBase {
blockSignals = true;
// Setting text properties model will also set the opentype features.
fontFeatureModel.setFromTextPropertiesModel(properties);
- visible = properties.fontFeatureSettingsState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.fontFeatureSettingsState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qml
index 6a3aaadfd2..0463748ed6 100644
--- a/plugins/dockers/textproperties/qml/TabSize.qml
+++ b/plugins/dockers/textproperties/qml/TabSize.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Tab Size");
propertyName: "tab-size";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
toolTip: i18nc("@info:tooltip",
"Tab Size allows defining the size of tabulation characters.");
searchTerms: i18nc("comma separated search terms for the tab-size property, matching is case-insensitive",
@@ -45,7 +45,9 @@ TextPropertyBase {
converter.dpi = canvasDPI;
converter.setFontMetricsFromTextPropertiesModel(properties);
converter.setDataValueAndUnit(properties.tabSize.value, properties.tabSize.unit);
- visible = properties.tabSizeState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.tabSizeState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextAlign.qml b/plugins/dockers/textproperties/qml/TextAlign.qml
index 5ff2be807c..020c219152 100644
--- a/plugins/dockers/textproperties/qml/TextAlign.qml
+++ b/plugins/dockers/textproperties/qml/TextAlign.qml
@@ -11,7 +11,8 @@ import org.krita.flake.text 1.0
CollapsibleGroupProperty {
propertyTitle: i18nc("@title:group", "Text Align");
propertyName: "text-align";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
+ visibilityState: TextPropertyConfigModel.AlwaysVisible;
toolTip: i18nc("@info:tooltip",
"Text Align sets the alignment for the given block of characters.");
searchTerms: i18nc("comma separated search terms for the text-anchor property, matching is case-insensitive",
@@ -27,9 +28,13 @@ CollapsibleGroupProperty {
textAlignLast = properties.textAlignLast;
textAnchor = properties.textAnchor;
setButtonsChecked();
- visible = properties.textAlignAllState !== KoSvgTextPropertiesModel.PropertyUnset ||
- properties.textAlignLastState !== KoSvgTextPropertiesModel.PropertyUnset ||
- properties.textAnchorState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [
+ properties.textAlignAllState,
+ properties.textAlignLastState,
+ properties.textAnchorState
+ ];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextDecoration.qml b/plugins/dockers/textproperties/qml/TextDecoration.qml
index 00347cac8e..f2a927573b 100644
--- a/plugins/dockers/textproperties/qml/TextDecoration.qml
+++ b/plugins/dockers/textproperties/qml/TextDecoration.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Text Decoration");
propertyName: "text-decoration";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Text Decoration allows drawing underlines, overlines and striking through text.");
searchTerms: i18nc("comma separated search terms for the text-decoration property, matching is case-insensitive",
@@ -31,9 +31,12 @@ TextPropertyBase {
lineStyle = properties.textDecorationStyle;
lineColor = properties.textDecorationColor;
- visible = (properties.textDecorationLineState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.textDecorationStyleState !== KoSvgTextPropertiesModel.PropertyUnset
- || properties.textDecorationColorState !== KoSvgTextPropertiesModel.PropertyUnset);
+ propertyState = [
+ properties.textDecorationLineState,
+ properties.textDecorationStyleState,
+ properties.textDecorationColorState
+ ];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qml
index 0f7f65469c..fe2bc84985 100644
--- a/plugins/dockers/textproperties/qml/TextIndent.qml
+++ b/plugins/dockers/textproperties/qml/TextIndent.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
CollapsibleGroupProperty {
propertyTitle: i18nc("@title:group", "Text Indent");
propertyName: "text-indent";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
toolTip: i18nc("@info:tooltip",
"Text Indent allows setting indentation at the line start. Only works when the text is wrapping.");
searchTerms: i18nc("comma separated search terms for the text-indent property, matching is case-insensitive",
@@ -30,7 +30,9 @@ CollapsibleGroupProperty {
textIndentUnitCmb.setDataValueAndUnit(properties.textIndent.length.value, properties.textIndent.length.unitType);
hanging = properties.textIndent.hanging;
eachLine = properties.textIndent.eachLine;
- visible = properties.textIndentState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.textIndentState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
index 36b5fd9bd3..159085727c 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
@@ -15,13 +15,6 @@ Column {
width: parent && parent !== undefined? parent.width - (padding*2): 100;
height: visible? childrenRect.height: 0;
- enum PropertyType {
- Character, ///< This property can be applied on a character level.
- Paragraph, ///< This property only does something when applied to a paragraph.
- Mixed ///< This property can be in either.
- }
-
-
property KoSvgTextPropertiesModel properties : textPropertiesModel;
property double dpi: canvasDPI;
signal propertiesUpdated; ///< Used by each text property panel to update the data on the controls.
@@ -35,6 +28,31 @@ Column {
property string toolTip; ///< Tooltip associated with the property.
property string searchTerms; ///< Any additional search terms associated with the property.
+ property int visibilityState: TextPropertyConfigModel.FollowDefault;
+ property var propertyState: []; /// All property states related to the current property.
+
+ function setVisibleFromProperty() {
+ let visibleState = visibilityState === TextPropertyConfigModel.FollowDefault? textPropertyConfigModel.defaultVisibilityState: visibilityState;
+ if (visibleState === TextPropertyConfigModel.AlwaysVisible) {
+ visible = true;
+ } else if (visibleState === TextPropertyConfigModel.NeverVisible) {
+ visible = false;
+ } else {
+ visible = false;
+ for (let propState of propertyState) {
+ if (propState === KoSvgTextPropertiesModel.PropertySet
+ || propState === KoSvgTextPropertiesModel.PropertyTriState) {
+ visible = true;
+ break;
+ } else if (propState !== KoSvgTextPropertiesModel.PropertyUnset
+ && visibleState === TextPropertyConfigModel.WhenRelevant) {
+ visible = true;
+ break;
+ }
+ }
+ }
+ }
+
function autoEnable() {
enabled = true;
}
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
index 605cc62efd..f60a37f176 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBaseList.qml
@@ -41,7 +41,6 @@ ColumnLayout {
prop.searchTerms,
);
textPropertyConfigModel.loadFromConfiguration();
- console.log("property show", filteredConfigModel.showParagraphProperties);
if (filteredConfigModel.showParagraphProperties && prop.propertyType === TextPropertyConfigModel.Character) {
propertyWidgetModel.get(i).visible = false;
} else if (!filteredConfigModel.showParagraphProperties && prop.propertyType === TextPropertyConfigModel.Paragraph) {
diff --git a/plugins/dockers/textproperties/qml/TextRendering.qml b/plugins/dockers/textproperties/qml/TextRendering.qml
index daff6dc8fc..2e677b1e4f 100644
--- a/plugins/dockers/textproperties/qml/TextRendering.qml
+++ b/plugins/dockers/textproperties/qml/TextRendering.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Text Rendering");
propertyName: "text-rendering";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
toolTip: i18nc("@info:tooltip",
"Text Rendering controls the hinting and rendering style for the property");
searchTerms: i18nc("comma separated search terms for the text-rendering property, matching is case-insensitive",
@@ -21,7 +21,9 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
textRendering = properties.textRendering;
- visible = properties.textRenderingState !== KoSvgTextPropertiesModel.PropertyUnset
+
+ propertyState = [properties.textRenderingState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/TextTransform.qml b/plugins/dockers/textproperties/qml/TextTransform.qml
index 04b4237d47..64579e7312 100644
--- a/plugins/dockers/textproperties/qml/TextTransform.qml
+++ b/plugins/dockers/textproperties/qml/TextTransform.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Text Transform");
propertyName: "text-transform";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Text Transform allows transforming the given range of characters, for example, by setting them uppercase, or switching out half-width forms for full-width forms.");
searchTerms: i18nc("comma separated search terms for the text-transform property, matching is case-insensitive",
@@ -25,7 +25,9 @@ TextPropertyBase {
fullWidth = properties.textTransform.fullWidth;
fullSizeKana = properties.textTransform.fullSizeKana;
capitals = properties.textTransform.capitals;
- visible = properties.textTransformState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.textTransformState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/UnderlinePosition.qml b/plugins/dockers/textproperties/qml/UnderlinePosition.qml
index f238ee2b8b..ac80574411 100644
--- a/plugins/dockers/textproperties/qml/UnderlinePosition.qml
+++ b/plugins/dockers/textproperties/qml/UnderlinePosition.qml
@@ -15,7 +15,8 @@ TextPropertyBase {
"Specify the position of the underline for text-decoration.");
searchTerms: i18nc("comma separated search terms for the text-decoration-position property, matching is case-insensitive",
"text-decoration-position, underline, left, right, under");
- propertyType: TextPropertyBase.Mixed;
+ propertyType: TextPropertyConfigModel.Mixed;
+
property int horizontalPos: 0;
property int verticalPos: 0;
@@ -23,7 +24,9 @@ TextPropertyBase {
blockSignals = true;
horizontalPos = properties.textDecorationUnderlinePosHorizontal;
verticalPos = properties.textDecorationUnderlinePosVertical;
- visible = properties.textDecorationUnderlinePositionState !== KoSvgTextPropertiesModel.PropertyUnset
+
+ propertyState = [properties.textDecorationUnderlinePositionState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/WhiteSpace.qml b/plugins/dockers/textproperties/qml/WhiteSpace.qml
index 4fc5db4c41..878ffaf545 100644
--- a/plugins/dockers/textproperties/qml/WhiteSpace.qml
+++ b/plugins/dockers/textproperties/qml/WhiteSpace.qml
@@ -15,9 +15,11 @@ TextPropertyBase {
"The CSS white space rule controls how multiples of spaces are handled, and whether the text can wrap.");
searchTerms: i18nc("comma separated search terms for the white-space property, matching is case-insensitive",
"white-space, collapse, pre-formatted");
- propertyType: TextPropertyBase.Mixed;
+ propertyType: TextPropertyConfigModel.Mixed;
property int whiteSpace: 0;
+ visibilityState: TextPropertyConfigModel.NeverVisible;
+
readonly property int wsNormal: 0;
readonly property int wsPre: 1;
readonly property int wsNoWrap: 2;
@@ -44,7 +46,9 @@ TextPropertyBase {
whiteSpace = wsNoWrap;
}
}
- visible = properties.textCollapseState !== KoSvgTextPropertiesModel.PropertyUnset
+
+ propertyState = [properties.textCollapseState, properties.textWrap];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/WordBreak.qml b/plugins/dockers/textproperties/qml/WordBreak.qml
index 1b2b323fc7..6fa070295e 100644
--- a/plugins/dockers/textproperties/qml/WordBreak.qml
+++ b/plugins/dockers/textproperties/qml/WordBreak.qml
@@ -11,7 +11,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:listbox", "Word Break");
propertyName: "word-break";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Word Break allows fine-tuning the line breaking by toggling whether to only break at words or also allow breaking at characters. Useful for Korean or Ethiopian.");
searchTerms: i18nc("comma separated search terms for the word-break property, matching is case-insensitive",
@@ -22,7 +22,9 @@ TextPropertyBase {
onPropertiesUpdated: {
blockSignals = true;
breakType = properties.wordBreak;
- visible = properties.wordBreakState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.wordBreakState];
+ setVisibleFromProperty();
blockSignals = false;
}
diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qml
index 19856b2e3f..1c349389f0 100644
--- a/plugins/dockers/textproperties/qml/WordSpacing.qml
+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml
@@ -12,7 +12,7 @@ import org.krita.components 1.0
TextPropertyBase {
propertyTitle: i18nc("@title:group", "Word Spacing");
propertyName: "word-spacing";
- propertyType: TextPropertyBase.Character;
+ propertyType: TextPropertyConfigModel.Character;
toolTip: i18nc("@info:tooltip",
"Word spacing controls the size of word-break characters, such as the space character.");
searchTerms: i18nc("comma separated search terms for the word-spacing property, matching is case-insensitive",
@@ -20,12 +20,15 @@ TextPropertyBase {
property alias wordSpacing: wordSpacingUnitCmb.dataValue;
property alias wordSpacingUnit: wordSpacingUnitCmb.dataUnit;
+
onPropertiesUpdated: {
blockSignals = true;
wordSpacingUnitCmb.dpi = canvasDPI;
wordSpacingUnitCmb.setTextProperties(properties);
wordSpacingUnitCmb.setDataValueAndUnit(properties.wordSpacing.value, properties.wordSpacing.unitType);
- visible = properties.wordSpacingState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.wordSpacingState];
+ setVisibleFromProperty();
blockSignals = false;
}
onWordSpacingChanged: {
diff --git a/plugins/dockers/textproperties/qml/WritingMode.qml b/plugins/dockers/textproperties/qml/WritingMode.qml
index 83547dd5e0..9df1a343d0 100644
--- a/plugins/dockers/textproperties/qml/WritingMode.qml
+++ b/plugins/dockers/textproperties/qml/WritingMode.qml
@@ -11,17 +11,21 @@ import org.krita.flake.text 1.0
TextPropertyBase {
propertyTitle: i18nc("@label:listbox", "Writing Mode");
propertyName: "writing-mode";
- propertyType: TextPropertyBase.Paragraph;
+ propertyType: TextPropertyConfigModel.Paragraph;
toolTip: i18nc("@info:tooltip",
"Writing Mode sets whether the text flows horizontally or vertically, and in the latter case, whether the block flows right to left or left to right.");
searchTerms: i18nc("comma separated search terms for the writing-mode property, matching is case-insensitive",
"writing-mode, horizontal, vertical, top-to-bottom");
property int writingMode;
+
+
onPropertiesUpdated: {
blockSignals = true;
writingMode = properties.writingMode;
- visible = properties.writingModeState !== KoSvgTextPropertiesModel.PropertyUnset;
+
+ propertyState = [properties.writingModeState];
+ setVisibleFromProperty();
blockSignals = false;
}