diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-26 23:11:28 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-07-26 23:11:28 +1000 |
| commit | db1e2ea3bf7dd1f5ac1960ca4c9dc17757649460 (patch) | |
| tree | 49db4ec68518e475f6e24f96373b28dd85e40e19 /widgets | |
| parent | dcontent: add bt pane (diff) | |
| download | caelestia-shell-db1e2ea3bf7dd1f5ac1960ca4c9dc17757649460.tar.gz caelestia-shell-db1e2ea3bf7dd1f5ac1960ca4c9dc17757649460.tar.bz2 caelestia-shell-db1e2ea3bf7dd1f5ac1960ca4c9dc17757649460.zip | |
dcontent: impl bt settings
Diffstat (limited to 'widgets')
| -rw-r--r-- | widgets/CustomSpinBox.qml | 107 | ||||
| -rw-r--r-- | widgets/StyledTextField.qml | 2 |
2 files changed, 109 insertions, 0 deletions
diff --git a/widgets/CustomSpinBox.qml b/widgets/CustomSpinBox.qml new file mode 100644 index 0000000..5021bd5 --- /dev/null +++ b/widgets/CustomSpinBox.qml @@ -0,0 +1,107 @@ +pragma ComponentBehavior: Bound + +import qs.services +import qs.config +import QtQuick +import QtQuick.Layouts + +RowLayout { + id: root + + property int value + property real max: NaN + property real min: NaN + property alias repeatRate: timer.interval + + signal valueModified(value: int) + + spacing: Appearance.spacing.small + + StyledTextField { + inputMethodHints: Qt.ImhFormattedNumbersOnly + text: root.value + onAccepted: root.valueModified(text) + + padding: Appearance.padding.small + leftPadding: Appearance.padding.normal + rightPadding: Appearance.padding.normal + + background: StyledRect { + implicitWidth: 100 + radius: Appearance.rounding.small + color: Colours.palette.m3surfaceContainerHigh + } + } + + StyledRect { + radius: Appearance.rounding.small + color: Colours.palette.m3primary + + implicitWidth: implicitHeight + implicitHeight: upIcon.implicitHeight + Appearance.padding.small * 2 + + StateLayer { + id: upState + + color: Colours.palette.m3onPrimary + + onPressAndHold: timer.start() + onReleased: timer.stop() + + function onClicked(): void { + root.valueModified(Math.min(root.max, root.value + 1)); + } + } + + MaterialIcon { + id: upIcon + + anchors.centerIn: parent + text: "keyboard_arrow_up" + color: Colours.palette.m3onPrimary + } + } + + StyledRect { + radius: Appearance.rounding.small + color: Colours.palette.m3primary + + implicitWidth: implicitHeight + implicitHeight: downIcon.implicitHeight + Appearance.padding.small * 2 + + StateLayer { + id: downState + + color: Colours.palette.m3onPrimary + + onPressAndHold: timer.start() + onReleased: timer.stop() + + function onClicked(): void { + root.valueModified(Math.max(root.min, root.value - 1)); + } + } + + MaterialIcon { + id: downIcon + + anchors.centerIn: parent + text: "keyboard_arrow_down" + color: Colours.palette.m3onPrimary + } + } + + Timer { + id: timer + + interval: 100 + repeat: true + triggeredOnStart: true + onTriggered: { + if (upState.pressed) + upState.onClicked(); + else if (downState.pressed) + downState.onClicked(); + } + } +} diff --git a/widgets/StyledTextField.qml b/widgets/StyledTextField.qml index d36ae02..ecde872 100644 --- a/widgets/StyledTextField.qml +++ b/widgets/StyledTextField.qml @@ -13,6 +13,8 @@ TextField { font.family: Appearance.font.family.sans font.pointSize: Appearance.font.size.smaller + background: null + cursorDelegate: StyledRect { id: cursor |