diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-14 16:59:19 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-09-14 16:59:19 +1000 |
| commit | 4b221e2fd5b7faf4747cff6c590b6ddc38870901 (patch) | |
| tree | 3041635aa0e94a7783410ccf76424143060fa605 /components/controls | |
| parent | internal: close panels when fullscreen app (diff) | |
| download | caelestia-shell-4b221e2fd5b7faf4747cff6c590b6ddc38870901.tar.gz caelestia-shell-4b221e2fd5b7faf4747cff6c590b6ddc38870901.tar.bz2 caelestia-shell-4b221e2fd5b7faf4747cff6c590b6ddc38870901.zip | |
utilities: add recording control
Diffstat (limited to 'components/controls')
| -rw-r--r-- | components/controls/IconButton.qml | 68 | ||||
| -rw-r--r-- | components/controls/StyledScrollBar.qml | 14 |
2 files changed, 81 insertions, 1 deletions
diff --git a/components/controls/IconButton.qml b/components/controls/IconButton.qml new file mode 100644 index 0000000..7eadcc3 --- /dev/null +++ b/components/controls/IconButton.qml @@ -0,0 +1,68 @@ +import ".." +import qs.services +import qs.config +import QtQuick + +StyledRect { + id: root + + enum Type { + Filled, + Tonal, + Text + } + + required property string icon + property bool checked + property bool toggle + property real padding: type == IconButton.Text ? Appearance.padding.small / 2 : Appearance.padding.smaller + property alias font: label.font + property int type: IconButton.Filled + + property alias label: label + + property bool internalChecked + property color activeColour: type == IconButton.Filled ? Colours.palette.m3primary : Colours.palette.m3secondary + property color inactiveColour: type == IconButton.Filled ? Colours.palette.m3surfaceContainer : Colours.palette.m3secondaryContainer + property color activeOnColour: type == IconButton.Filled ? Colours.palette.m3onPrimary : Colours.palette.m3onSecondary + property color inactiveOnColour: type == IconButton.Filled ? Colours.palette.m3onSurface : Colours.palette.m3onSecondaryContainer + + function onClicked(): void { + } + + onCheckedChanged: internalChecked = checked + + radius: internalChecked ? Appearance.rounding.small : implicitHeight / 2 + color: type == IconButton.Text ? "transparent" : internalChecked ? activeColour : inactiveColour + + implicitWidth: implicitHeight + implicitHeight: label.implicitHeight + padding * 2 + + StateLayer { + color: root.internalChecked ? root.activeOnColour : root.inactiveOnColour + + function onClicked(): void { + if (root.toggle) + root.internalChecked = !root.internalChecked; + root.onClicked(); + } + } + + MaterialIcon { + id: label + + anchors.centerIn: parent + + text: root.icon + color: root.internalChecked ? root.activeOnColour : root.inactiveOnColour + fill: root.internalChecked ? 1 : 0 + + Behavior on fill { + Anim {} + } + } + + Behavior on radius { + Anim {} + } +} diff --git a/components/controls/StyledScrollBar.qml b/components/controls/StyledScrollBar.qml index 69a01f3..ea895ae 100644 --- a/components/controls/StyledScrollBar.qml +++ b/components/controls/StyledScrollBar.qml @@ -7,12 +7,24 @@ import QtQuick.Controls ScrollBar { id: root + leftPadding: 0 + contentItem: StyledRect { + x: 0 implicitWidth: 6 - opacity: root.pressed ? 1 : root.policy === ScrollBar.AlwaysOn || (root.active && root.size < 1) ? 0.8 : 0 + opacity: root.pressed ? 1 : mouse.containsMouse ? 0.8 : root.policy === ScrollBar.AlwaysOn || (root.active && root.size < 1) ? 0.6 : 0 radius: Appearance.rounding.full color: Colours.palette.m3secondary + MouseArea { + id: mouse + + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + hoverEnabled: true + acceptedButtons: Qt.NoButton + } + Behavior on opacity { Anim {} } |