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

Replace all instances of DoubleSpinBox and Spinbox in text properties docker with sliders.

Wolthera van Hövell tot Westerflier36f52d0cb013
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qml
index ae15096084..34b6267e37 100644
--- a/plugins/dockers/textproperties/qml/BaselineShift.qml
+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml
@@ -116,13 +116,13 @@ TextPropertyBase {
id: baselinePalette;
colorGroup: baselineShiftSpn.enabled? SystemPalette.Active: SystemPalette.Disabled;
}
- DoubleSpinBox {
+ KisDoubleSliderSpinBox {
id: baselineShiftSpn
width: parent.width;
enabled: baselineShiftMode === KoSvgText.ShiftLengthPercentage;
- from: -999 * multiplier;
- to: 999 * multiplier;
- onValueChanged: if (enabled) baselineShiftUnitCmb.userValue = value;
+ dFrom: -99;
+ dTo: 99;
+ onDValueChanged: if (enabled) baselineShiftUnitCmb.userValue = dValue;
palette: baselinePalette.palette;
}
}
@@ -136,7 +136,7 @@ TextPropertyBase {
isFontSize: false;
enabled: baselineShiftMode === KoSvgText.ShiftLengthPercentage;
dpi:dpi;
- onUserValueChanged: baselineShiftSpn.value = userValue;
+ onUserValueChanged: baselineShiftSpn.dValue = userValue;
}
}
}
diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qml
index d95f9a2a29..55a29e981c 100644
--- a/plugins/dockers/textproperties/qml/FontSize.qml
+++ b/plugins/dockers/textproperties/qml/FontSize.qml
@@ -53,23 +53,19 @@ TextPropertyBase {
onClicked: properties.fontSizeState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: propertyTitle;
- elide: Text.ElideRight;
- Layout.fillWidth: true;
- font.italic: properties.fontSizeState === KoSvgTextPropertiesModel.PropertyTriState;
- }
-
- DoubleSpinBox {
+ KisDoubleSliderSpinBox {
id: fontSizeSpn;
- editable: true;
+ prefix: propertyTitle+ ": "
Layout.fillWidth: true;
- from: 0;
- to: 99999 * multiplier;
- stepSize: 100;
+ dFrom: 0;
+ dTo: 999;
+ softDFrom: 0;
+ softDTo: 72;
+ softRangeActive: true;
+ blockUpdateSignalOnDrag: true;
- onValueChanged: fontSizeUnitCmb.userValue = value;
+ onDValueChanged: fontSizeUnitCmb.userValue = dValue;
}
UnitComboBox {
@@ -81,7 +77,7 @@ TextPropertyBase {
Layout.preferredWidth: minimumUnitBoxWidth;
Layout.maximumWidth: implicitWidth;
- onUserValueChanged: fontSizeSpn.value = userValue;
+ onUserValueChanged: fontSizeSpn.dValue = userValue;
}
}
}
diff --git a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
index 4ee7a24f11..41704fa827 100644
--- a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
+++ b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml
@@ -18,18 +18,18 @@ TextPropertyBase {
searchTerms: i18nc("comma separated search terms for the fontsize adjust property, matching is case-insensitive",
"size, small, big, medium, font-size-adjust");
- property alias fontSizeAdjust: fontSizeAdjustSpn.value;
+ property alias fontSizeAdjust: fontSizeAdjustSpn.dValue;
onPropertiesUpdated: {
blockSignals = true;
- fontSizeAdjust = properties.fontSizeAdjust * fontSizeAdjustSpn.multiplier;
+ fontSizeAdjust = properties.fontSizeAdjust;
propertyState = [properties.fontSizeAdjustState];
setVisibleFromProperty();
blockSignals = false;
}
onFontSizeAdjustChanged: {
if (!blockSignals) {
- properties.fontSizeAdjust = fontSizeAdjust/fontSizeAdjustSpn.multiplier;
+ properties.fontSizeAdjust = fontSizeAdjust;
}
}
@@ -45,21 +45,17 @@ TextPropertyBase {
onClicked: properties.fontSizeAdjustState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: propertyTitle;
- elide: Text.ElideRight;
+ KisDoubleSliderSpinBox {
+ id: fontSizeAdjustSpn
+ prefix: propertyTitle+ ": "
+ softDFrom: 0
+ softDTo: 1
+ dFrom: 0;
+ dTo: 5;
+ softRangeActive: true
+ dStepSize: 0.1;
+ Layout.preferredWidth: implicitWidth;
Layout.fillWidth: true;
- font.italic: properties.fontSizeAdjustState === KoSvgTextPropertiesModel.PropertyTriState;
- }
-
- DoubleSpinBox {
- id: fontSizeAdjustSpn;
- editable: true;
- Layout.fillWidth: true;
-
- from: 0;
- to: 999 * multiplier;
- stepSize: 100;
}
Button {
diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qml
index 8fefc182e6..153ca054f6 100644
--- a/plugins/dockers/textproperties/qml/FontStyle.qml
+++ b/plugins/dockers/textproperties/qml/FontStyle.qml
@@ -153,24 +153,14 @@ CollapsibleGroupProperty {
onClicked: properties.fontWeightState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: i18nc("@label:spinbox", "Weight:")
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
- horizontalAlignment: Text.AlignRight;
- Layout.preferredWidth: implicitWidth;
- elide: Text.ElideRight;
- font.italic: properties.fontWeightState === KoSvgTextPropertiesModel.PropertyTriState;
- }
-
-
- SpinBox {
+ KisIntSliderSpinBox {
id: fontWeightSpn
+ prefix: i18nc("@label:spinbox", "Weight: ");
from: 0;
to: 1000;
- editable: true;
+ blockUpdateSignalOnDrag: true;
Layout.fillWidth: true;
-
- wheelEnabled: true;
+ Layout.columnSpan: 2;
}
RevertPropertyButton {
@@ -193,22 +183,15 @@ CollapsibleGroupProperty {
revertState: properties.fontWidthState;
onClicked: properties.fontWidthState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- id: widthLabel;
- text: i18nc("@label:spinbox", "Width:")
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
- horizontalAlignment: Text.AlignRight;
- Layout.preferredWidth: implicitWidth;
- elide: Text.ElideRight;
- font.italic: properties.fontWidthState === KoSvgTextPropertiesModel.PropertyTriState;
- }
- SpinBox {
+
+ KisIntSliderSpinBox {
id: fontStretchSpn
+ prefix: i18nc("@label:spinbox", "Width: ")
from: 0;
to: 200;
- editable: true;
+ blockUpdateSignalOnDrag: true;
Layout.fillWidth: true;
- wheelEnabled: true;
+ Layout.columnSpan: 2;
}
RevertPropertyButton {
@@ -249,17 +232,18 @@ CollapsibleGroupProperty {
fontSlant = CssFontStyleModel.StyleOblique;
}
Layout.fillWidth: true;
- Layout.fillHeight: true;
- Layout.minimumHeight: fontSlantSpn.height;
- SpinBox {
- id: fontSlantSpn
+ Layout.preferredHeight: fontSlantSpn.implicitHeight;
+ KisIntSliderSpinBox {
+ id: fontSlantSpn;
+ suffix:"°"
from: -90;
to: 90;
- editable: true;
enabled: fontSlant == CssFontStyleModel.StyleOblique;
-
- wheelEnabled: true;
-
+ PaletteControl {
+ id: slantSpnPal;
+ }
+ anchors.fill: parent;
+ palette: slantSpnPal.palette;
}
}
@@ -309,6 +293,7 @@ CollapsibleGroupProperty {
Layout.fillWidth: true;
Layout.preferredHeight: contentHeight;
spacing: parent.columnSpacing;
+ reuseItems: true;
Label {
text: i18n("No extra variable axes in this font");
@@ -318,32 +303,22 @@ CollapsibleGroupProperty {
visible: parent.count === 0;
}
- delegate: RowLayout {
- spacing: axesView.spacing;
- width: axesView.width;
- height: implicitHeight;
+ delegate: KisDoubleSliderSpinBox {
+ id: axisSpn;
required property string display;
required property double axismin;
required property double axismax;
required property bool axishidden;
required property var model;
- Label {
- text: parent.display;
- Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
- horizontalAlignment: Text.AlignRight;
- height: parent.height;
- elide: Text.ElideRight;
- Layout.preferredWidth: widthLabel.width+spacing;
- }
- DoubleSpinBox {
- id: axisSpn;
- from: parent.axismin * multiplier;
- to: parent.axismax * multiplier;
- value: model.edit * multiplier;
- onValueModified: model.edit = (value / axisSpn.multiplier);
- Layout.fillWidth: true;
- }
+ prefix: display + ": ";
+ dFrom: axismin;
+ dTo: axismax;
+ dValue: model.edit;
+ blockUpdateSignalOnDrag: true;
+ onDValueChanged: model.edit = dValue;
+
+ width: ListView.view.width;
}
}
diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qml
index ea7c2e8a4e..215731e6e8 100644
--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml
+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml
@@ -53,31 +53,32 @@ TextPropertyBase {
onClicked: properties.letterSpacingState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: propertyTitle;
- elide: Text.ElideRight;
- Layout.fillWidth: true;
- font.italic: properties.letterSpacingState === KoSvgTextPropertiesModel.PropertyTriState;
- }
- DoubleSpinBox {
- id: letterSpacingSpn
- editable: true;
- Layout.fillWidth: true;
- from: -999 * multiplier;
- to: 999 * multiplier;
- onValueChanged: letterSpacingUnitCmb.userValue = value;
- }
+ KisDoubleSliderSpinBox {
+ id: letterSpacingSpn;
+ prefix: propertyTitle+ ": "
+ Layout.fillWidth: true;
- UnitComboBox {
- id: letterSpacingUnitCmb
- spinBoxControl: letterSpacingSpn;
- isFontSize: false;
- dpi:dpi;
- onUserValueChanged: letterSpacingSpn.value = userValue;
- Layout.preferredWidth: minimumUnitBoxWidth;
- Layout.maximumWidth: implicitWidth;
- allowPercentage: false; // CSS-Text-4 has percentages for letter-spacing, but so does SVG 1.1, and they both are implemented differently.
- }
+ dFrom: -99;
+ dTo: 99;
+ softDFrom: -10;
+ softDTo: 10;
+ softRangeActive: true;
+ dStepSize: 0.1;
+
+ onDValueChanged: letterSpacingUnitCmb.userValue = dValue;
+
+ }
+
+ UnitComboBox {
+ id: letterSpacingUnitCmb
+ spinBoxControl: letterSpacingSpn;
+ isFontSize: false;
+ dpi:dpi;
+ onUserValueChanged: letterSpacingSpn.dValue = userValue;
+ Layout.preferredWidth: minimumUnitBoxWidth;
+ Layout.maximumWidth: implicitWidth;
+ allowPercentage: false; // CSS-Text-4 has percentages for letter-spacing, but so does SVG 1.1, and they both are implemented differently.
+ }
}
}
diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qml
index 0ff3b78b0c..6e7be01835 100644
--- a/plugins/dockers/textproperties/qml/LineHeight.qml
+++ b/plugins/dockers/textproperties/qml/LineHeight.qml
@@ -35,9 +35,8 @@ TextPropertyBase {
CssQmlUnitConverter {
id: converter;
dpi: dpi;
- dataMultiplier: lineHeightSpn.multiplier;
- onUserValueChanged: lineHeightSpn.value = userValue;
+ onUserValueChanged: lineHeightSpn.dValue = userValue;
onUserUnitChanged: lineHeightUnitCmb.currentIndex = lineHeightUnitCmb.indexOfValue(userUnit);
}
@@ -122,14 +121,14 @@ TextPropertyBase {
}
Layout.fillWidth: true;
Layout.fillHeight: true;
- DoubleSpinBox {
+ KisDoubleSliderSpinBox {
id: lineHeightSpn
width: parent.width;
enabled: !lineHeightNormalCbx.checked;
- from: 0;
- to: 999 * multiplier;
+ dFrom: 0;
+ dTo: 99;
- onValueChanged:if (enabled) converter.userValue = value;
+ onDValueChanged:if (enabled) converter.userValue = dValue;
palette: lineHeightPalette.palette;
}
}
@@ -152,7 +151,6 @@ TextPropertyBase {
PaletteControl {
id: lineHeightPalette;
- colorGroup: lineHeightUnitCmb.enabled? SystemPalette.Active: SystemPalette.Disabled;
}
palette: lineHeightPalette.palette;
wheelEnabled: true;
diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qml
index 0463748ed6..9edfbd0ef3 100644
--- a/plugins/dockers/textproperties/qml/TabSize.qml
+++ b/plugins/dockers/textproperties/qml/TabSize.qml
@@ -34,9 +34,8 @@ TextPropertyBase {
CssQmlUnitConverter {
id: converter;
dpi: dpi;
- dataMultiplier: tabSizeSpn.multiplier;
- onUserValueChanged: tabSizeSpn.value = userValue;
+ onUserValueChanged: tabSizeSpn.dValue = userValue;
onUserUnitChanged: tabSizeUnitCmb.currentIndex = tabSizeUnitCmb.indexOfValue(userUnit);
}
@@ -70,35 +69,23 @@ TextPropertyBase {
onEnableProperty: properties.tabSizeState = KoSvgTextPropertiesModel.PropertySet;
- GridLayout {
- columns: 3
+ RowLayout {
anchors.left: parent.left
anchors.right: parent.right
- columnSpacing: columnSpacing;
+ spacing: columnSpacing;
RevertPropertyButton {
revertState: properties.tabSizeState;
onClicked: properties.tabSizeState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: propertyTitle
- Layout.columnSpan: 2;
- elide: Text.ElideRight;
- Layout.fillWidth: true;
- font.italic: properties.tabSizeState === KoSvgTextPropertiesModel.PropertyTriState;
- }
-
- Item {
- width: 1;
- height: 1;
- }
- DoubleSpinBox {
+ KisDoubleSliderSpinBox {
id: tabSizeSpn;
+ prefix: propertyTitle + ": ";
Layout.fillWidth: true;
- from: 0;
- to: 999 * multiplier;
- onValueChanged: converter.userValue = value;
+ dFrom: 0;
+ dTo: 99;
+ onDValueChanged: converter.userValue = dValue;
}
SqueezedComboBox {
id: tabSizeUnitCmb;
diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qml
index fe2bc84985..b88130ce4a 100644
--- a/plugins/dockers/textproperties/qml/TextIndent.qml
+++ b/plugins/dockers/textproperties/qml/TextIndent.qml
@@ -67,28 +67,20 @@ CollapsibleGroupProperty {
height: childrenRect.height;
spacing: columnSpacing;
- Label {
- id: propertyTitleLabel;
- text: propertyTitle;
- verticalAlignment: Text.AlignVCenter
- color: sysPalette.text;
- elide: Text.ElideRight;
- Layout.maximumWidth: contentWidth;
- }
-
- DoubleSpinBox {
+ KisDoubleSliderSpinBox {
+ prefix: propertyTitle + ": ";
id: textIndentSpn;
Layout.fillWidth: true;
- from: 0;
- to: 999 * multiplier;
- onValueChanged: textIndentUnitCmb.userValue = value;
+ dFrom: 0;
+ dTo: 999;
+ onDValueChanged: textIndentUnitCmb.userValue = dValue;
}
/// Note: percentage calculation in the default unitcombobox isn't great for textIndent as it assumes 100% = fontsize,
/// While spec-wise, it's the inline length that defines percentage.
UnitComboBox {
id: textIndentUnitCmb;
spinBoxControl: textIndentSpn;
- onUserValueChanged: textIndentSpn.value = userValue;
+ onUserValueChanged: textIndentSpn.dValue = userValue;
Layout.preferredWidth: minimumUnitBoxWidth;
Layout.maximumWidth: implicitWidth;
}
diff --git a/plugins/dockers/textproperties/qml/UnitComboBox.qml b/plugins/dockers/textproperties/qml/UnitComboBox.qml
index bcab2b318e..fd360c165e 100644
--- a/plugins/dockers/textproperties/qml/UnitComboBox.qml
+++ b/plugins/dockers/textproperties/qml/UnitComboBox.qml
@@ -41,7 +41,6 @@ SqueezedComboBox {
CssQmlUnitConverter {
id: converter;
- dataMultiplier: spinBoxControl.multiplier;
onUserUnitChanged: root.currentIndex = root.indexOfValue(userUnit);
}
diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qml
index 1c349389f0..708656b552 100644
--- a/plugins/dockers/textproperties/qml/WordSpacing.qml
+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml
@@ -54,21 +54,19 @@ TextPropertyBase {
onClicked: properties.wordSpacingState = KoSvgTextPropertiesModel.PropertyUnset;
}
- Label {
- text: propertyTitle;
- elide: Text.ElideRight;
+ KisDoubleSliderSpinBox {
+ id: wordSpacingSpn;
+ prefix: propertyTitle+ ": "
Layout.fillWidth: true;
- font.italic: properties.wordSpacingState === KoSvgTextPropertiesModel.PropertyTriState;
- }
- DoubleSpinBox {
- id: wordSpacingSpn
- editable: true;
- Layout.fillWidth: true;
- from: -999 * multiplier;
- to: 999 * multiplier;
+ dFrom: -99;
+ dTo: 99;
+ softDFrom: -10;
+ softDTo: 10;
+ softRangeActive: true;
+ dStepSize: 0.1;
- onValueChanged: wordSpacingUnitCmb.userValue = value;
+ onDValueChanged: wordSpacingUnitCmb.userValue = dValue;
}
UnitComboBox {
@@ -76,7 +74,7 @@ TextPropertyBase {
spinBoxControl: wordSpacingSpn;
isFontSize: false;
dpi: dpi;
- onUserValueChanged: wordSpacingSpn.value = userValue;
+ onUserValueChanged: wordSpacingSpn.dValue = userValue;
Layout.preferredWidth: minimumUnitBoxWidth;
Layout.maximumWidth: implicitWidth;
allowPercentage: false; // CSS-Text-4 has percentages for word-spacing, but so does SVG 1.1, and they both are implemented differently.