From ca6b5aae787ec539f3be84ded3c00e8e880b33b1 Mon Sep 17 00:00:00 2001 From: voidarc Date: Wed, 2 Sep 2026 19:21:41 +0100 Subject: [PATCH] made the tablet buttons a component and added an animation --- Bar/Time.qml | 175 +++++++++++++++++++++++++-------------------------- 1 file changed, 87 insertions(+), 88 deletions(-) diff --git a/Bar/Time.qml b/Bar/Time.qml index 82545aa..0cd26fb 100644 --- a/Bar/Time.qml +++ b/Bar/Time.qml @@ -344,6 +344,63 @@ Container { anchors { fill: parent margins: 3 + topMargin: 3 + } + + Component { + id: tabletButton + + Rectangle { + id: tabletButtonRoot + + required property var modelData + + color: Colors.overlay0 + implicitWidth: 25 + radius: root.boxRadius - 4 + + Behavior on color { + ColorAnimation { + duration: 60 + } + } + + anchors { + bottom: parent.bottom + top: parent.top + } + + TapHandler { + onTapped: { + tabletButtonRoot.modelData.onTapped(); + tabletButtonRoot.color = Colors.text; + tapAnimationTimer.restart(); + } + } + + Timer { + id: tapAnimationTimer + + interval: 80 + repeat: false + running: false + + onTriggered: { + tabletButtonRoot.color = Colors.overlay0; + } + } + + StyledText { + anchors.fill: parent + color: Colors.mauve + fontSize: 14 + fontWeight: 10 + horizontalAlignment: Qt.AlignHCenter + propo: true + text: tabletButtonRoot.modelData.text + verticalAlignment: Qt.AlignVCenter + } + } } Row { @@ -356,32 +413,16 @@ Container { topMargin: 3 } - Rectangle { - color: Colors.overlay0 - implicitWidth: 25 - radius: root.boxRadius - 4 - - anchors { - bottom: parent.bottom - top: parent.top - } - - TapHandler { - onTapped: { - console.log("kando"); - } - } - - StyledText { - anchors.fill: parent - color: Colors.mauve - fontSize: 14 - fontWeight: 10 - horizontalAlignment: Qt.AlignHCenter - propo: true - text: "󱗿" - verticalAlignment: Qt.AlignVCenter - } + Repeater { + delegate: tabletButton + model: [ + { + text: "󱗿", + onTapped: function () { + IpcManager.toggleLauncher(); + } + }, + ] } } @@ -389,77 +430,35 @@ Container { color: Colors.mauve text: TimeManager.time } - } - Row { - spacing: 3 - - anchors { - bottom: parent.bottom - bottomMargin: 3 - right: parent.right - rightMargin: 7 - top: parent.top - topMargin: 3 - } - - Rectangle { - color: Colors.overlay0 - implicitWidth: 25 - radius: root.boxRadius - 4 + Row { + spacing: 3 anchors { bottom: parent.bottom bottomMargin: 3 + right: parent.right + rightMargin: 4 top: parent.top topMargin: 3 } - TapHandler { - onTapped: { - WorkspaceManager.activateWorkspaceById("-1"); - } - } - - StyledText { - anchors.fill: parent - color: Colors.mauve - fontSize: 14 - fontWeight: 10 - horizontalAlignment: Qt.AlignHCenter - propo: true - text: "" - verticalAlignment: Qt.AlignVCenter - } - } - - Rectangle { - color: Colors.overlay0 - implicitWidth: 25 - radius: root.boxRadius - 4 - - anchors { - bottom: parent.bottom - bottomMargin: 3 - top: parent.top - topMargin: 3 - } - - TapHandler { - onTapped: { - Hyprland.dispatch(`hl.dsp.focus({workspace = "+1"})`); - } - } - - StyledText { - anchors.fill: parent - color: Colors.mauve - fontSize: 14 - fontWeight: 10 - horizontalAlignment: Qt.AlignHCenter - propo: true - text: "" - verticalAlignment: Qt.AlignVCenter + Repeater { + delegate: tabletButton + model: [ + { + text: "", + onTapped: function () { + WorkspaceManager.activateWorkspaceById("-1"); + } + }, + { + text: "", + onTapped: function () { + Hyprland.dispatch(`hl.dsp.focus({workspace = "+1"})`); + } + }, + ] } } }