summaryrefslogtreecommitdiff
path: root/components/controls/IconTextButton.qml
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-15 15:59:24 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-15 15:59:24 +1000
commit4f54763e02dab4e33764cdd57c204368da57dd1c (patch)
tree3f0626f2ba67b1c95b352061ab090f441c7cb694 /components/controls/IconTextButton.qml
parentutilities/record: app2unit (diff)
downloadcaelestia-shell-4f54763e02dab4e33764cdd57c204368da57dd1c.tar.gz
caelestia-shell-4f54763e02dab4e33764cdd57c204368da57dd1c.tar.bz2
caelestia-shell-4f54763e02dab4e33764cdd57c204368da57dd1c.zip
utilities/record: select mode
Diffstat (limited to 'components/controls/IconTextButton.qml')
-rw-r--r--components/controls/IconTextButton.qml86
1 files changed, 86 insertions, 0 deletions
diff --git a/components/controls/IconTextButton.qml b/components/controls/IconTextButton.qml
new file mode 100644
index 0000000..ba60f3b
--- /dev/null
+++ b/components/controls/IconTextButton.qml
@@ -0,0 +1,86 @@
+import ".."
+import qs.services
+import qs.config
+import QtQuick
+
+StyledRect {
+ id: root
+
+ enum Type {
+ Filled,
+ Tonal,
+ Text
+ }
+
+ property alias icon: iconLabel.text
+ property alias text: label.text
+ property bool checked
+ property bool toggle
+ property real horizontalPadding: Appearance.padding.normal
+ property real verticalPadding: Appearance.padding.smaller
+ property alias font: label.font
+ property int type: IconTextButton.Filled
+
+ property alias stateLayer: stateLayer
+ property alias iconLabel: iconLabel
+ property alias label: label
+
+ property bool internalChecked
+ property color activeColour: type == IconTextButton.Filled ? Colours.palette.m3primary : Colours.palette.m3secondary
+ property color inactiveColour: type == IconTextButton.Filled ? Colours.palette.m3surfaceContainer : Colours.palette.m3secondaryContainer
+ property color activeOnColour: type == IconTextButton.Filled ? Colours.palette.m3onPrimary : Colours.palette.m3onSecondary
+ property color inactiveOnColour: type == IconTextButton.Filled ? Colours.palette.m3onSurface : Colours.palette.m3onSecondaryContainer
+
+ function onClicked(): void {
+ }
+
+ onCheckedChanged: internalChecked = checked
+
+ radius: internalChecked ? Appearance.rounding.small : implicitHeight / 2
+ color: type == IconTextButton.Text ? "transparent" : internalChecked ? activeColour : inactiveColour
+
+ implicitWidth: row.implicitWidth + horizontalPadding * 2
+ implicitHeight: row.implicitHeight + verticalPadding * 2
+
+ StateLayer {
+ id: stateLayer
+
+ color: root.internalChecked ? root.activeOnColour : root.inactiveOnColour
+
+ function onClicked(): void {
+ if (root.toggle)
+ root.internalChecked = !root.internalChecked;
+ root.onClicked();
+ }
+ }
+
+ Row {
+ id: row
+
+ anchors.centerIn: parent
+ spacing: Appearance.spacing.small
+
+ MaterialIcon {
+ id: iconLabel
+
+ anchors.verticalCenter: parent.verticalCenter
+ color: root.internalChecked ? root.activeOnColour : root.inactiveOnColour
+ fill: root.internalChecked ? 1 : 0
+
+ Behavior on fill {
+ Anim {}
+ }
+ }
+
+ StyledText {
+ id: label
+
+ anchors.verticalCenter: parent.verticalCenter
+ color: root.internalChecked ? root.activeOnColour : root.inactiveOnColour
+ }
+ }
+
+ Behavior on radius {
+ Anim {}
+ }
+}