Warning, /utilities/skanpage/src/qml/IntegerSpinBoxWithSuffix.qml is written in an unsupported language. File is not indexed.
0001 /** 0002 * SPDX-FileCopyrightText: 2021 by Alexander Stippich <a.stippich@gmx.net> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 0009 import QtQuick.Layouts 1.1 0010 0011 import org.kde.kirigami 2.12 as Kirigami 0012 0013 Item { 0014 id: container 0015 property alias value: control.value 0016 property alias from: control.from 0017 property alias to: control.to 0018 property alias stepSize: control.stepSize 0019 property alias suffix: suffixText.text 0020 property alias editable: control.editable 0021 0022 implicitWidth: control.width 0023 implicitHeight: control.implicitHeight 0024 0025 signal valueModified(int value) 0026 0027 SpinBox { 0028 id: control 0029 0030 onValueChanged: { 0031 container.valueModified(value) 0032 } 0033 0034 TextMetrics { 0035 id: minTextSize 0036 font: textInput.font 0037 text: control.textFromValue(control.from, control.locale) 0038 } 0039 0040 TextMetrics { 0041 id: maxTextSize 0042 font: textInput.font 0043 text: control.textFromValue(control.to, control.locale) 0044 } 0045 0046 contentItem: Row { 0047 spacing: Kirigami.Units.smallSpacing 0048 0049 TextInput { 0050 id: textInput 0051 color: Kirigami.Theme.textColor 0052 readOnly: !control.editable 0053 text: control.textFromValue(control.value, control.locale) 0054 0055 horizontalAlignment: Qt.AlignRight 0056 verticalAlignment: Qt.AlignVCenter 0057 validator: control.validator 0058 inputMethodHints: Qt.ImhFormattedNumbersOnly 0059 0060 onTextEdited: { 0061 control.value = control.valueFromText(text.replace(control.locale.groupSeparator, ""), control.locale) 0062 control.valueModified() 0063 } 0064 0065 width: Math.max(minTextSize.width, maxTextSize.width) + Kirigami.Units.smallSpacing 0066 } 0067 0068 Label { 0069 id: suffixText 0070 visible: text !== '' 0071 } 0072 } 0073 } 0074 }