diff --git a/modules/bar/components/hyprland/Workspace.qml b/modules/bar/components/hyprland/Workspace.qml index ba1f9d2..d4ffca7 100644 --- a/modules/bar/components/hyprland/Workspace.qml +++ b/modules/bar/components/hyprland/Workspace.qml @@ -1,56 +1,89 @@ import QtQuick +import QtQuick.Controls +import QtQuick.Effects import Quickshell.Hyprland import "../../../../config" import "../../../../styled/" -Loader { +Item { + id: workspace + required property HyprlandWorkspace modelData - active: modelData.id > 0 + visible: modelData.id > 0 - sourceComponent: workspace - property Component workspace: Clickable { - id: clickable + width: Dimensions.workspace.width + height: Dimensions.workspace.height - width: Dimensions.workspace.width - height: Dimensions.workspace.height - - onClicked: modelData.activate() - - Icon { - id: icon - - source: "/home/baobeld/dotfiles/quickshell/assets/triangle.svg" - - anchors.centerIn: parent - size: Dimensions.workspace.iconSize - - states: State { - name: "active" - when: modelData.active - PropertyChanges { - icon { - rotation: 180 - color: clickable.hovered ? Theme.palette.basecontent : Theme.palette.primary - } + Rectangle { + id: rectangle + anchors.fill: parent + color: Theme.palette.base100 + radius: Dimensions.radius + states: State { + name: "hovered" + when: mouseArea.containsMouse + PropertyChanges { + rectangle { + color: Theme.palette.primary } } + } + transitions: Transition { + from: "" + to: "hovered" + reversible: true + ColorAnimation { + properties: "color" + duration: 200 + easing.type: Easing.InOutCubic + } + } + } - transitions: Transition { - from: "" - to: "active" - reversible: true - ParallelAnimation { - RotationAnimation { - duration: 200 - easing.type: Easing.InOutCubic - } - ColorAnimation { - duration: 200 - easing.type: Easing.OutCubic - } + Icon { + id: icon + + source: "/home/baobeld/dotfiles/quickshell/assets/triangle.svg" + + anchors.centerIn: parent + size: Dimensions.workspace.iconSize + + states: State { + name: "active" + when: workspace.modelData.active + PropertyChanges { + icon { + rotation: 180 + color: mouseArea.containsMouse ? Theme.palette.basecontent : Theme.palette.primary + } + } + } + + transitions: Transition { + from: "" + to: "active" + reversible: true + ParallelAnimation { + RotationAnimation { + duration: 200 + easing.type: Easing.InOutCubic + } + ColorAnimation { + duration: 200 + easing.type: Easing.OutCubic } } } } + + MouseArea { + id: mouseArea + + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + + hoverEnabled: true + onClicked: workspace.modelData.activate() + } } diff --git a/modules/bar/components/mpris/Mpris.qml b/modules/bar/components/mpris/Mpris.qml index b129e77..85dd15e 100644 --- a/modules/bar/components/mpris/Mpris.qml +++ b/modules/bar/components/mpris/Mpris.qml @@ -16,8 +16,8 @@ Item { Player { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter + anchors.horizontalCenter: parent.horizontalCenter + anchors.verticalCenter: parent.verticalCenter visible: index === root.currentIndex && modelData.canControl diff --git a/modules/bar/components/mpris/Player.qml b/modules/bar/components/mpris/Player.qml index 47cc619..0399031 100644 --- a/modules/bar/components/mpris/Player.qml +++ b/modules/bar/components/mpris/Player.qml @@ -1,21 +1,40 @@ +import Quickshell import Quickshell.Services.Mpris import QtQuick import "../../../../styled/" import "../../../../config/" -Loader { +Item { required property MprisPlayer modelData required property int index signal nextPlayer signal previousPlayer - sourceComponent: player - property Component player: Clickable { - id: clickable + implicitWidth: text.width + implicitHeight: Dimensions.mpris.height - implicitWidth: text.width - implicitHeight: Dimensions.mpris.height + StyledLabel { + anchors.fill: text + } + + StyledText { + id: text + text: `${modelData.isPlaying ? "" : ""} ${modelData.trackTitle} - ${modelData.trackArtist}` + + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.mpris.verticalPadding + bottomPadding: Dimensions.mpris.verticalPadding + leftPadding: Dimensions.mpris.horizontalPadding + rightPadding: Dimensions.mpris.horizontalPadding + + font.pixelSize: Dimensions.mpris.fontSize + } + + MouseArea { + anchors.fill: text + + cursorShape: Qt.PointingHandCursor onClicked: { if (!modelData.canTogglePlaying) { @@ -27,39 +46,11 @@ Loader { modelData.play(); } } - onScrolledUp: parent.nextPlayer() - onScrolledDown: parent.previousPlayer() - - StyledText { - id: text - text: `${modelData.isPlaying ? "" : ""} ${modelData.trackTitle} - ${modelData.trackArtist}` - - anchors.verticalCenter: parent.verticalCenter - topPadding: Dimensions.mpris.verticalPadding - bottomPadding: Dimensions.mpris.verticalPadding - leftPadding: Dimensions.mpris.horizontalPadding - rightPadding: Dimensions.mpris.horizontalPadding - - font.pixelSize: Dimensions.mpris.fontSize - - states: State { - name: "hovered" - when: clickable.hovered - PropertyChanges { - text { - color: Theme.palette.base300 - } - } - } - transitions: Transition { - from: "" - to: "hovered" - reversible: true - ColorAnimation { - properties: "color" - duration: 200 - easing.type: Easing.InOutCubic - } + onWheel: event => { + if (event.angleDelta.y > 0) { + parent.nextPlayer(); + } else if (event.angleDelta.y < 0) { + parent.previousPlayer(); } } } diff --git a/styled/Clickable.qml b/styled/Clickable.qml deleted file mode 100644 index ec4eff1..0000000 --- a/styled/Clickable.qml +++ /dev/null @@ -1,53 +0,0 @@ -import QtQuick -import "../config/" - -Item { - id: root - property bool disabled: false - property alias hovered: mouseArea.containsMouse - signal clicked - signal scrolledUp - signal scrolledDown - - StyledLabel { - id: background - anchors.fill: parent - states: State { - name: "hovered" - when: mouseArea.containsMouse - PropertyChanges { - background { - color: Theme.palette.primary - } - } - } - transitions: Transition { - from: "" - to: "hovered" - reversible: true - ColorAnimation { - properties: "color" - duration: 200 - easing.type: Easing.InOutCubic - } - } - } - - MouseArea { - id: mouseArea - anchors.fill: parent - - hoverEnabled: !disabled - cursorShape: Qt.PointingHandCursor - - onClicked: root.clicked() - - onWheel: event => { - if (event.angleDelta.y > 0) { - root.scrolledUp(); - } else if (event.angleDelta.y < 0) { - root.scrolledDown(); - } - } - } -}