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++
Rename most QML components to be without Kis prefix, and add usage documentation.
Wolthera van Hövell tot Westerflier338046ce90dc
diff --git a/plugins/dockers/textproperties/qml/BaselineShift.qml b/plugins/dockers/textproperties/qml/BaselineShift.qmlindex 34b6267e37..a6caf88dd7 100644--- a/plugins/dockers/textproperties/qml/BaselineShift.qml+++ b/plugins/dockers/textproperties/qml/BaselineShift.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label", "Baseline-Shift");@@ -116,7 +116,7 @@ TextPropertyBase {id: baselinePalette;colorGroup: baselineShiftSpn.enabled? SystemPalette.Active: SystemPalette.Disabled;}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: baselineShiftSpnwidth: parent.width;enabled: baselineShiftMode === KoSvgText.ShiftLengthPercentage;diff --git a/plugins/dockers/textproperties/qml/FontSize.qml b/plugins/dockers/textproperties/qml/FontSize.qmlindex 55a29e981c..41b7b14484 100644--- a/plugins/dockers/textproperties/qml/FontSize.qml+++ b/plugins/dockers/textproperties/qml/FontSize.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label:spinbox", "Font Size");@@ -53,7 +53,7 @@ TextPropertyBase {onClicked: properties.fontSizeState = KoSvgTextPropertiesModel.PropertyUnset;}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: fontSizeSpn;prefix: propertyTitle+ ": "Layout.fillWidth: true;diff --git a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml b/plugins/dockers/textproperties/qml/FontSizeAdjust.qmlindex 41704fa827..a038cdd8c5 100644--- a/plugins/dockers/textproperties/qml/FontSizeAdjust.qml+++ b/plugins/dockers/textproperties/qml/FontSizeAdjust.qml@@ -7,7 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label:spinbox", "Font Size Adjust");@@ -45,7 +45,7 @@ TextPropertyBase {onClicked: properties.fontSizeAdjustState = KoSvgTextPropertiesModel.PropertyUnset;}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: fontSizeAdjustSpnprefix: propertyTitle+ ": "softDFrom: 0diff --git a/plugins/dockers/textproperties/qml/FontStyle.qml b/plugins/dockers/textproperties/qml/FontStyle.qmlindex 153ca054f6..488767da6e 100644--- a/plugins/dockers/textproperties/qml/FontStyle.qml+++ b/plugins/dockers/textproperties/qml/FontStyle.qml@@ -7,7 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisCollapsibleGroupProperty {propertyTitle: i18nc("@label", "Font Style");@@ -153,7 +153,7 @@ CollapsibleGroupProperty {onClicked: properties.fontWeightState = KoSvgTextPropertiesModel.PropertyUnset;}- KisIntSliderSpinBox {+ Kis.IntSliderSpinBox {id: fontWeightSpnprefix: i18nc("@label:spinbox", "Weight: ");from: 0;@@ -184,7 +184,7 @@ CollapsibleGroupProperty {onClicked: properties.fontWidthState = KoSvgTextPropertiesModel.PropertyUnset;}- KisIntSliderSpinBox {+ Kis.IntSliderSpinBox {id: fontStretchSpnprefix: i18nc("@label:spinbox", "Width: ")from: 0;@@ -233,7 +233,7 @@ CollapsibleGroupProperty {}Layout.fillWidth: true;Layout.preferredHeight: fontSlantSpn.implicitHeight;- KisIntSliderSpinBox {+ Kis.IntSliderSpinBox {id: fontSlantSpn;suffix:"°"from: -90;@@ -303,7 +303,7 @@ CollapsibleGroupProperty {visible: parent.count === 0;}- delegate: KisDoubleSliderSpinBox {+ delegate: Kis.DoubleSliderSpinBox {id: axisSpn;required property string display;required property double axismin;diff --git a/plugins/dockers/textproperties/qml/LetterSpacing.qml b/plugins/dockers/textproperties/qml/LetterSpacing.qmlindex 215731e6e8..3337abcdec 100644--- a/plugins/dockers/textproperties/qml/LetterSpacing.qml+++ b/plugins/dockers/textproperties/qml/LetterSpacing.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label:spinbox", "Letter Spacing");@@ -54,7 +54,7 @@ TextPropertyBase {}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: letterSpacingSpn;prefix: propertyTitle+ ": "Layout.fillWidth: true;diff --git a/plugins/dockers/textproperties/qml/LineHeight.qml b/plugins/dockers/textproperties/qml/LineHeight.qmlindex 6e7be01835..ba94e34b2a 100644--- a/plugins/dockers/textproperties/qml/LineHeight.qml+++ b/plugins/dockers/textproperties/qml/LineHeight.qml@@ -7,7 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@label", "Line Height");@@ -121,7 +121,7 @@ TextPropertyBase {}Layout.fillWidth: true;Layout.fillHeight: true;- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: lineHeightSpnwidth: parent.width;enabled: !lineHeightNormalCbx.checked;diff --git a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qmlindex 17462befc5..2d183bdf31 100644--- a/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml+++ b/plugins/dockers/textproperties/qml/OpenTypeFeatureDelegate.qml@@ -7,7 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.15import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisControl {id: root;@@ -76,7 +76,7 @@ Control {color: root.containsMouse? palette.highlightedText: palette.text;}- SvgTextLabel {+ Kis.SvgTextLabel {text: root.sample;id: svgTextLabel;implicitWidth: minimumRect.width;diff --git a/plugins/dockers/textproperties/qml/TabSize.qml b/plugins/dockers/textproperties/qml/TabSize.qmlindex 9edfbd0ef3..53b3db45f5 100644--- a/plugins/dockers/textproperties/qml/TabSize.qml+++ b/plugins/dockers/textproperties/qml/TabSize.qml@@ -7,7 +7,7 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@title:group", "Tab Size");@@ -79,7 +79,7 @@ TextPropertyBase {onClicked: properties.tabSizeState = KoSvgTextPropertiesModel.PropertyUnset;}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: tabSizeSpn;prefix: propertyTitle + ": ";Layout.fillWidth: true;diff --git a/plugins/dockers/textproperties/qml/TextAlign.qml b/plugins/dockers/textproperties/qml/TextAlign.qmlindex d91457b783..854536984d 100644--- a/plugins/dockers/textproperties/qml/TextAlign.qml+++ b/plugins/dockers/textproperties/qml/TextAlign.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisCollapsibleGroupProperty {propertyTitle: i18nc("@title:group", "Text Align");@@ -168,8 +168,8 @@ CollapsibleGroupProperty {RowLayout {spacing: 0;- KisGroupButton {- groupPosition: KisGroupButton.GroupLeft;+ Kis.GroupButton {+ groupPosition: Kis.GroupButton.GroupLeft;id: alignStartBtn;checkable: true;icon.source: properties.direction === KoSvgText.DirectionLeftToRight? "qrc:///16_light_format-justify-left.svg"@@ -181,9 +181,9 @@ CollapsibleGroupProperty {Layout.preferredWidth: height;onToggled: setAlignmentFromButtons();}- KisGroupButton {+ Kis.GroupButton {id: alignMiddleBtn;- groupPosition: KisGroupButton.GroupCenter;+ groupPosition: Kis.GroupButton.GroupCenter;checkable: true;icon.source: "qrc:///16_light_format-justify-center.svg";icon.height: 16;@@ -195,8 +195,8 @@ CollapsibleGroupProperty {setAlignmentFromButtons();}}- KisGroupButton {- groupPosition: KisGroupButton.GroupRight;+ Kis.GroupButton {+ groupPosition: Kis.GroupButton.GroupRight;id: alignEndBtn;checkable: true;icon.source: properties.direction === KoSvgText.DirectionLeftToRight? "qrc:///16_light_format-justify-right.svg"@@ -212,7 +212,7 @@ CollapsibleGroupProperty {Layout.fillWidth: true;}- KisGroupButton {+ Kis.GroupButton {id: alignJustifyBtn;checkable: true;checked: textAlignAll === KoSvgText.AlignJustify;diff --git a/plugins/dockers/textproperties/qml/TextIndent.qml b/plugins/dockers/textproperties/qml/TextIndent.qmlindex b88130ce4a..05fabb15e4 100644--- a/plugins/dockers/textproperties/qml/TextIndent.qml+++ b/plugins/dockers/textproperties/qml/TextIndent.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisCollapsibleGroupProperty {propertyTitle: i18nc("@title:group", "Text Indent");@@ -67,7 +67,7 @@ CollapsibleGroupProperty {height: childrenRect.height;spacing: columnSpacing;- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {prefix: propertyTitle + ": ";id: textIndentSpn;Layout.fillWidth: true;diff --git a/plugins/dockers/textproperties/qml/WordSpacing.qml b/plugins/dockers/textproperties/qml/WordSpacing.qmlindex 708656b552..10ed56fbcd 100644--- a/plugins/dockers/textproperties/qml/WordSpacing.qml+++ b/plugins/dockers/textproperties/qml/WordSpacing.qml@@ -7,7 +7,7 @@ import QtQuick 2.0import QtQuick.Controls 2.0import QtQuick.Layouts 1.12import org.krita.flake.text 1.0-import org.krita.components 1.0+import org.krita.components 1.0 as KisTextPropertyBase {propertyTitle: i18nc("@title:group", "Word Spacing");@@ -54,7 +54,7 @@ TextPropertyBase {onClicked: properties.wordSpacingState = KoSvgTextPropertiesModel.PropertyUnset;}- KisDoubleSliderSpinBox {+ Kis.DoubleSliderSpinBox {id: wordSpacingSpn;prefix: propertyTitle+ ": "Layout.fillWidth: true;diff --git a/qmlmodules/components/CMakeLists.txt b/qmlmodules/components/CMakeLists.txtindex 202b260fac..495374d8da 100644--- a/qmlmodules/components/CMakeLists.txt+++ b/qmlmodules/components/CMakeLists.txt@@ -37,33 +37,32 @@ else ()endif ()ecm_target_qml_sources(kritaqmlcomponents SOURCES- qml/DoubleSpinBox.qml- qml/button/KisGroupButton.qml- qml/button/KisOptionButtonStrip.qml+ qml/button/GroupButton.qml+ qml/button/OptionButtonStrip.qml- qml/overlays/KisWarningOverlay.qml- qml/overlays/KisSliderOverlay.qml+ qml/overlays/WarningOverlay.qml+ qml/overlays/SliderOverlay.qmlqml/tooltip/KisToolTip.qml- qml/textinput/KisTextInputWithSelectionRange.qml- qml/textinput/KisTextInputWithPrefixAndSuffix.qml+ qml/textinput/TextInputWithSelectionRange.qml+ qml/textinput/TextInputWithPrefixAndSuffix.qml- qml/spinbox/KisParseSpinBoxContentItem.qml- qml/spinbox/KisIntParseSpinBox.qml- qml/spinbox/KisDoubleSpinBox.qml- qml/spinbox/KisDoubleParseSpinBox.qml-- qml/sliderspinbox/KisSliderSpinBoxManipulator.qml- qml/sliderspinbox/KisSliderSpinBoxRangeSwitch.qml- qml/sliderspinbox/KisSliderSpinBoxContentItem.qml- qml/sliderspinbox/KisIntSliderSpinBox.qml- qml/sliderspinbox/KisDoubleSliderSpinBox.qml-- qml/curvewidget/KisCurveWidget.qml- qml/angleselector/KisAngleGauge.qml- qml/angleselector/KisAngleSelector.qml- qml/angleselector/KisAngleSelectorUtil.js+ qml/spinbox/ParseSpinBoxContentItem.qml+ qml/spinbox/IntParseSpinBox.qml+ qml/spinbox/DoubleSpinBox.qml+ qml/spinbox/DoubleParseSpinBox.qml++ qml/sliderspinbox/SliderSpinBoxManipulator.qml+ qml/sliderspinbox/SliderSpinBoxRangeSwitch.qml+ qml/sliderspinbox/SliderSpinBoxContentItem.qml+ qml/sliderspinbox/IntSliderSpinBox.qml+ qml/sliderspinbox/DoubleSliderSpinBox.qml++ qml/curvewidget/CurveWidget.qml+ qml/angleselector/AngleGauge.qml+ qml/angleselector/AngleSelector.qml+ qml/angleselector/AngleSelectorUtil.js)target_link_libraries(kritaqmlcomponentsdiff --git a/qmlmodules/components/qml/DoubleSpinBox.qml b/qmlmodules/components/qml/DoubleSpinBox.qmldeleted file mode 100644index 137c27fd98..0000000000--- a/qmlmodules/components/qml/DoubleSpinBox.qml+++ /dev/null@@ -1,31 +0,0 @@-/*- * 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.15---// Simple double spinbox based on Qt example implementation, should-// probably be switched to spinbox slider at some point.-SpinBox {- editable: true;- wheelEnabled: true;-- property int decimals: 2;- property int multiplier: Math.pow(10, decimals);-- validator: DoubleValidator {- bottom: Math.min(from, to)- top: Math.max(from, to)- }-- textFromValue: function(value, locale) {- return Number(value / multiplier).toLocaleString(locale, 'f', decimals)- }-- valueFromText: function(text, locale) {- return Number.fromLocaleString(locale, text) * multiplier;- }-}diff --git a/qmlmodules/components/qml/angleselector/KisAngleGauge.qml b/qmlmodules/components/qml/angleselector/AngleGauge.qmlsimilarity index 91%rename from qmlmodules/components/qml/angleselector/KisAngleGauge.qmlrename to qmlmodules/components/qml/angleselector/AngleGauge.qmlindex 93fe8f0510..cee273255e 100644--- a/qmlmodules/components/qml/angleselector/KisAngleGauge.qml+++ b/qmlmodules/components/qml/angleselector/AngleGauge.qml@@ -8,12 +8,48 @@ import QtQuick 2.15import QtQuick.Controls 2.15import QtQuick.Shapes 1.15+/*+ \qmltype AngleGauge+ A Circular Control for setting the angle.++ \qml+ AngleGauge {+ angle: 45;+ snapAngle: 5;+ defaultAngle 0;+ increaseClockwise: true;+ }+ \endqml+ */Control {id: root+ /*+ \qmlproperty angle+ Current angle value.+ */property real angle: 0.0+ /*+ \qmlproperty snapAngle+ Gets the angle to which multiples the selected angle will snap.++ The default snap angle is 15 degrees so the selected angle will snap+ to its multiples (0, 15, 30, 45, etc.)+ */property real snapAngle: 15.0++ /*+ \qmlproperty defaultAngle+ Gets the angle that is used to reset the current angle.+ This angle is used when the user double clicks on the widget.+ */property real defaultAngle: 0.0++ /*+ \qmlproperty increaseClockwise+ Whether the angle gauge increase clockwise.+ Otherwise, increases counter clockwise.+ */property bool increaseClockwise: falsefunction reset()diff --git a/qmlmodules/components/qml/angleselector/KisAngleSelector.qml b/qmlmodules/components/qml/angleselector/AngleSelector.qmlsimilarity index 65%rename from qmlmodules/components/qml/angleselector/KisAngleSelector.qmlrename to qmlmodules/components/qml/angleselector/AngleSelector.qmlindex 85949b2d7d..1ee0e45068 100644--- a/qmlmodules/components/qml/angleselector/KisAngleSelector.qml+++ b/qmlmodules/components/qml/angleselector/AngleSelector.qml@@ -5,33 +5,133 @@*/import QtQuick 2.15import QtQuick.Controls 2.15-import org.krita.components 1.0-import "KisAngleSelectorUtil.js" as KisAngleSelectorUtil+import org.krita.components 1.0 as Kis+import "AngleSelectorUtil.js" as AngleSelectorUtil+/*+ \qmltype AngleSelector+ A FocusScope that combines a AngleGauge and a DoubleSpinBox into one+ convenient widget.++ \qml+ AngleSelector {+ angle: 45;+ deimals: 2;+ from: -180;+ to: 180;+ snapAngle: 5;+ defaultAngle 0;+ increaseClockwise: true;++ prefix: i18nc("@label:spinbox", "Angle: ")+ suffix: i18nc("@item:valuesuffix", "°")++ flipOptionsMode: AngleSelector.Buttons+ flatSpinBox: false;+ }+ \endqml+ */FocusScope {id: rootenum FlipOptionsMode{- NoFlipOptions,- MenuButton,- Buttons,- ContextMenu+ NoFlipOptions, ///< There is no flip options available+ MenuButton, ///< The flip options are shown as a menu accessible via a options button+ Buttons, ///< The flip options are shown as individual buttons+ ContextMenu ///< The flip options are shown only as a context menu when+ ///< right-clicking the gauge widget.+ ///< The options are shown in the context menu also if the mode is+ ///< FlipOptionsMode_MenuButton or FlipOptionsMode_Buttons but with this+ ///< mode there will be no additional buttons}+ /*+ \qmlproperty angle+ Current angle value.+ */property alias angle: spinBox.dValue++ /*+ \qmlproperty decimals+ Amount of decimals to show.+ /sa DoubleSpinBox+ */property alias decimals: spinBox.decimals++ /*+ \qmlproperty from+ Lower end of the angle range. Is a double.+ */property alias from: spinBox.dFrom++ /*+ \qmlproperty to+ Upper end of the angle range. Is a double.+ */property alias to: spinBox.dTo++ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */property alias prefix: spinBox.prefix++ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */property alias suffix: spinBox.suffix++ /*+ \qmlproperty wrap+ Whether the spinbox is wrapping.+ */property alias wrap: spinBox.wrap++ /*+ \qmlproperty snapAngle+ Gets the angle to which multiples the selected angle will snap.++ The default snap angle is 15 degrees so the selected angle will snap+ to its multiples (0, 15, 30, 45, etc.)+ */property alias snapAngle: angleGauge.snapAngle++ /*+ \qmlproperty defaultAngle+ Gets the angle that is used to reset the current angle.+ This angle is used when the user double clicks on the widget.+ */property alias defaultAngle: angleGauge.defaultAngle++ /*+ \qmlproperty increaseClockwise+ Whether the angle gauge increase clockwise.+ Otherwise, increases counter clockwise.+ */property alias increaseClockwise: angleGauge.increaseClockwise- property int flipOptionsMode: KisAngleSelector.FlipOptionsMode.Buttons+ /*+ \qmlproperty flipOptionsMode+ How the flipOptions are presented.++ \sa FlipOptionsMode enum.+ */+ property int flipOptionsMode: AngleSelector.FlipOptionsMode.Buttons++ /*+ \qmlproperty gaugeSize++ Set the explicit size for the gauge. Will otherwise use the implicit size.+ */property int gaugeSize: 0++ /*+ \qmlproperty flatSpinBox++ Gets if the spin box is flat (no border or background).+ */property bool flatSpinBox: falsefunction reset()@@ -41,13 +141,13 @@ FocusScope {function closestCoterminalAngleInRange(angle: real) : real{- return KisAngleSelectorUtil.closestCoterminalAngleInRange(angle, root.from, root.to);+ return AngleSelectorUtil.closestCoterminalAngleInRange(angle, root.from, root.to);}function flip(horizontal: bool, vertical: bool){let ok = true;- let flippedAngle = KisAngleSelectorUtil.flipAngleInRange(root.angle, root.from, root.to, horizontal, vertical,+ let flippedAngle = AngleSelectorUtil.flipAngleInRange(root.angle, root.from, root.to, horizontal, vertical,() => { ok = false; });if (ok) {root.angle = flippedAngle;@@ -112,7 +212,7 @@ FocusScope {spacing: 5anchors.fill: parent- KisAngleGauge {+ Kis.AngleGauge {id: angleGaugeanchors.verticalCenter: parent.verticalCenter@@ -132,7 +232,7 @@ FocusScope {}}- KisDoubleParseSpinBox {+ Kis.DoubleParseSpinBox {id: spinBoxanchors.verticalCenter: parent.verticalCenter@@ -206,7 +306,7 @@ FocusScope {display: AbstractButton.IconOnlyaction: actionFlipHorizontallyAndVerticallyicon.color: palette.buttonText;- KisToolTip {+ Kis.KisToolTip {parentControl: buttonFlipHorizontallyAndVerticallytext: actionFlipHorizontallyAndVertically.text}diff --git a/qmlmodules/components/qml/angleselector/KisAngleSelectorUtil.js b/qmlmodules/components/qml/angleselector/AngleSelectorUtil.jssimilarity index 100%rename from qmlmodules/components/qml/angleselector/KisAngleSelectorUtil.jsrename to qmlmodules/components/qml/angleselector/AngleSelectorUtil.jsdiff --git a/qmlmodules/components/qml/button/GroupButton.qml b/qmlmodules/components/qml/button/GroupButton.qmlnew file mode 100644index 0000000000..066a39da4c--- /dev/null+++ b/qmlmodules/components/qml/button/GroupButton.qml@@ -0,0 +1,97 @@+/*+ * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import QtQuick.Controls 2.15+++/*+ \qmltype GroupButton++ A thin tool button which can be visually grouped with other buttons.++ The group can thus look like one solid bar: ( button1 | button2 | button3 )++ \qml+ Row {+ ButtonGroup {+ id: alignGroup;+ }+ GroupButton {+ icon.source: "qrc:///16_light_format-justify-left.svg";+ icon.width: 16;+ icon.height: 16;+ text: i18nc("@action:button", "Align Left");++ groupPosition: GroupButton.GroupLeft;+ ButtonGroup.group: alignGroup;+ }+ GroupButton {+ icon.source: "qrc:///16_light_format-justify-center.svg";+ icon.width: 16;+ icon.height: 16;+ text: i18nc("@action:button", "Align Center");++ groupPosition: GroupButton.GroupCenter;+ ButtonGroup.group: alignGroup;+ }+ GroupButton {+ icon.source: "qrc:///16_light_format-justify-right.svg";+ icon.width: 16;+ icon.height: 16;+ text: i18nc("@action:button", "Align Right");++ groupPosition: GroupButton.GroupRight;+ ButtonGroup.group: alignGroup;+ }+ }+ \endqml+ */+Button {+ id: root++ enum GroupPosition {+ NoGroup, //!< No particular position, gives the button unchanged appearance+ GroupLeft, //!< The button is at the left of the group, so it would have rounded the left part+ GroupRight, //!< The button is at the right of the group, so it would have rounded the right part+ GroupCenter //!< The button is on the center of the group, so it would have separators on both sides+ }++ SystemPalette {+ id: sysPalette;+ colorGroup: root.enabled?+ root.activeFocus? SystemPalette.Active:+ SystemPalette.Inactive: SystemPalette.Disabled;+ }++ /*+ \qmlproperty groupPosition+ One of the GroupPosition enum.++ /sa GroupPosition+ */+ property int groupPosition: KisGroupButton.GroupPosition.NoGroup+ palette.button: checked? sysPalette.highlight: sysPalette.button;+ palette.buttonText: checked? sysPalette.highlightedText: sysPalette.buttonText++ text: "Button"+ clip: true+ implicitWidth: implicitContentWidth + (root.leftPadding ?? root.padding)+ + (root.rightPadding ?? root.padding)+ leftInset: (groupPosition === KisGroupButton.GroupPosition.GroupRight ||+ groupPosition === KisGroupButton.GroupPosition.GroupCenter) * -50+ rightInset: (groupPosition === KisGroupButton.GroupPosition.GroupLeft ||+ groupPosition === KisGroupButton.GroupPosition.GroupCenter) * -50++ Rectangle {+ width: 1+ height: root.background.height+ anchors.right: parent.right+ color: root.palette.buttonText;+ opacity: 0.1;+ visible: root.groupPosition === KisGroupButton.GroupPosition.GroupLeft ||+ root.groupPosition === KisGroupButton.GroupPosition.GroupCenter+ }+}diff --git a/qmlmodules/components/qml/button/KisGroupButton.qml b/qmlmodules/components/qml/button/KisGroupButton.qmldeleted file mode 100644index e46af48605..0000000000--- a/qmlmodules/components/qml/button/KisGroupButton.qml+++ /dev/null@@ -1,48 +0,0 @@-/*- * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */-import QtQuick 2.15-import QtQuick.Controls 2.15--Button {- id: root-- enum GroupPosition {- NoGroup,- GroupLeft,- GroupRight,- GroupCenter- }-- SystemPalette {- id: sysPalette;- colorGroup: root.enabled?- root.activeFocus? SystemPalette.Active:- SystemPalette.Inactive: SystemPalette.Disabled;- }-- property int groupPosition: KisGroupButton.GroupPosition.NoGroup- palette.button: checked? sysPalette.highlight: sysPalette.button;- palette.buttonText: checked? sysPalette.highlightedText: sysPalette.buttonText-- text: "Button"- clip: true- implicitWidth: implicitContentWidth + (root.leftPadding ?? root.padding)- + (root.rightPadding ?? root.padding)- leftInset: (groupPosition === KisGroupButton.GroupPosition.GroupRight ||- groupPosition === KisGroupButton.GroupPosition.GroupCenter) * -50- rightInset: (groupPosition === KisGroupButton.GroupPosition.GroupLeft ||- groupPosition === KisGroupButton.GroupPosition.GroupCenter) * -50-- Rectangle {- width: 1- height: root.background.height- anchors.right: parent.right- color: root.palette.buttonText;- opacity: 0.1;- visible: root.groupPosition === KisGroupButton.GroupPosition.GroupLeft ||- root.groupPosition === KisGroupButton.GroupPosition.GroupCenter- }-}diff --git a/qmlmodules/components/qml/button/KisOptionButtonStrip.qml b/qmlmodules/components/qml/button/OptionButtonStrip.qmlsimilarity index 95%rename from qmlmodules/components/qml/button/KisOptionButtonStrip.qmlrename to qmlmodules/components/qml/button/OptionButtonStrip.qmlindex 4213d75f6d..d836a6a55b 100644--- a/qmlmodules/components/qml/button/KisOptionButtonStrip.qml+++ b/qmlmodules/components/qml/button/OptionButtonStrip.qml@@ -10,7 +10,7 @@ Row {id: rootproperty alias exclusive: buttonGroup.exclusive- readonly property KisGroupButton checkedButton: buttonGroup.checkedButton as KisGroupButton+ readonly property Kis.GroupButton checkedButton: buttonGroup.checkedButton as Kis.GroupButtonproperty int checkedButtonIndex: -1function updateCheckedStatusFromIndex()diff --git a/qmlmodules/components/qml/curvewidget/KisCurveWidget.qml b/qmlmodules/components/qml/curvewidget/CurveWidget.qmlsimilarity index 97%rename from qmlmodules/components/qml/curvewidget/KisCurveWidget.qmlrename to qmlmodules/components/qml/curvewidget/CurveWidget.qmlindex 9042ff25c1..eca2312dbd 100644--- a/qmlmodules/components/qml/curvewidget/KisCurveWidget.qml+++ b/qmlmodules/components/qml/curvewidget/CurveWidget.qml@@ -8,11 +8,34 @@ import QtQuick.Controls 2.15import QtQuick.Shapes 1.15import org.krita.components 1.0+/*+ \qmltype CurveWidget+ A Widget to edit a kiscubic curve.++ \qml+ CurveWidget {+ }+ \endqml+ */Control {id: root+ /*+ \qmlproperty curve+ The current curve being edited.+ */property KisCubicCurve curve: KisCubicCurve {}++ /*+ \qmlproperty selectedKnotIndex+ current knot of the curve being edited.+ */property int selectedKnotIndex: 0++ /*+ \qmlproperty readonly+ whether to allow editing.+ */property bool readOnly: falsepadding: 1diff --git a/qmlmodules/components/qml/overlays/KisSliderOverlay.qml b/qmlmodules/components/qml/overlays/SliderOverlay.qmlsimilarity index 70%rename from qmlmodules/components/qml/overlays/KisSliderOverlay.qmlrename to qmlmodules/components/qml/overlays/SliderOverlay.qmlindex d97f30a277..4ca17f2576 100644--- a/qmlmodules/components/qml/overlays/KisSliderOverlay.qml+++ b/qmlmodules/components/qml/overlays/SliderOverlay.qml@@ -5,16 +5,60 @@*/import QtQuick 2.15+/*+ \qmltype SliderOverlay+ This item is an overlay that draws the slider in slider spinboxes.++ It can show two seperate bars. Each can have a separate width, however+ only one can be active. This bar will be shown wider than the inactive bar.+ */Item {id: root+ /*+ \qmlproperty showTopBar+ Whether to show the topbar. When this is inactive, only a single+ bar will be shown.+ */property bool showTopBar: false+ /*+ \qmlproperty topBarActive+ whether the topbar is active currently. If not, bottom bar is assumed+ to be active.+ */property bool topBarActive: false+ /*+ \qmlproperty radius+ The radius on the slider bar rectangles.+ */property real radius: 0.0+ /*+ \qmlproperty color+ The color of the sliders.+ By default blue, but should be set to palette highlight.+ */property color color: "blue"+ /*+ \qmlproperty topBarWidth+ Width of the top bar. Ranges from 0.0 to 1.0. Exponent ratio, if any,+ is applied separately.+ */property real topBarWidth: 0.0+ /*+ \qmlproperty bottomBarWidth+ Width of the bottom bar. Ranges from 0.0 to 1.0. Exponent ratio, if any,+ is applied separately.+ */property real bottomBarWidth: 0.0+ /*+ \qmlproperty faded+ */property bool faded: false+ /*+ \qmlproperty exponentRatio+ The exponent ratio. This is applied onto the values of the top and+ bottom bar so they show the exponent of the slider appropriately.+ */property real exponentRatio: 1.0states: [diff --git a/qmlmodules/components/qml/overlays/KisWarningOverlay.qml b/qmlmodules/components/qml/overlays/WarningOverlay.qmlsimilarity index 83%rename from qmlmodules/components/qml/overlays/KisWarningOverlay.qmlrename to qmlmodules/components/qml/overlays/WarningOverlay.qmlindex 58c58825d0..c928c3d835 100644--- a/qmlmodules/components/qml/overlays/KisWarningOverlay.qml+++ b/qmlmodules/components/qml/overlays/WarningOverlay.qml@@ -5,12 +5,36 @@*/import QtQuick 2.15+/*+ \qmltype WarningOverlay+ This item is an overlay for the parse spinboxes, when enabled+ it shows a bright orange-red overlay with a warning sign.++ It handles animating the changes for showing this warning as well.+ */Item {id: root+ /*+ \qmlproperty warn+ Whether to start warning. When enabled the overlay will show itself.+ */property bool warn: false+ /*+ \qmlproperty warningSignAlignment+ Whether the warning sign is at the left or right of the overlay.+ By default this is Qt.AlignLeft.+ */property int warningSignAlignment: Qt.AlignLeft+ /*+ \qmlproperty showWarningSign+ Whether to show the warning sign.+ */property bool showWarningSign: true+ /*+ \qmlproperty radius+ the radius of the overlay rectangle.+ */property alias radius: background.radiusstates: [diff --git a/qmlmodules/components/qml/sliderspinbox/DoubleSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/DoubleSliderSpinBox.qmlnew file mode 100644index 0000000000..05006af481--- /dev/null+++ b/qmlmodules/components/qml/sliderspinbox/DoubleSliderSpinBox.qml@@ -0,0 +1,186 @@+/*+ * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import org.krita.components 1.0 as Kis++/*+ \qmltype DoubleSliderSpinBox+ A DoubleSpinBox with a ParseSpinBoxContentItem and a slider.+ This one only supports floating point values.++ Biggest difference between this and IntSliderSpinBox is that the value and+ range (from, to, softFrom and softTo) are prefixed with "d", and *must* be+ used instead of from/to/value. This is because those other values are+ reserved to be used by spinbox itself, and must be multiplied by the desired+ factor.++ NOTE: SliderSpinBoxes have no internal signal compressors, so it may be+ useful to implement those on the level of the data model to reduce updates,+ OR you can use \sa blockUpdateSignalOnDrag.++ \qml+ DoubleSliderSpinBox {+ id: spinbox+ dFrom: -100.0;+ dTo: 200.0;+ softDFrom: 0.0;+ softDTo: 100.0;+ value: 50.25;++ prefix: i18nc("@label:spinbox", "Percentage: ")+ suffix: i18nc("@item:valuesuffix", "%")+ }+ \endqml++ The value can be set by click and dragging with the mouse or pen or by+ typing in with the keyboard. To enter the edit mode, in which the keyboard+ can be used, one has to right-click inside the spinbox or click and hold+ the pointer inside or press the enter key. To leave the edit mode, one+ can press the enter key again, in which case the value is committed, or+ press the escape key, in which case the value is rejected.++ When dragging with the pointer, one can fine tune the value by dragging+ far away vertically from the spinbox. The farther the pointer is, the+ slower the value will change. If the pointer is inside the spinbox plus+ a certain margin, the value will not be scaled.+ By pressing the shift key the slow down will be even more pronounced and+ by pressing the control key the value will snap to the increment set by+ \sa fastSliderStep. The two keys can be used at the same time.++ A "soft range" can be set to make the slider display only a sub-range of the+ spinbox range. This way one can have a large range but display and set with+ the pointer and with more precision only the most commonly used sub-set+ of values.+ A value outside the "soft range" can be set by entering the edit+ mode and using the keyboard.+ The "soft range" is considered valid if the "soft maximum" is greater than+ the "soft minimum".+ */+Kis.DoubleSpinBox {+ id: root++ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */+ property alias prefix: contentId.prefix++ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */+ property alias suffix: contentId.suffix++ /*+ \qmlproperty softDFrom+ Lower end of the soft range. Should be below softDTo and Dto,+ and below or equals to "DFrom".+ */+ property real softDFrom: dFrom+ /*+ \qmlproperty softDTo+ Upper end of the soft range. Should be above softDFrom and dFrom,+ and below or equals to dTo.+ */+ property real softDTo: dFrom++ /*+ \qmlproperty softRangeActive+ Whether the soft range is active.+ */+ property bool softRangeActive: false++ /*+ \qmlproperty blockUpdateSignalOnDrag+ Whether to block the value from being updates when dragging.+ When enabled, will only update the value on mouse release.+ */+ property alias blockUpdateSignalOnDrag: contentId.blockUpdateSignalOnDrag++ /*+ \qmlproperty exponentRatio+ Set the exponent used by a power function to modify the values+ as a function of the horizontal position.++ This allows having more values concentrated in one side of the+ slider than the other.+ */+ property alias exponentRatio: contentId.exponentRatio++ /*+ \qmlproperty fastSliderStep+ This sets the stepSize used when the user presses CTRL when modifying+ the slider.+ */+ property alias fastSliderStep: contentId.fastSliderStep++ /*+ \qmlproperty dragging++ Whether the slider is currently being dragged by the mouse.+ */+ readonly property alias dragging : contentId.dragging++ property bool isComplete: false;++ function fixSoftRange() {+ if (!isComplete) return;+ root.softDFrom = Math.min(Math.max(root.softDFrom, root.dFrom), root.dTo);+ root.softDTo = Math.min(Math.max(root.softDTo, root.softDFrom), root.dTo);+ contentId.showSoftRange = (root.softDFrom != root.softDTo)+ && (root.softDFrom !== root.dFrom || root.softDTo !== root.dTo);+ }++ editable: false+ padding: 0+ focusPolicy: Qt.WheelFocus+ implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding++ contentItem: FocusScope {+ focus: true++ Kis.SliderSpinBoxContentItem {+ id: contentId++ anchors.fill: parent+ anchors.margins: 1+ anchors.rightMargin: 2+ focus: true++ decimals: root.decimals+ from: root.dFrom+ to: root.dTo+ softFrom: root.softDFrom+ softTo: root.softDTo+ showSoftRange: false+ softRangeActive: root.softRangeActive+ focusPolicy: root.focusPolicy+ parentSpinBox: root++ onValueChanged: {+ if (!(blockUpdateSignalOnDrag && dragging) && root.dValue !== value) {+ root.dValue = value;+ }+ }+ onDraggingChanged: {+ if (blockUpdateSignalOnDrag && !dragging) {+ root.dValue = value;+ }+ }+ }+ }++ onDValueChanged: contentId.value = root.dValue;+ onDFromChanged: fixSoftRange()+ onDToChanged: fixSoftRange()+ onSoftDFromChanged: fixSoftRange()+ onSoftDToChanged: fixSoftRange()++ Component.onCompleted: {+ isComplete = true;+ fixSoftRange()+ }+}diff --git a/qmlmodules/components/qml/sliderspinbox/IntSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/IntSliderSpinBox.qmlnew file mode 100644index 0000000000..89c8dbbf9c--- /dev/null+++ b/qmlmodules/components/qml/sliderspinbox/IntSliderSpinBox.qml@@ -0,0 +1,185 @@+/*+ * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import QtQuick.Controls 2.15++/*+ \qmltype IntSliderSpinBox+ A SpinBox with a ParseSpinBoxContentItem and a slider.+ This one only supports integers.++ NOTE: SliderSpinBoxes have no internal signal compressors, so it may be+ useful to implement those on the level of the data model to reduce updates,+ OR you can use \sa blockUpdateSignalOnDrag.++ \qml+ IntSliderSpinBox {+ id: spinbox+ from: 0;+ to: 100;+ value: 50;++ prefix: i18nc("@label:spinbox", "Percentage: ")+ suffix: i18nc("@item:valuesuffix", "%")+ }+ \endqml++ The value can be set by click and dragging with the mouse or pen or by+ typing in with the keyboard. To enter the edit mode, in which the keyboard+ can be used, one has to right-click inside the spinbox or click and hold+ the pointer inside or press the enter key. To leave the edit mode, one+ can press the enter key again, in which case the value is committed, or+ press the escape key, in which case the value is rejected.++ When dragging with the pointer, one can fine tune the value by dragging+ far away vertically from the spinbox. The farther the pointer is, the+ slower the value will change. If the pointer is inside the spinbox plus+ a certain margin, the value will not be scaled.+ By pressing the shift key the slow down will be even more pronounced and+ by pressing the control key the value will snap to the increment set by+ \sa fastSliderStep. The two keys can be used at the same time.++ A "soft range" can be set to make the slider display only a sub-range of the+ spinbox range. This way one can have a large range but display and set with+ the pointer and with more precision only the most commonly used sub-set+ of values.+ A value outside the "soft range" can be set by entering the edit+ mode and using the keyboard.+ The "soft range" is considered valid if the "soft maximum" is greater than+ the "soft minimum".+ */+SpinBox {+ id: root++ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */+ property alias prefix: contentId.prefix++ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */+ property alias suffix: contentId.suffix++ /*+ \qmlproperty softFrom+ Lower end of the soft range. Should be below softTo and to,+ and below or equals to "from".+ */+ property int softFrom: from++ /*+ \qmlproperty softTo+ Upper end of the soft range. Should be above softFrom and from,+ and below or equals to "to".+ */+ property int softTo: from++ /*+ \qmlproperty softRangeActive+ Whether the soft range is active.+ */+ property bool softRangeActive: false++ /*+ \qmlproperty blockUpdateSignalOnDrag+ Whether to block the value from being updates when dragging.+ When enabled, will only update the value on mouse release.+ */+ property alias blockUpdateSignalOnDrag: contentId.blockUpdateSignalOnDrag++ /*+ \qmlproperty exponentRatio+ Set the exponent used by a power function to modify the values+ as a function of the horizontal position.++ This allows having more values concentrated in one side of the+ slider than the other.+ */+ property alias exponentRatio: contentId.exponentRatio++ /*+ \qmlproperty fastSliderStep+ This sets the stepSize used when the user presses CTRL when modifying+ the slider.+ */+ property int fastSliderStep: 5++ /*+ \qmlproperty dragging+ Whether the slider is currently being dragged by the mouse.+ */+ readonly property alias dragging : contentId.dragging++ property bool isComplete: false;++ function fixSoftRange() {+ if (!isComplete) return;+ root.softFrom = Math.min(Math.max(root.softFrom, root.from), root.To);+ root.softTo = Math.min(Math.max(root.softTo, root.softFrom), root.To);+ contentId.showSoftRange = (root.softFrom !== root.softTo)+ && (root.softFrom !== root.from || root.softTo !== root.to);+ }++ editable: false+ padding: 0+ focusPolicy: Qt.WheelFocus+ implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding++ contentItem: FocusScope {+ focus: true++ KisSliderSpinBoxContentItem {+ id: contentId++ anchors.fill: parent+ anchors.margins: 1+ anchors.rightMargin: 2+ focus: true++ from: root.from+ to: root.to+ softFrom: root.softFrom+ softTo: root.softTo+ showSoftRange: false+ softRangeActive: root.softRangeActive+ parentSpinBox: root+ focusPolicy: root.focusPolicy+ fastSliderStep: root.fastSliderStep++ onValueChanged: {+ if (!(blockUpdateSignalOnDrag && dragging) && root.value !== value) {+ root.value = value;+ }+ }+ onDraggingChanged: {+ if (blockUpdateSignalOnDrag && !dragging) {+ root.value = value;+ }+ }+ }+ }++ onValueChanged: contentId.value = root.value+ onFromChanged: fixSoftRange()+ onToChanged: fixSoftRange()+ onSoftFromChanged: fixSoftRange()+ onSoftToChanged: fixSoftRange()++ Component.onCompleted: {+ // The following is to avoid an oddity inside Fusion+ // Where padding is added to ensure a centered text.+ if (root.mirrored) {+ root.rightPadding = 0;+ } else {+ root.leftPadding = 0;+ }+ isComplete = true;+ fixSoftRange()+ }+}diff --git a/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qmldeleted file mode 100644index 0544c0c985..0000000000--- a/qmlmodules/components/qml/sliderspinbox/KisDoubleSliderSpinBox.qml+++ /dev/null@@ -1,81 +0,0 @@-/*- * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */-import QtQuick 2.15-import org.krita.components 1.0--KisDoubleSpinBox {- id: root-- property alias prefix: contentId.prefix- property alias suffix: contentId.suffix- property real softDFrom: dFrom- property real softDTo: dFrom- property bool softRangeActive: false- property alias blockUpdateSignalOnDrag: contentId.blockUpdateSignalOnDrag- property alias exponentRatio: contentId.exponentRatio- property alias fastSliderStep: contentId.fastSliderStep- readonly property alias dragging : contentId.dragging-- property bool isComplete: false;-- function fixSoftRange() {- if (!isComplete) return;- root.softDFrom = Math.min(Math.max(root.softDFrom, root.dFrom), root.dTo);- root.softDTo = Math.min(Math.max(root.softDTo, root.softDFrom), root.dTo);- contentId.showSoftRange = (root.softDFrom != root.softDTo)- && (root.softDFrom !== root.dFrom || root.softDTo !== root.dTo);- }-- editable: false- padding: 0- focusPolicy: Qt.WheelFocus- implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding-- contentItem: FocusScope {- focus: true-- KisSliderSpinBoxContentItem {- id: contentId-- anchors.fill: parent- anchors.margins: 1- anchors.rightMargin: 2- focus: true-- decimals: root.decimals- from: root.dFrom- to: root.dTo- softFrom: root.softDFrom- softTo: root.softDTo- showSoftRange: false- softRangeActive: root.softRangeActive- focusPolicy: root.focusPolicy- parentSpinBox: root-- onValueChanged: {- if (!(blockUpdateSignalOnDrag && dragging) && root.dValue !== value) {- root.dValue = value;- }- }- onDraggingChanged: {- if (blockUpdateSignalOnDrag && !dragging) {- root.dValue = value;- }- }- }- }-- onDValueChanged: contentId.value = root.dValue;- onDFromChanged: fixSoftRange()- onDToChanged: fixSoftRange()- onSoftDFromChanged: fixSoftRange()- onSoftDToChanged: fixSoftRange()-- Component.onCompleted: {- isComplete = true;- fixSoftRange()- }-}diff --git a/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml b/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qmldeleted file mode 100644index f34a7255d5..0000000000--- a/qmlmodules/components/qml/sliderspinbox/KisIntSliderSpinBox.qml+++ /dev/null@@ -1,88 +0,0 @@-/*- * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */-import QtQuick 2.15-import QtQuick.Controls 2.15--SpinBox {- id: root-- property alias prefix: contentId.prefix- property alias suffix: contentId.suffix- property int softFrom: from- property int softTo: from- property bool softRangeActive: false- property alias blockUpdateSignalOnDrag: contentId.blockUpdateSignalOnDrag- property alias exponentRatio: contentId.exponentRatio- property int fastSliderStep: 5- readonly property alias dragging : contentId.dragging-- property bool isComplete: false;-- function fixSoftRange() {- if (!isComplete) return;- root.softFrom = Math.min(Math.max(root.softFrom, root.from), root.To);- root.softTo = Math.min(Math.max(root.softTo, root.softFrom), root.To);- contentId.showSoftRange = (root.softFrom !== root.softTo)- && (root.softFrom !== root.from || root.softTo !== root.to);- }-- editable: false- padding: 0- focusPolicy: Qt.WheelFocus- implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding-- contentItem: FocusScope {- focus: true-- KisSliderSpinBoxContentItem {- id: contentId-- anchors.fill: parent- anchors.margins: 1- anchors.rightMargin: 2- focus: true-- from: root.from- to: root.to- softFrom: root.softFrom- softTo: root.softTo- showSoftRange: false- softRangeActive: root.softRangeActive- parentSpinBox: root- focusPolicy: root.focusPolicy- fastSliderStep: root.fastSliderStep-- onValueChanged: {- if (!(blockUpdateSignalOnDrag && dragging) && root.value !== value) {- root.value = value;- }- }- onDraggingChanged: {- if (blockUpdateSignalOnDrag && !dragging) {- root.value = value;- }- }- }- }-- onValueChanged: contentId.value = root.value- onFromChanged: fixSoftRange()- onToChanged: fixSoftRange()- onSoftFromChanged: fixSoftRange()- onSoftToChanged: fixSoftRange()-- Component.onCompleted: {- // The following is to avoid an oddity inside Fusion- // Where padding is added to ensure a centered text.- if (root.mirrored) {- root.rightPadding = 0;- } else {- root.leftPadding = 0;- }- isComplete = true;- fixSoftRange()- }-}diff --git a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qmlsimilarity index 71%rename from qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qmlrename to qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qmlindex 79b0f6c122..8fbe8a1de5 100644--- a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxContentItem.qml+++ b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxContentItem.qml@@ -5,28 +5,134 @@*/import QtQuick 2.15import QtQuick.Controls 2.15-import org.krita.components 1.0+import org.krita.components 1.0 as Kis+/*+ \qmltype SliderSpinBoxContentItem+ This is a FocusScope that enables a slider on a spinbox.++ \qml+ SpinBox {+ id: spinbox+ contentItem: SliderSpinBoxContentItem {+ id: parseItem+ parentSpinBox: spinbox+ anchors.fill: parent+ from: spinbox.from+ to: spinbox.to+ softFrom: from + 1+ softTo: to -1+ onValueChanged: spinbox.value = Math.round(value)++ prefix: i18nc("@label:spinbox", "Percentage: ")+ suffix: i18nc("@item:valuesuffix", "%")+ }++ onValueChanged: parseItem.value = value;+ }+ \endqml+ */FocusScope {id: root+ /*+ \qmlproperty value+ The current value.+ */property alias value: parseSpinBoxContentItem.value+ /*+ \qmlproperty decimals+ Amount of decimals shown.+ */property alias decimals: parseSpinBoxContentItem.decimals+ /*+ \qmlproperty from+ Lower end of the hard range.+ */property alias from: parseSpinBoxContentItem.from+ /*+ \qmlproperty to+ Upper end of the hard range.+ */property alias to: parseSpinBoxContentItem.to+ /*+ \qmlproperty softFrom+ Lower end of the soft range. Should be below softTo and to,+ and below or equals to "from".+ */property real softFrom: 0+ /*+ \qmlproperty softTo+ Upper end of the soft range. Should be above softFrom and from,+ and below or equals to "to".+ */property real softTo: 0+ /*+ \qmlproperty showSoftRange+ Whether the softrange is shown. This is set whether the softrange+ and the hard range overlap.+ */property alias showSoftRange: sliderOverlay.showTopBar+ /*+ \qmlproperty softRangeActive+ Whether the soft range is active.+ */property alias softRangeActive: sliderOverlay.topBarActive+ /*+ \qmlproperty valueBeforeEditing+ */property real valueBeforeEditing: 0.0+ /*+ \qmlproperty parentSpinBox+ The SpinBox object that this is a content item of.+ */required property SpinBox parentSpinBox+ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */property alias prefix: parseSpinBoxContentItem.prefix+ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */property alias suffix: parseSpinBoxContentItem.suffix+ /*+ \qmlproperty focusPolicy+ */property alias focusPolicy: sliderManipulator.focusPolicy+ /*+ \qmlproperty editing+ returns true when the parentSpinBox is currently being edited.+ */readonly property bool editing: parentSpinBox ? parentSpinBox.editable : false+ /*+ \qmlproperty blockUpdateSignalOnDrag+ Whether to block the value from being updates when dragging.+ */property alias blockUpdateSignalOnDrag: sliderManipulator.blockUpdateSignalOnDrag++ /*+ \qmlproperty exponentRatio+ Set the exponent used by a power function to modify the values+ as a function of the horizontal position.++ This allows having more values concentrated in one side of the+ slider than the other.+ */property alias exponentRatio: sliderManipulator.exponentRatio++ /*+ \qmlproperty fastSliderStep+ This sets the stepSize used when the user presses CTRL when modifying+ the slider.+ */property alias fastSliderStep: sliderManipulator.fastSliderStep++ /*+ \qmlproperty dragging+ Whether the slider is currently being dragged by the mouse.+ */readonly property alias dragging : sliderManipulator.draggingimplicitHeight: parseSpinBoxContentItem.implicitHeight@@ -34,7 +140,7 @@ FocusScope {onSoftRangeActiveChanged: rangeSwitch.softRangeActive = root.softRangeActive- KisSliderSpinBoxRangeSwitch {+ SliderSpinBoxRangeSwitch {id: rangeSwitchanchors.top: parent.top@@ -53,7 +159,7 @@ FocusScope {onSoftRangeActiveChanged: root.softRangeActive = softRangeActive}- KisSliderOverlay {+ Kis.SliderOverlay {id: sliderOverlayproperty real value: parseSpinBoxContentItem.value@@ -71,7 +177,7 @@ FocusScope {exponentRatio: root.exponentRatio}- KisParseSpinBoxContentItem {+ Kis.ParseSpinBoxContentItem {id: parseSpinBoxContentItemanchors.top: parent.top@@ -117,7 +223,7 @@ FocusScope {}}- KisSliderSpinBoxManipulator {+ SliderSpinBoxManipulator {id: sliderManipulatoranchors.fill: parseSpinBoxContentItemfocus: truediff --git a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxManipulator.qml b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxManipulator.qmlsimilarity index 83%rename from qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxManipulator.qmlrename to qmlmodules/components/qml/sliderspinbox/SliderSpinBoxManipulator.qmlindex acd848fdb1..ce15fbc6b0 100644--- a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxManipulator.qml+++ b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxManipulator.qml@@ -5,22 +5,72 @@*/import QtQuick 2.15+/*+ \qmltype SliderSpinBoxManipulator+ This is a FocusScope that handles dragging the sliders on slider spinboxes.+ */FocusScope {id: root+ /*+ \qmlproperty min+ lower end of the total range.+ */property real min: 0.0+ /*+ \qmlproperty max+ upper end of the total range.+ */property real max: 0.0+ /*+ \qmlproperty value+ current value within range.+ */property real value: 0.0+ /*+ \qmlproperty stepSize+ the stepsize for increase and decrease actions.+ */property real stepSize: 1.0+ /*+ \qmlproperty blockUpdateSignalOnDrag+ Whether to block the value from being updates when dragging.+ */property bool blockUpdateSignalOnDrag: false+ /*+ \qmlproperty exponentRatio+ \sa SliderSpinBoxContentItem.exponentRatio+ */property real exponentRatio: 1.0+ /*+ \qmlproperty fastSliderStep+ This sets the stepSize used when the user presses CTRL when modifying+ the slider.+ */property real fastSliderStep: 5.0+ /*+ \qmlproperty dragging+ returns true whether the slider is currently being dragged.+ */readonly property alias dragging : mouseArea.isDragging+property int focusPolicy: Qt.WheelFocus+ /**+ Emitted when editing is started.+ */signal editingStarted()+ /**+ Emitted when editing is started with value+ */signal editingStartedWithValue(v: real)+ /**+ Emitted when increased and whether that is from a wheel event.+ */signal increase(wheel: bool)+ /**+ Emitted when deincreased and whether that is from a wheel event.+ */signal decrease(wheel: bool)MouseArea {diff --git a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxRangeSwitch.qml b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxRangeSwitch.qmlsimilarity index 82%rename from qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxRangeSwitch.qmlrename to qmlmodules/components/qml/sliderspinbox/SliderSpinBoxRangeSwitch.qmlindex c0cc0e1f20..e00465a4ef 100644--- a/qmlmodules/components/qml/sliderspinbox/KisSliderSpinBoxRangeSwitch.qml+++ b/qmlmodules/components/qml/sliderspinbox/SliderSpinBoxRangeSwitch.qml@@ -6,11 +6,32 @@import QtQuick 2.15import org.krita.components 1.0+/*+ \qmltype SliderSpinBoxRangeSwitch+ This item is a button to that can be used to switch between the hard and+ soft range that the slider spinboxes are capable of having these.++ It uses states to witch between hovered/enabled/not enabled to allow+ graceful transition between these states.+ */Item {id: root+ /*+ \qmlproperty softRangeActive+ Boolean indicating whether the softrange is active now.+ */property bool softRangeActive: false+ /*+ \qmlproperty color+ The color of the button+ By default black, but should be set to palette text.+ */property color color: "black"+ /*+ \qmlproperty toolTip.+ The text of the tool tip.+ */property alias toolTip: toolTipPopup.textopacity: 0.4diff --git a/qmlmodules/components/qml/spinbox/DoubleParseSpinBox.qml b/qmlmodules/components/qml/spinbox/DoubleParseSpinBox.qmlnew file mode 100644index 0000000000..c2de104444--- /dev/null+++ b/qmlmodules/components/qml/spinbox/DoubleParseSpinBox.qml@@ -0,0 +1,66 @@+/*+ * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15++/*+ \qmltype DoubleParseSpinBox+ \inherits DoubleSpinBox+ A DoubleSpinBox with a ParseSpinboxContentItem. This will allow users to input+ simple maths expressions. This version is meant for double input only.++ \qml+ DoubleParseSpinBox {+ dFrom: 0+ dTo: 100.0+ dValue: 50.0+ decimals: 2++ prefix: i18nc("@label:spinbox", "Percentage: ")+ suffix: i18nc("@item:valuesuffix", "%")+ }+ \endqml+++ */+DoubleSpinBox {+ id: root++ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */+ property alias prefix: contentId.prefix+ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */+ property alias suffix: contentId.suffix++ editable: true+ padding: 0+ focusPolicy: Qt.WheelFocus++ implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding++ contentItem: ParseSpinBoxContentItem {+ id: contentId++ anchors.fill: parent+ anchors.margins: 1+ anchors.rightMargin: 2+ focus: true++ value: root.dValue+ decimals: root.decimals+ from: root.dFrom+ to: root.dTo+ parentSpinBox: root++ onValueChanged: root.dValue = value+ }++ onDValueChanged: contentId.value = root.dValue+}diff --git a/qmlmodules/components/qml/spinbox/KisDoubleSpinBox.qml b/qmlmodules/components/qml/spinbox/DoubleSpinBox.qmlsimilarity index 53%rename from qmlmodules/components/qml/spinbox/KisDoubleSpinBox.qmlrename to qmlmodules/components/qml/spinbox/DoubleSpinBox.qmlindex 2a315b588e..b82baee832 100644--- a/qmlmodules/components/qml/spinbox/KisDoubleSpinBox.qml+++ b/qmlmodules/components/qml/spinbox/DoubleSpinBox.qml@@ -6,16 +6,64 @@import QtQuick 2.15import QtQuick.Controls 2.15+/*+ \qmltype DoubleSpinBox+ \inherits SpinBox+ \brief A SpinBox that allows for floating point input.++ Biggest difference between this and SpinBox is that the value and range+ (from and to) are prefixed with "d", and *must* be used instead of from/to/value.+ This is because those other values are reserved to be used by spinbox itself,+ and must be multiplied by the desired factor.++ \qml+ DoubleParseSpinBox {+ dFrom: 0+ dTo: 100.0+ dValue: 50.0+ dStepSize: 5.0;+ decimals: 2;+ }+ \endqml++ */SpinBox {id: root+ /*+ \qmlproperty decimals+ The amount of decimals after the floating point to show. In practice+ this will affect the factor used to convert for the value inside the SpinBox.+ By default this is 2.+ */property int decimals: 2+ /*+ \qmlproperty dValue+ The floating point value. This must used instead of "value".+ */property real dValue: 0.0+ /*+ \qmlproperty dFrom+ The floating point lower end of the spinbox range. This must used instead of "from".+ */property real dFrom: 0.0+ /*+ \qmlproperty dTo+ The floating point upper end of the spinbox range. This must used instead of "to".+ */property real dTo: 100.0+ /*+ \qmlproperty dStepSize+ The floating point increment size of the spinbox range. This must used instead of "stepsize".+ */property real dStepSize: 1.0- property real factor: Math.pow(10, decimals)+ /*+ \qmlproperty factor+ The multiplier to multiply the d-values to spinbox internal values.+ It uses the decimals property as a power to 10 to achieve that.+ */+ readonly property real factor: Math.pow(10, decimals)stepSize: Math.round(dStepSize * factor)from: Math.round(dFrom * factor)diff --git a/qmlmodules/components/qml/spinbox/IntParseSpinBox.qml b/qmlmodules/components/qml/spinbox/IntParseSpinBox.qmlnew file mode 100644index 0000000000..20190e7b59--- /dev/null+++ b/qmlmodules/components/qml/spinbox/IntParseSpinBox.qml@@ -0,0 +1,73 @@+/*+ * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>+ *+ * SPDX-License-Identifier: GPL-2.0-or-later+ */+import QtQuick 2.15+import QtQuick.Controls 2.15++/*+ \qmltype IntParseSpinBox+ A SpinBox with a ParseSpinboxContentItem. This will allow users to input+ simple maths expressions. This version is meant for integer input only.++ \qml+ IntParseSpinBox {+ from: 0+ to: 100+ value: 50++ prefix: i18nc("@label:spinbox", "Percentage: ")+ suffix: i18nc("@item:valuesuffix", "%")+ }+ \endqml+ */+SpinBox {+ id: root++ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */+ property alias prefix: contentId.prefix+ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */+ property alias suffix: contentId.suffix++ editable: true+ padding: 0+ focusPolicy: Qt.WheelFocus+ implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding++ contentItem: ParseSpinBoxContentItem {+ id: contentId++ anchors.fill: parent+ anchors.margins: 1+ anchors.rightMargin: 2+ focus: true++ value: root.value+ from: root.from+ to: root.to+ parentSpinBox: root++ onValueChanged: root.value = Math.round(value)+ }+++ onValueChanged: contentId.value = root.value;++ Component.onCompleted: {++ // The following is to avoid an oddity inside Fusion+ // Where padding is added to ensure a centered text.+ if (root.mirrored) {+ root.rightPadding = 0;+ } else {+ root.leftPadding = 0;+ }+ }+}diff --git a/qmlmodules/components/qml/spinbox/KisDoubleParseSpinBox.qml b/qmlmodules/components/qml/spinbox/KisDoubleParseSpinBox.qmldeleted file mode 100644index 4e7c2ee5c3..0000000000--- a/qmlmodules/components/qml/spinbox/KisDoubleParseSpinBox.qml+++ /dev/null@@ -1,40 +0,0 @@-/*- * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */-import QtQuick 2.15--KisDoubleSpinBox {- id: root-- property alias prefix: contentId.prefix- property alias suffix: contentId.suffix-- editable: true- padding: 0- focusPolicy: Qt.WheelFocus-- implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding-- contentItem: FocusScope {- KisParseSpinBoxContentItem {- id: contentId-- anchors.fill: parent- anchors.margins: 1- anchors.rightMargin: 2- focus: true-- value: root.dValue- decimals: root.decimals- from: root.dFrom- to: root.dTo- parentSpinBox: root-- onValueChanged: root.dValue = value- }- }-- onDValueChanged: contentId.value = root.dValue-}diff --git a/qmlmodules/components/qml/spinbox/KisIntParseSpinBox.qml b/qmlmodules/components/qml/spinbox/KisIntParseSpinBox.qmldeleted file mode 100644index 0ca92a8c39..0000000000--- a/qmlmodules/components/qml/spinbox/KisIntParseSpinBox.qml+++ /dev/null@@ -1,50 +0,0 @@-/*- * SPDX-FileCopyrightText: 2024 Deif Lou <[email protected]>- *- * SPDX-License-Identifier: GPL-2.0-or-later- */-import QtQuick 2.15-import QtQuick.Controls 2.15--SpinBox {- id: root-- property alias prefix: contentId.prefix- property alias suffix: contentId.suffix-- editable: true- padding: 0- focusPolicy: Qt.WheelFocus- implicitWidth: contentId.implicitWidth + 1 + 2 + leftPadding + rightPadding-- contentItem: FocusScope {- KisParseSpinBoxContentItem {- id: contentId-- anchors.fill: parent- anchors.margins: 1- anchors.rightMargin: 2- focus: true-- value: root.value- from: root.from- to: root.to- parentSpinBox: root-- onValueChanged: root.value = Math.round(value)- }- }-- onValueChanged: contentId.value = root.value;-- Component.onCompleted: {-- // The following is to avoid an oddity inside Fusion- // Where padding is added to ensure a centered text.- if (root.mirrored) {- root.rightPadding = 0;- } else {- root.leftPadding = 0;- }- }-}diff --git a/qmlmodules/components/qml/spinbox/KisParseSpinBoxContentItem.qml b/qmlmodules/components/qml/spinbox/ParseSpinBoxContentItem.qmlsimilarity index 68%rename from qmlmodules/components/qml/spinbox/KisParseSpinBoxContentItem.qmlrename to qmlmodules/components/qml/spinbox/ParseSpinBoxContentItem.qmlindex e4ba9b1b19..1c7a4d62bd 100644--- a/qmlmodules/components/qml/spinbox/KisParseSpinBoxContentItem.qml+++ b/qmlmodules/components/qml/spinbox/ParseSpinBoxContentItem.qml@@ -6,23 +6,95 @@import QtQml 2.15import QtQuick 2.15import QtQuick.Controls 2.15-import org.krita.components 1.0+import org.krita.components 1.0 as Kis+/*+ \qmltype ParseSpinBoxContentItem+ A FocusScope that allows for parsing math expressions via KisNumParser,+ in addtion to allowing for suffix and prefix.++ When the math expression is incorrect, a WarningOverlay will be drawn.++ ParseSpinBoxContentItem is meant to be used as the contentItem of a Spinbox.++ \qml+ SpinBox {+ id: spinbox+ contentItem: ParseSpinBoxContentItem {+ id: parseItem+ parentSpinBox: spinbox+ anchors.fill: parent+ from: spinbox.from+ to: spinbox.to+ onValueChanged: spinbox.value = Math.round(value)+ }++ onValueChanged: parseItem.value = value;+ }+ \endqml+ */FocusScope {id: root+ /*+ \qmlproperty value+ current value as qreal.+ */property real value: 0.0+ /*+ \qmlproperty decimals+ Number of visible decimals.+ */property int decimals: 0+ /*+ \qmlproperty from+ Real representing the lower end of the value range.+ */property real from: 0+ /*+ \qmlproperty to+ Real representing the upper end of the value range.+ */property real to: 0+ /*+ \qmlproperty prefix+ A string that will be prefixed to the current value.+ */property alias prefix: textInput.prefix+ /*+ \qmlproperty suffix+ A string that will be suffixed to the current value.+ */property alias suffix: textInput.suffix+ /*+ \qmlproperty warningOverlay+ The WarningOverlay object.+ */property alias warningOverlay: warningOverlay+ /*+ \qmlproperty textInput+ The TextInputWithPrefixAndSuffix object.+ */property alias textInput: textInput+ /*+ \qmlproperty parentSpinBox+ The SpinBox object that this is a content item of.+ */required property SpinBox parentSpinBox+ /*+ This signal is emitted when editing has finished on the text input.+ */signal editingFinished()++ /*+ This signal is emitted when editing has been canceled on the text input.+ */signal editingCanceled()++ /*+ This signal is emitted when the text input value has been parsed successfully.+ */signal valueParsed(real parsedValue)implicitHeight: textInput.implicitHeight@@ -32,7 +104,7 @@ FocusScope {onDecimalsChanged: textInput.contentsText = Number(root.value).toLocaleString(Qt.locale(), 'f', decimals);- KisWarningOverlay {+ Kis.WarningOverlay {id: warningOverlayanchors.fill: parentclip: true@@ -42,12 +114,9 @@ FocusScope {warningSignAlignment: Qt.AlignRight}- KisTextInputWithPrefixAndSuffix {+ Kis.TextInputWithPrefixAndSuffix {id: textInput-- // This is a double, but QML 5.15 doesn't like it- // when assigning a NaN to a double.- property var parsedValue: 0.0+ property double parsedValue: 0.0anchors.fill: parentverticalAlignment: Text.AlignVCenter@@ -72,7 +141,7 @@ FocusScope {}}- KisNumParser { id: numParser;}+ Kis.KisNumParser { id: numParser;}onContentsTextChanged: {parsedValue = numParser.parseSimpleMathExpr(contentsText);diff --git a/qmlmodules/components/qml/textinput/KisTextInputWithPrefixAndSuffix.qml b/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qmlsimilarity index 58%rename from qmlmodules/components/qml/textinput/KisTextInputWithPrefixAndSuffix.qmlrename to qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qmlindex af7210c83a..f90c0c90e3 100644--- a/qmlmodules/components/qml/textinput/KisTextInputWithPrefixAndSuffix.qml+++ b/qmlmodules/components/qml/textinput/TextInputWithPrefixAndSuffix.qml@@ -3,9 +3,26 @@** SPDX-License-Identifier: GPL-2.0-or-later*/-KisTextInputWithSelectionRange {+/*+ \qmltype TextInputWithPrefixAndSuffix+ This is a Text Input which holds a prefix and a suffix.++ */+TextInputWithSelectionRange {+ /*+ \qmlproperty prefix+ A string that will be prefixed to the current input.+ */property string prefix: ""+ /*+ \qmlproperty suffix+ A string that will be suffixed to the current input.+ */property string suffix: ""+ /*+ \qmlproperty contentsText+ The current input text.+ */property string contentsText: ""selectionRangeStart: prefix.lengthdiff --git a/qmlmodules/components/qml/textinput/KisTextInputWithSelectionRange.qml b/qmlmodules/components/qml/textinput/TextInputWithSelectionRange.qmlsimilarity index 73%rename from qmlmodules/components/qml/textinput/KisTextInputWithSelectionRange.qmlrename to qmlmodules/components/qml/textinput/TextInputWithSelectionRange.qmlindex 49b2102465..520af67bf1 100644--- a/qmlmodules/components/qml/textinput/KisTextInputWithSelectionRange.qml+++ b/qmlmodules/components/qml/textinput/TextInputWithSelectionRange.qml@@ -5,12 +5,36 @@*/import QtQuick 2.15+/*+ \qmltype TextInputWithSelectionRange+ This is a Text Input which keeps track of which part of the text can be+ considered selected.++ This is useful when dealing with a prefix or suffix.++ */TextInput {id: root+ /*+ \qmlproperty selectionRangeStart+ Start of the range.+ */property int selectionRangeStart: 0+ /*+ \qmlproperty selectionRangeEnd+ End of the range.+ */property int selectionRangeEnd: 0+ /*+ \qmlproperty selectionRangeLength+ Range length. Automatically determine by selectionRangeStart and selectionRangeEnd.+ */property int selectionRangeLength: selectionRangeEnd - selectionRangeStart+ /*+ \qmlproperty displayTextWidth+ Width of the text itself.+ */property int displayTextWidth: textMetrics.boundingRect.widthclip: displayTextWidth > width