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 the revert buttons check the state of the given property.

Wolthera van Hövell tot Westerflierb6c229e0bfac
diff --git a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
index 5d73980ae8..edb01e5b16 100644
--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.cpp
@@ -126,8 +126,21 @@ auto fontStyleProperty = lager::lenses::getset(
auto qColorProperty = lager::lenses::getset(
[](const QVariant &value) -> QColor {return value.value<QColor>();},
[](QVariant value, const QColor &val){value = QVariant::fromValue(val); return value;});
+
+
}
+auto propertyState = [](const KoSvgTextProperties::PropertyId &propId) { return [propId] (const KoSvgTextPropertyData &value) -> KoSvgTextPropertiesModel::PropertyState {
+ if (value.commonProperties.hasProperty(propId)) {
+ return KoSvgTextPropertiesModel::PropertySet;
+ } else if (value.tristate.contains(propId) || value.inheritedProperties.hasProperty(propId)) {
+ return KoSvgTextPropertiesModel::PropertyTriState;
+ }
+ return KoSvgTextPropertiesModel::PropertyUnset;
+
+};
+};
+
KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextPropertyData> _textData)
: textData(_textData)
, commonProperties(textData.zoom(createCommonProperties))
@@ -147,29 +160,53 @@ KoSvgTextPropertiesModel::KoSvgTextPropertiesModel(lager::cursor<KoSvgTextProper
, textIndentModel(textIndentData)
, tabSizeModel(tabSizeData)
, textTransformModel(textTransformData)
+ , LAGER_QT(fontSizeState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontSizeId))}
+ , LAGER_QT(lineHeightState) {lager::with(textData).map(propertyState(KoSvgTextProperties::LineHeightId))}
+ , LAGER_QT(letterSpacingState) {lager::with(textData).map(propertyState(KoSvgTextProperties::LetterSpacingId))}
+ , LAGER_QT(wordSpacingState) {lager::with(textData).map(propertyState(KoSvgTextProperties::WordSpacingId))}
+ , LAGER_QT(textIndentState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextIndentId))}
+ , LAGER_QT(tabSizeState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TabSizeId))}
+ , LAGER_QT(textTransformState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextTransformId))}
, LAGER_QT(writingMode) {textData.zoom(createTextProperty(KoSvgTextProperties::WritingModeId)).zoom(integerProperty)}
+ , LAGER_QT(writingModeState) {lager::with(textData).map(propertyState(KoSvgTextProperties::WritingModeId))}
, LAGER_QT(direction) {textData.zoom(createTextProperty(KoSvgTextProperties::DirectionId)).zoom(integerProperty)}
+ , LAGER_QT(directionState) {lager::with(textData).map(propertyState(KoSvgTextProperties::DirectionId))}
, LAGER_QT(textAlignAll) {textData.zoom(createTextProperty(KoSvgTextProperties::TextAlignAllId)).zoom(integerProperty)}
+ , LAGER_QT(textAlignAllState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextAlignAllId))}
, LAGER_QT(textAlignLast) {textData.zoom(createTextProperty(KoSvgTextProperties::TextAlignLastId)).zoom(integerProperty)}
+ , LAGER_QT(textAlignLastState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextAlignLastId))}
, LAGER_QT(textAnchor) {textData.zoom(createTextProperty(KoSvgTextProperties::TextAnchorId)).zoom(integerProperty)}
+ , LAGER_QT(textAnchorState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextAnchorId))}
, LAGER_QT(fontWeight) {textData.zoom(createTextProperty(KoSvgTextProperties::FontWeightId)).zoom(integerProperty)}
+ , LAGER_QT(fontWeightState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontWeightId))}
, LAGER_QT(fontWidth) {textData.zoom(createTextProperty(KoSvgTextProperties::FontStretchId)).zoom(integerProperty)}
+ , LAGER_QT(fontWidthState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontStretchId))}
, LAGER_QT(fontStyle) {textData.zoom(createTextProperty(KoSvgTextProperties::FontStyleId)).zoom(fontStyleProperty)}
+ , LAGER_QT(fontStyleState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontStyleId))}
, LAGER_QT(fontOpticalSizeLink) {textData.zoom(createTextProperty(KoSvgTextProperties::FontOpticalSizingId)).zoom(boolProperty)}
+ , LAGER_QT(fontOpticalSizeLinkState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontOpticalSizingId))}
, LAGER_QT(fontFamilies) {textData.zoom(createTextProperty(KoSvgTextProperties::FontFamiliesId)).zoom(stringListProperty)}
+ , LAGER_QT(fontFamiliesState) {lager::with(textData).map(propertyState(KoSvgTextProperties::FontFamiliesId))}
, LAGER_QT(textDecorationUnderline){textData.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationUnderline))}
, LAGER_QT(textDecorationOverline){textData.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationOverline))}
, LAGER_QT(textDecorationLineThrough){textData.zoom(createTextProperty(KoSvgTextProperties::TextDecorationLineId)).zoom(textDecorLineProp(KoSvgText::DecorationLineThrough))}
+ , LAGER_QT(textDecorationLineState) {lager::with(textData).map(propertyState(KoSvgTextProperties::TextDecorationLineId))}
, LAGER_QT(textDecorationStyle){textData.zoom(createTextProperty(KoSvgTextProperties::TextDecorationStyleId)).zoom(integerProperty)}
, LAGER_QT(textDecorationColor){textData.zoom(createTextProperty(KoSvgTextProperties::TextDecorationColorId)).zoom(qColorProperty)}
, LAGER_QT(hangingPunctuationFirst){textData.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangPunctuationProp(KoSvgText::HangFirst))}
, LAGER_QT(hangingPunctuationComma){textData.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangingPunactuationCommaProp)}
, LAGER_QT(hangingPunctuationLast){textData.zoom(createTextProperty(KoSvgTextProperties::HangingPunctuationId)).zoom(hangPunctuationProp(KoSvgText::HangLast))}
+ , LAGER_QT(hangingPunctuationState) {lager::with(textData).map(propertyState(KoSvgTextProperties::HangingPunctuationId))}
, LAGER_QT(alignmentBaseline){textData.zoom(createTextProperty(KoSvgTextProperties::AlignmentBaselineId)).zoom(integerProperty)}
+ , LAGER_QT(alignmentBaselineState) {lager::with(textData).map(propertyState(KoSvgTextProperties::AlignmentBaselineId))}
, LAGER_QT(dominantBaseline){textData.zoom(createTextProperty(KoSvgTextProperties::DominantBaselineId)).zoom(integerProperty)}
+ , LAGER_QT(dominantBaselineState) {lager::with(textData).map(propertyState(KoSvgTextProperties::DominantBaselineId))}
, LAGER_QT(baselineShiftMode){textData.zoom(createTextProperty(KoSvgTextProperties::BaselineShiftModeId)).zoom(integerProperty)}
+ , LAGER_QT(baselineShiftState) {lager::with(textData).map(propertyState(KoSvgTextProperties::BaselineShiftModeId))}
, LAGER_QT(wordBreak){textData.zoom(createTextProperty(KoSvgTextProperties::WordBreakId)).zoom(integerProperty)}
+ , LAGER_QT(wordBreakState) {lager::with(textData).map(propertyState(KoSvgTextProperties::WordBreakId))}
, LAGER_QT(lineBreak){textData.zoom(createTextProperty(KoSvgTextProperties::LineBreakId)).zoom(integerProperty)}
+ , LAGER_QT(lineBreakState) {lager::with(textData).map(propertyState(KoSvgTextProperties::LineBreakId))}
{
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.h
index 11c03d6a3c..b2c80c17cd 100644
--- a/libs/flake/text/lager/KoSvgTextPropertiesModel.h
+++ b/libs/flake/text/lager/KoSvgTextPropertiesModel.h
@@ -24,11 +24,11 @@
class KRITAFLAKE_EXPORT KoSvgTextPropertiesModel : public QObject
{
Q_OBJECT
- Q_PROPERTY(CssLengthPercentageModel *fontSize READ fontSize NOTIFY fontSizeChanged);
- Q_PROPERTY(LineHeightModel *lineHeight READ lineHeight NOTIFY lineHeightChanged);
- Q_PROPERTY(CssLengthPercentageModel *letterSpacing READ letterSpacing NOTIFY letterSpacingChanged);
- Q_PROPERTY(CssLengthPercentageModel *wordSpacing READ wordSpacing NOTIFY wordSpacingChanged);
- Q_PROPERTY(CssLengthPercentageModel *baselineShiftValue READ baselineShiftValue NOTIFY baselineShiftValueChanged);
+ Q_PROPERTY(CssLengthPercentageModel *fontSize READ fontSize NOTIFY fontSizeChanged)
+ Q_PROPERTY(LineHeightModel *lineHeight READ lineHeight NOTIFY lineHeightChanged)
+ Q_PROPERTY(CssLengthPercentageModel *letterSpacing READ letterSpacing NOTIFY letterSpacingChanged)
+ Q_PROPERTY(CssLengthPercentageModel *wordSpacing READ wordSpacing NOTIFY wordSpacingChanged)
+ Q_PROPERTY(CssLengthPercentageModel *baselineShiftValue READ baselineShiftValue NOTIFY baselineShiftValueChanged)
Q_PROPERTY(TextIndentModel *textIndent READ textIndent NOTIFY textIndentChanged)
Q_PROPERTY(TabSizeModel *tabSize READ tabSize NOTIFY tabSizeChanged)
Q_PROPERTY(TextTransformModel *textTransform READ textTransform NOTIFY textTransformChanged)
@@ -58,25 +58,47 @@ public:
TabSizeModel tabSizeModel;
TextTransformModel textTransformModel;
+ // Whether a given property is set, unset or tristate.
+ enum PropertyState {
+ PropertyUnset,
+ PropertySet,
+ PropertyTriState
+ };
+ Q_ENUM(PropertyState)
+
CssLengthPercentageModel *fontSize();
+ LAGER_QT_READER(PropertyState, fontSizeState);
LineHeightModel *lineHeight();
+ LAGER_QT_READER(PropertyState, lineHeightState);
CssLengthPercentageModel *letterSpacing();
+ LAGER_QT_READER(PropertyState, letterSpacingState);
CssLengthPercentageModel *wordSpacing();
+ LAGER_QT_READER(PropertyState, wordSpacingState);
CssLengthPercentageModel *baselineShiftValue();
TextIndentModel *textIndent();
+ LAGER_QT_READER(PropertyState, textIndentState);
TabSizeModel *tabSize();
+ LAGER_QT_READER(PropertyState, tabSizeState);
TextTransformModel *textTransform();
+ LAGER_QT_READER(PropertyState, textTransformState);
LAGER_QT_CURSOR(int, writingMode);
+ LAGER_QT_READER(PropertyState, writingModeState);
LAGER_QT_CURSOR(int, direction);
+ LAGER_QT_READER(PropertyState, directionState);
LAGER_QT_CURSOR(int, textAlignAll);
+ LAGER_QT_READER(PropertyState, textAlignAllState);
LAGER_QT_CURSOR(int, textAlignLast);
+ LAGER_QT_READER(PropertyState, textAlignLastState);
LAGER_QT_CURSOR(int, textAnchor);
+ LAGER_QT_READER(PropertyState, textAnchorState);
LAGER_QT_CURSOR(int, fontWeight);
+ LAGER_QT_READER(PropertyState, fontWeightState);
LAGER_QT_CURSOR(int, fontWidth);
+ LAGER_QT_READER(PropertyState, fontWidthState);
// QFont::Style isn't exposed to qml.
enum FontStyle {
@@ -84,16 +106,20 @@ public:
StyleItalic = QFont::StyleItalic,
StyleOblique = QFont::StyleOblique
};
- Q_ENUM(FontStyle);
+ Q_ENUM(FontStyle)
LAGER_QT_CURSOR(FontStyle, fontStyle);
+ LAGER_QT_READER(PropertyState, fontStyleState);
LAGER_QT_CURSOR(bool, fontOpticalSizeLink);
+ LAGER_QT_READER(PropertyState, fontOpticalSizeLinkState);
LAGER_QT_CURSOR(QStringList, fontFamilies);
+ LAGER_QT_READER(PropertyState, fontFamiliesState);
LAGER_QT_CURSOR(bool, textDecorationUnderline);
LAGER_QT_CURSOR(bool, textDecorationOverline);
LAGER_QT_CURSOR(bool, textDecorationLineThrough);
+ LAGER_QT_READER(PropertyState, textDecorationLineState);
LAGER_QT_CURSOR(int, textDecorationStyle);
@@ -108,13 +134,19 @@ public:
LAGER_QT_CURSOR(bool, hangingPunctuationFirst);
LAGER_QT_CURSOR(HangComma, hangingPunctuationComma);
LAGER_QT_CURSOR(bool, hangingPunctuationLast);
+ LAGER_QT_READER(PropertyState, hangingPunctuationState);
LAGER_QT_CURSOR(int, alignmentBaseline);
+ LAGER_QT_READER(PropertyState, alignmentBaselineState);
LAGER_QT_CURSOR(int, dominantBaseline);
+ LAGER_QT_READER(PropertyState, dominantBaselineState);
LAGER_QT_CURSOR(int, baselineShiftMode);
+ LAGER_QT_READER(PropertyState, baselineShiftState);
LAGER_QT_CURSOR(int, wordBreak);
+ LAGER_QT_READER(PropertyState, wordBreakState);
LAGER_QT_CURSOR(int, lineBreak);
+ LAGER_QT_READER(PropertyState, lineBreakState);
Q_SIGNALS:
diff --git a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
index 9ba4ab1436..65d3e498f8 100644
--- a/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
+++ b/plugins/dockers/textproperties/qml/AlignmentBaseline.qml
@@ -29,16 +29,8 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.alignmentBaselineState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qml
index 1ee07a2de5..a68d4cd5c8 100644
--- a/plugins/dockers/textproperties/qml/BaselineShift.qml
+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml
@@ -38,16 +38,8 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.baselineShiftState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
index 9904cfb588..90c77c3af8 100644
--- a/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
+++ b/plugins/dockers/textproperties/qml/CollapsibleGroupProperty.qml
@@ -33,6 +33,7 @@ TextPropertyBase {
id: collapse;
display: AbstractButton.IconOnly
icon.source: contentItemContainer.visible? "qrc:///light_groupOpened.svg" : "qrc:///light_groupClosed.svg";
+ icon.color: sysPalette.text;
icon.width: 12;
icon.height: 12;
onClicked: contentItemContainer.visible = !contentItemContainer.visible;
@@ -61,6 +62,6 @@ TextPropertyBase {
Item {
id: contentItemContainer;
width: parent.width;
- height: childrenRect.height;
+ height: visible? childrenRect.height: 0;
}
}
diff --git a/plugins/dockers/textproperties/qml/Direction.qml b/plugins/dockers/textproperties/qml/Direction.qml
index 674abc4211..661cfd34d6 100644
--- a/plugins/dockers/textproperties/qml/Direction.qml
+++ b/plugins/dockers/textproperties/qml/Direction.qml
@@ -29,16 +29,8 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.directionState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/DominantBaseline.qml b/plugins/dockers/textproperties/qml/DominantBaseline.qml
index 8db9541d39..1d4a9fb400 100644
--- a/plugins/dockers/textproperties/qml/DominantBaseline.qml
+++ b/plugins/dockers/textproperties/qml/DominantBaseline.qml
@@ -29,16 +29,8 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.dominantBaselineState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/FontFamily.qml b/plugins/dockers/textproperties/qml/FontFamily.qml
index f8c0ecbcf7..f294bec2eb 100644
--- a/plugins/dockers/textproperties/qml/FontFamily.qml
+++ b/plugins/dockers/textproperties/qml/FontFamily.qml
@@ -6,6 +6,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.12
+import org.krita.flake.text 1.0
CollapsibleGroupProperty {
propertyName: i18nc("@label", "Font Family:");
@@ -47,11 +48,8 @@ CollapsibleGroupProperty {
anchors.right: parent.right
columnSpacing: columnSpacing;
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.fontFamiliesState === KoSvgTextPropertiesModel.PropertySet;
}
ScrollView {
diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qml
index 97ae3c8e93..62f118acb8 100644
--- a/plugins/dockers/textproperties/qml/FontSize.qml
+++ b/plugins/dockers/textproperties/qml/FontSize.qml
@@ -6,10 +6,12 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.12
+import org.krita.flake.text 1.0
TextPropertyBase {
property alias fontSize: fontSizeSpn.value;
+ visible: properties.fontSizeState !== KoSvgTextPropertiesModel.PropertyUnset;
onPropertiesUpdated: {
blockSignals = true;
@@ -26,16 +28,9 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ id: revertFontSize;
+ revertEnabled: properties.fontSizeState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qml
index 5ba0003d0d..dd435b9ea3 100644
--- a/plugins/dockers/textproperties/qml/FontStyle.qml
+++ b/plugins/dockers/textproperties/qml/FontStyle.qml
@@ -14,6 +14,11 @@ CollapsibleGroupProperty {
property alias fontWeight: fontWeightSpn.value;
property alias fontWidth: fontStretchSpn.value;
property int fontSlant: KoSvgTextPropertiesModel.StyleNormal;
+
+ visible: properties.fontWeightState !== KoSvgTextPropertiesModel.PropertyUnset
+ || properties.fontStyleState !== KoSvgTextPropertiesModel.PropertyUnset
+ || properties.fontWidthState !== KoSvgTextPropertiesModel.PropertyUnset;
+
onFontSlantChanged: {
fontSlantCmb.currentIndex = fontSlantCmb.indexOfValue(fontSlant);
if (!blockSignals) {
@@ -59,12 +64,11 @@ CollapsibleGroupProperty {
anchors.right: parent.right
columnSpacing: 5;
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ id: revertWeight;
+ revertEnabled: properties.fontWeightState === KoSvgTextPropertiesModel.PropertySet;
}
+
Label {
text: i18nc("@label:spinbox", "Weight:")
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
@@ -79,11 +83,9 @@ CollapsibleGroupProperty {
}
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ id: revertWidth;
+ revertEnabled: properties.fontWidthState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@label:spinbox", "Width:")
@@ -98,11 +100,9 @@ CollapsibleGroupProperty {
Layout.fillWidth: true
}
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ id: revertStyle;
+ revertEnabled: properties.fontStyleState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@label:listbox", "Slant:")
@@ -123,11 +123,9 @@ CollapsibleGroupProperty {
onActivated: fontSlant = currentValue;
}
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ id: revertOpticalLink;
+ revertEnabled: properties.fontOpticalSizeLinkState === KoSvgTextPropertiesModel.PropertySet;
}
Item {
width: 1;
diff --git a/plugins/dockers/textproperties/qml/HangingPunctuation.qml b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
index 03ed353c2c..15ee0470f4 100644
--- a/plugins/dockers/textproperties/qml/HangingPunctuation.qml
+++ b/plugins/dockers/textproperties/qml/HangingPunctuation.qml
@@ -44,16 +44,8 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.hangingPunctuationState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qml
index 68b6914538..fd52136c9e 100644
--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml
+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml
@@ -6,6 +6,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.12
+import org.krita.flake.text 1.0
TextPropertyBase {
property alias letterSpacing: letterSpacingSpn.value;
@@ -25,16 +26,8 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.letterSpacingState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/LineBreak.qml b/plugins/dockers/textproperties/qml/LineBreak.qml
index 262b4186fe..92d4536719 100644
--- a/plugins/dockers/textproperties/qml/LineBreak.qml
+++ b/plugins/dockers/textproperties/qml/LineBreak.qml
@@ -10,6 +10,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
property int breakType;
+ visible: properties.lineBreakState !== KoSvgTextPropertiesModel.PropertyUnset;
onPropertiesUpdated: {
blockSignals = true;
@@ -28,16 +29,9 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ id: revertLineBreak;
+ revertEnabled: properties.lineBreakState === KoSvgTextPropertiesModel.PropertySet
}
Label {
diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qml
index 9060358be5..9256fe0b7e 100644
--- a/plugins/dockers/textproperties/qml/LineHeight.qml
+++ b/plugins/dockers/textproperties/qml/LineHeight.qml
@@ -12,6 +12,7 @@ TextPropertyBase {
property alias isNormal: lineHeightNormalCbx.checked;
property alias lineHeight: lineHeightSpn.value;
property int lineHeightUnit: LineHeightModel.Lines;
+ visible: properties.lineHeightState !== KoSvgTextPropertiesModel.PropertyUnset;
onPropertiesUpdated: {
blockSignals = true;
@@ -44,16 +45,9 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ id: revertLineHeight;
+ revertEnabled: properties.lineHeightState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/RevertPropertyButton.qml b/plugins/dockers/textproperties/qml/RevertPropertyButton.qml
new file mode 100644
index 0000000000..54a2a65622
--- /dev/null
+++ b/plugins/dockers/textproperties/qml/RevertPropertyButton.qml
@@ -0,0 +1,25 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Wolthera van Hövell tot Westerflier <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+import QtQuick 2.15
+import QtQuick.Controls 2.0
+
+Item {
+ width: firstColumnWidth;
+ height: firstColumnWidth;
+
+ property alias revertEnabled: revert.enabled;
+ property bool inheritable: true;
+
+ ToolButton {
+ id: revert;
+ icon.width: 22;
+ icon.height: 22;
+ icon.color: sysPalette.text;
+ opacity: enabled? 1.0: 0.5;
+ display: AbstractButton.IconOnly
+ icon.source: parent.inheritable? "qrc:///light_edit-undo.svg": "qrc:///22_light_trash-empty.svg";
+ }
+}
diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qml
index aff0ec5eb7..2ce561bb56 100644
--- a/plugins/dockers/textproperties/qml/TabSize.qml
+++ b/plugins/dockers/textproperties/qml/TabSize.qml
@@ -39,11 +39,8 @@ TextPropertyBase {
anchors.right: parent.right
columnSpacing: columnSpacing;
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.tabSizeState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@title:group", "Tab Size:")
diff --git a/plugins/dockers/textproperties/qml/TextAlign.qml b/plugins/dockers/textproperties/qml/TextAlign.qml
index 2278ecfcc0..836cd15d88 100644
--- a/plugins/dockers/textproperties/qml/TextAlign.qml
+++ b/plugins/dockers/textproperties/qml/TextAlign.qml
@@ -50,11 +50,8 @@ CollapsibleGroupProperty {
anchors.right: parent.right
columnSpacing: columnSpacing;
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.textAlignAllState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@label:listbox", "Text Align:")
@@ -77,11 +74,8 @@ CollapsibleGroupProperty {
onActivated: textAlignAll = currentValue;
}
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.textAlignLastState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@label:listbox", "Align Last:")
@@ -105,11 +99,8 @@ CollapsibleGroupProperty {
}
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.textAnchorState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
text: i18nc("@label:listbox", "Text Anchor:")
diff --git a/plugins/dockers/textproperties/qml/TextDecoration.qml b/plugins/dockers/textproperties/qml/TextDecoration.qml
index 23e830cc6c..26990087f7 100644
--- a/plugins/dockers/textproperties/qml/TextDecoration.qml
+++ b/plugins/dockers/textproperties/qml/TextDecoration.qml
@@ -56,16 +56,9 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.textDecorationLineState === KoSvgTextPropertiesModel.PropertySet;
+ inheritable: false;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qml
index 44bb65800b..943ba3bc3e 100644
--- a/plugins/dockers/textproperties/qml/TextIndent.qml
+++ b/plugins/dockers/textproperties/qml/TextIndent.qml
@@ -6,6 +6,7 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.12
+import org.krita.flake.text 1.0
CollapsibleGroupProperty {
propertyName: i18nc("@title:group", "Text Indent:");
@@ -58,11 +59,8 @@ CollapsibleGroupProperty {
anchors.right: parent.right
columnSpacing: columnSpacing;
- ToolButton {
- width: firstColumnWidth;
- height: firstColumnWidth;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
+ RevertPropertyButton {
+ revertEnabled: properties.textIndentState === KoSvgTextPropertiesModel.PropertySet;
}
diff --git a/plugins/dockers/textproperties/qml/TextProperties.qml b/plugins/dockers/textproperties/qml/TextProperties.qml
index 2ec13c058d..f355645454 100644
--- a/plugins/dockers/textproperties/qml/TextProperties.qml
+++ b/plugins/dockers/textproperties/qml/TextProperties.qml
@@ -22,11 +22,9 @@ Rectangle {
function setProperties() {
for (var i = 0; i < characterPropertiesModel.count; i++) {
- characterPropertiesModel.get(i).properties = textPropertiesModel;
characterPropertiesModel.get(i).propertiesUpdated();
}
for (var l = 0; l < paragraphPropertiesModel.count; l++) {
- paragraphPropertiesModel.get(l).properties = textPropertiesModel;
paragraphPropertiesModel.get(l).propertiesUpdated();
}
}
@@ -109,6 +107,7 @@ Rectangle {
border.color: sysPalette.base;
border.width: 1;
}
+ clip: true;
ListView {
id: paragraphProperties
model: ObjectModel {
diff --git a/plugins/dockers/textproperties/qml/TextPropertyBase.qml b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
index 2dbbf51205..fc889a99cd 100644
--- a/plugins/dockers/textproperties/qml/TextPropertyBase.qml
+++ b/plugins/dockers/textproperties/qml/TextPropertyBase.qml
@@ -9,9 +9,12 @@ import org.krita.flake.text 1.0
Column {
property int firstColumnWidth: 32;
property int columnSpacing: 5;
- width: parent? parent.width: 100;
+ padding: columnSpacing;
+ width: parent? parent.width - (padding*2): 100;
+ height: visible? childrenRect.height+padding: 0;
- property KoSvgTextPropertiesModel properties;
+
+ property KoSvgTextPropertiesModel properties : textPropertiesModel;
signal propertiesUpdated; ///< Used by each text property panel to update the data on the controls.
property bool blockSignals; ///< When setting the data on the controls, this needs to be enabled and checked while returning data from the controls.
diff --git a/plugins/dockers/textproperties/qml/TextTransform.qml b/plugins/dockers/textproperties/qml/TextTransform.qml
index a455aa1130..21943b4678 100644
--- a/plugins/dockers/textproperties/qml/TextTransform.qml
+++ b/plugins/dockers/textproperties/qml/TextTransform.qml
@@ -45,16 +45,8 @@ TextPropertyBase {
columnSpacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.textTransformState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/WordBreak.qml b/plugins/dockers/textproperties/qml/WordBreak.qml
index f92be655f5..eb42f5f7d6 100644
--- a/plugins/dockers/textproperties/qml/WordBreak.qml
+++ b/plugins/dockers/textproperties/qml/WordBreak.qml
@@ -10,6 +10,7 @@ import org.krita.flake.text 1.0
TextPropertyBase {
property int breakType;
+ visible: properties.wordBreakState !== KoSvgTextPropertiesModel.PropertyUnset;
onPropertiesUpdated: {
blockSignals = true;
@@ -28,16 +29,9 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ id: revertWordBreak;
+ revertEnabled: properties.wordBreakState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qml
index ce2d97d0d6..3c9d3a8dd4 100644
--- a/plugins/dockers/textproperties/qml/WordSpacing.qml
+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml
@@ -6,9 +6,11 @@
import QtQuick 2.0
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.12
+import org.krita.flake.text 1.0
TextPropertyBase {
- property alias wordSpacing: wordSpacingSpn.value
+ property alias wordSpacing: wordSpacingSpn.value;
+ visible: properties.wordSpacingState !== KoSvgTextPropertiesModel.PropertyUnset;
onPropertiesUpdated: {
blockSignals = true;
@@ -25,16 +27,8 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.wordSpacingState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/qml/WritingMode.qml b/plugins/dockers/textproperties/qml/WritingMode.qml
index 7a0b442f41..58a06e880d 100644
--- a/plugins/dockers/textproperties/qml/WritingMode.qml
+++ b/plugins/dockers/textproperties/qml/WritingMode.qml
@@ -28,16 +28,8 @@ TextPropertyBase {
spacing: columnSpacing;
width: parent.width;
- Item {
- width: firstColumnWidth;
- height: firstColumnWidth;
- ToolButton {
- id: revert;
- icon.width: 22;
- icon.height: 22;
- display: AbstractButton.IconOnly
- icon.source: "qrc:///light_view-refresh.svg"
- }
+ RevertPropertyButton {
+ revertEnabled: properties.writingModeState === KoSvgTextPropertiesModel.PropertySet;
}
Label {
diff --git a/plugins/dockers/textproperties/textproperties.qrc b/plugins/dockers/textproperties/textproperties.qrc
index 26835ff8e3..2fda58c6ed 100644
--- a/plugins/dockers/textproperties/textproperties.qrc
+++ b/plugins/dockers/textproperties/textproperties.qrc
@@ -29,5 +29,6 @@
<file alias="TabSize.qml">qml/TabSize.qml</file>
<file alias="WhiteSpace.qml">qml/WhiteSpace.qml</file>
<file alias="UnderlinePosition.qml">qml/UnderlinePosition.qml</file>
+ <file alias="RevertPropertyButton.qml">qml/RevertPropertyButton.qml</file>
</qresource>
</RCC>