forked from Shinonome/dots-hyprland
add spinbox
This commit is contained in:
@@ -0,0 +1,31 @@
|
|||||||
|
import "root:/modules/common/widgets/"
|
||||||
|
import "root:/modules/common/"
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Layouts
|
||||||
|
import QtQuick.Controls
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: root
|
||||||
|
property string text: ""
|
||||||
|
property alias value: spinBoxWidget.value
|
||||||
|
property alias stepSize: spinBoxWidget.stepSize
|
||||||
|
property alias from: spinBoxWidget.from
|
||||||
|
property alias to: spinBoxWidget.to
|
||||||
|
spacing: 10
|
||||||
|
Layout.leftMargin: 8
|
||||||
|
Layout.rightMargin: 8
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
id: labelWidget
|
||||||
|
Layout.fillWidth: true
|
||||||
|
text: root.text
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.small
|
||||||
|
color: Appearance.colors.colOnSecondaryContainer
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledSpinBox {
|
||||||
|
id: spinBoxWidget
|
||||||
|
Layout.fillWidth: false
|
||||||
|
value: root.value
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import "root:/modules/common"
|
||||||
|
import "root:/modules/common/functions/color_utils.js" as ColorUtils
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Material 3 styled SpinBox component.
|
||||||
|
*/
|
||||||
|
SpinBox {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property real baseHeight: 35
|
||||||
|
property real radius: Appearance.rounding.small
|
||||||
|
property real innerButtonRadius: Appearance.rounding.unsharpen
|
||||||
|
editable: true
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
color: Appearance.colors.colLayer2
|
||||||
|
radius: root.radius
|
||||||
|
}
|
||||||
|
|
||||||
|
contentItem: Item {
|
||||||
|
implicitHeight: root.baseHeight
|
||||||
|
implicitWidth: Math.max(labelText.implicitWidth, 40)
|
||||||
|
|
||||||
|
StyledTextInput {
|
||||||
|
id: labelText
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: root.displayText
|
||||||
|
color: Appearance.colors.colOnLayer2
|
||||||
|
font.pixelSize: Appearance.font.pixelSize.small
|
||||||
|
validator: root.validator
|
||||||
|
onTextChanged: {
|
||||||
|
root.value = parseFloat(text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
down.indicator: Rectangle {
|
||||||
|
anchors {
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
left: parent.left
|
||||||
|
}
|
||||||
|
implicitHeight: root.baseHeight
|
||||||
|
implicitWidth: root.baseHeight
|
||||||
|
topLeftRadius: root.radius
|
||||||
|
bottomLeftRadius: root.radius
|
||||||
|
topRightRadius: root.innerButtonRadius
|
||||||
|
bottomRightRadius: root.innerButtonRadius
|
||||||
|
|
||||||
|
color: root.down.pressed ? Appearance.colors.colLayer2Active :
|
||||||
|
root.down.hovered ? Appearance.colors.colLayer2Hover :
|
||||||
|
ColorUtils.transparentize(Appearance.colors.colLayer2)
|
||||||
|
Behavior on color {
|
||||||
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "remove"
|
||||||
|
iconSize: 20
|
||||||
|
color: Appearance.colors.colOnLayer2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
up.indicator: Rectangle {
|
||||||
|
anchors {
|
||||||
|
verticalCenter: parent.verticalCenter
|
||||||
|
right: parent.right
|
||||||
|
}
|
||||||
|
implicitHeight: root.baseHeight
|
||||||
|
implicitWidth: root.baseHeight
|
||||||
|
topRightRadius: root.radius
|
||||||
|
bottomRightRadius: root.radius
|
||||||
|
topLeftRadius: root.innerButtonRadius
|
||||||
|
bottomLeftRadius: root.innerButtonRadius
|
||||||
|
|
||||||
|
color: root.up.pressed ? Appearance.colors.colLayer2Active :
|
||||||
|
root.up.hovered ? Appearance.colors.colLayer2Hover :
|
||||||
|
ColorUtils.transparentize(Appearance.colors.colLayer2)
|
||||||
|
Behavior on color {
|
||||||
|
animation: Appearance.animation.elementMoveFast.colorAnimation.createObject(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
MaterialSymbol {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "add"
|
||||||
|
iconSize: 20
|
||||||
|
color: Appearance.colors.colOnLayer2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user