From 09cdad1554995c74e0de7a33d78d3fefa9af302c Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Fri, 6 Feb 2026 23:38:05 +0100 Subject: [PATCH] hefty: bar: time widget --- .../modules/common/functions/ObjectUtils.qml | 11 +++ .../modules/common/widgets/StateOverlay.qml | 23 ++++- .../hefty/topLayer/bar/HBarContent.qml | 32 ++++++- .../hefty/topLayer/bar/HBarGroupContainer.qml | 9 +- .../bar/HBarUserFallbackComponentRepeater.qml | 13 ++- .../hefty/topLayer/bar/widgets/HTime.qml | 91 +++++++++++++++++++ .../topLayer/bar/widgets/HWorkspaces.qml | 9 +- .../hefty/topLayer/bar/widgets/Invisible.qml | 6 ++ .../ii/modules/ii/bar/ClockWidget.qml | 1 - 9 files changed, 177 insertions(+), 18 deletions(-) create mode 100644 dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HTime.qml create mode 100644 dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/Invisible.qml diff --git a/dots/.config/quickshell/ii/modules/common/functions/ObjectUtils.qml b/dots/.config/quickshell/ii/modules/common/functions/ObjectUtils.qml index d1204cddc..178d07645 100644 --- a/dots/.config/quickshell/ii/modules/common/functions/ObjectUtils.qml +++ b/dots/.config/quickshell/ii/modules/common/functions/ObjectUtils.qml @@ -95,4 +95,15 @@ Singleton { } } } + + function findParentWithProperty(obj, propertyName) { + let current = obj; + while (current) { + if (current.hasOwnProperty(propertyName)) { + return current; + } + current = current.parent; + } + return null; + } } diff --git a/dots/.config/quickshell/ii/modules/common/widgets/StateOverlay.qml b/dots/.config/quickshell/ii/modules/common/widgets/StateOverlay.qml index 65cabc218..44fc64494 100644 --- a/dots/.config/quickshell/ii/modules/common/widgets/StateOverlay.qml +++ b/dots/.config/quickshell/ii/modules/common/widgets/StateOverlay.qml @@ -1,5 +1,6 @@ pragma ComponentBehavior: Bound import QtQuick +import qs.modules.common as C Rectangle { id: root @@ -7,7 +8,7 @@ Rectangle { property bool hover: false property bool press: false property bool drag: false - property color contentColor: Appearance.m3colors.m3onBackground + property color contentColor: C.Appearance.m3colors.m3onBackground color: "transparent" FadeLoader { @@ -15,9 +16,12 @@ Rectangle { anchors.fill: parent shown: root.hover sourceComponent: StateLayer { - radius: root.radius state: StateLayer.State.Hover color: root.contentColor + topLeftRadius: root.topLeftRadius + topRightRadius: root.topRightRadius + bottomLeftRadius: root.bottomLeftRadius + bottomRightRadius: root.bottomRightRadius } } FadeLoader { @@ -25,9 +29,12 @@ Rectangle { anchors.fill: parent shown: root.focus sourceComponent: StateLayer { - radius: root.radius state: StateLayer.State.Focus color: root.contentColor + topLeftRadius: root.topLeftRadius + topRightRadius: root.topRightRadius + bottomLeftRadius: root.bottomLeftRadius + bottomRightRadius: root.bottomRightRadius } } FadeLoader { @@ -35,9 +42,12 @@ Rectangle { anchors.fill: parent shown: root.press sourceComponent: StateLayer { - radius: root.radius state: StateLayer.State.Press color: root.contentColor + topLeftRadius: root.topLeftRadius + topRightRadius: root.topRightRadius + bottomLeftRadius: root.bottomLeftRadius + bottomRightRadius: root.bottomRightRadius } } FadeLoader { @@ -45,9 +55,12 @@ Rectangle { anchors.fill: parent shown: root.drag sourceComponent: StateLayer { - radius: root.radius state: StateLayer.State.Drag color: root.contentColor + topLeftRadius: root.topLeftRadius + topRightRadius: root.topRightRadius + bottomLeftRadius: root.bottomLeftRadius + bottomRightRadius: root.bottomRightRadius } } } diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarContent.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarContent.qml index a26e5b232..cd0fe80ea 100644 --- a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarContent.qml +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarContent.qml @@ -9,13 +9,19 @@ Item { property bool vertical: C.Config.options.bar.vertical property real spacing: 4 + property list leftWidgets: C.Config.options.hefty.bar.leftWidgets + property list centerLeftWidgets: C.Config.options.hefty.bar.centerLeftWidgets + property list centerWidgets: C.Config.options.hefty.bar.centerWidgets + property list centerRightWidgets: C.Config.options.hefty.bar.centerRightWidgets + property list rightWidgets: C.Config.options.hefty.bar.rightWidgets + Side { id: leftSide anchors.left: parent.left anchors.top: parent.top HBarUserFallbackComponentRepeater { - componentNames: C.Config.options.hefty.bar.leftWidgets + componentNames: root.leftWidgets } } @@ -24,7 +30,16 @@ Item { anchors.right: !root.vertical ? centerSide.left : parent.right anchors.bottom: root.vertical ? parent.bottom : undefined HBarUserFallbackComponentRepeater { - componentNames: C.Config.options.hefty.bar.centerLeftWidgets + componentNames: { + print(JSON.stringify([ + ...root.centerLeftWidgets, + ...(root.centerLeftWidgets.length > 0 ? [invisibleItem] : []), + ], null, 2)); + return [ + ...root.centerLeftWidgets, + ...(root.centerLeftWidgets.length > 0 ? [invisibleItem] : []), + ]; + } } } @@ -33,7 +48,11 @@ Item { anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined HBarUserFallbackComponentRepeater { - componentNames: C.Config.options.hefty.bar.centerWidgets + componentNames: [ + ...(root.centerLeftWidgets.length > 0 ? [invisibleItem] : []), + ...root.centerWidgets, + ...(root.centerRightWidgets.length > 0 ? [invisibleItem] : []), + ] } } @@ -42,7 +61,10 @@ Item { anchors.left: !root.vertical ? centerSide.right : parent.left anchors.top: root.vertical ? parent.top : undefined HBarUserFallbackComponentRepeater { - componentNames: C.Config.options.hefty.bar.centerRightWidgets + componentNames: [ + ...(root.centerLeftWidgets.length > 0 ? [invisibleItem] : []), + ...root.centerRightWidgets, + ] } } @@ -51,7 +73,7 @@ Item { anchors.right: parent.right anchors.bottom: parent.bottom HBarUserFallbackComponentRepeater { - componentNames: C.Config.options.hefty.bar.rightWidgets + componentNames: root.rightWidgets } } diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarGroupContainer.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarGroupContainer.qml index fc8f2b863..a96eeb32b 100644 --- a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarGroupContainer.qml +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarGroupContainer.qml @@ -22,10 +22,17 @@ Item { implicitWidth: vertical ? barUndirectionalWidth : layout.implicitWidth + padding * 2 implicitHeight: vertical ? layout.implicitHeight + padding * 2 : barUndirectionalWidth + property alias startRadius: bg.startRadius + property alias endRadius: bg.endRadius + property alias topLeftRadius: bg.topLeftRadius + property alias topRightRadius: bg.topRightRadius + property alias bottomLeftRadius: bg.bottomLeftRadius + property alias bottomRightRadius: bg.bottomRightRadius + W.AxisRectangle { id: bg anchors.centerIn: parent - contentLayer: W.StyledRectangle.ContentLayer.Pane + contentLayer: W.StyledRectangle.ContentLayer.Group width: root.vertical ? root.backgroundUndirectionalWidth : root.width height: root.vertical ? root.height : root.backgroundUndirectionalWidth diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarUserFallbackComponentRepeater.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarUserFallbackComponentRepeater.qml index 0961058f3..9d265c81b 100644 --- a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarUserFallbackComponentRepeater.qml +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/HBarUserFallbackComponentRepeater.qml @@ -7,21 +7,25 @@ import qs.modules.common.widgets as W Repeater { id: root + readonly property string invisibleItem: "_invisible" required property list componentNames property string context: Quickshell.shellPath("modules/hefty/topLayer/bar/widgets") + model: { const m = componentNames.map(item => { if (item instanceof Array) return ({"type": "container", "value": item}); + else if (item === root.invisibleItem) + return ({"type": "invisible", "value": item}); else return ({"type": "component", "value": item}); }); for (var i = 0;i < m.length; i++) { const item = m[i]; if (item.type === "container") { - item.startSide = (i === 0) || (m[i - 1].type !== "container"); - item.endSide = (i + 1 >= m.length) || (m[i + 1].type !== "container"); + item.startSide = (i === 0) || (m[i - 1].type === "component"); + item.endSide = (i + 1 >= m.length) || (m[i + 1].type === "component"); } } // print(JSON.stringify(m, null, 2)); @@ -29,6 +33,11 @@ Repeater { } delegate: DelegateChooser { role: "type" + + DelegateChoice { + roleValue: root.invisibleItem + delegate: Item { visible: false } + } DelegateChoice { roleValue: "component" diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HTime.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HTime.qml new file mode 100644 index 000000000..de2d1f8a0 --- /dev/null +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HTime.qml @@ -0,0 +1,91 @@ +pragma ComponentBehavior: Bound +import QtQuick +import QtQuick.Layouts + +import qs.modules.common as C +import qs.modules.common.functions as F +import qs.services as S +import qs.modules.common.widgets as W + +W.ButtonMouseArea { + id: root + + property bool vertical: C.Config.options.bar.vertical + property bool showPopup: false + + property var layoutParent: F.ObjectUtils.findParentWithProperty(root, "startSide") + property real layoutParentTopLeftRadius: layoutParent.topLeftRadius + property real layoutParentTopRightRadius: layoutParent.topRightRadius + property real layoutParentBottomLeftRadius: layoutParent.bottomLeftRadius + property real layoutParentBottomRightRadius: layoutParent.bottomRightRadius + + readonly property real barThickness: vertical ? C.Appearance.sizes.verticalBarWidth : C.Appearance.sizes.barHeight + property var activeContent: vertical ? verticalContent : horizontalContent + property real parentRadiusToPaddingRatio: 0.3 + implicitWidth: vertical ? barThickness : (activeContent.implicitWidth + (layoutParentTopLeftRadius + layoutParentBottomRightRadius) * parentRadiusToPaddingRatio) + implicitHeight: !vertical ? barThickness : (activeContent.implicitHeight + (layoutParentTopLeftRadius + layoutParentBottomRightRadius) * parentRadiusToPaddingRatio) + Layout.alignment: vertical ? Qt.AlignHCenter : Qt.AlignVCenter + Layout.fillWidth: vertical + Layout.fillHeight: !vertical + + onClicked: showPopup = !showPopup + + W.StateOverlay { + id: hoverOverlay + anchors.fill: parent + property real parentMargins: 4 + property real ownMargins: 2 + property real edgeMargins: parentMargins + ownMargins + property real sideMargins: -2 + anchors { + leftMargin: root.vertical ? edgeMargins : sideMargins + rightMargin: root.vertical ? edgeMargins : sideMargins + topMargin: root.vertical ? sideMargins : edgeMargins + bottomMargin: root.vertical ? sideMargins : edgeMargins + } + topLeftRadius: root.layoutParentTopLeftRadius - ownMargins + topRightRadius: root.layoutParentTopRightRadius - ownMargins + bottomLeftRadius: root.layoutParentBottomLeftRadius - ownMargins + bottomRightRadius: root.layoutParentBottomRightRadius - ownMargins + + hover: root.containsMouse + press: root.containsPress + } + + W.FadeLoader { + id: horizontalContent + anchors.fill: parent + shown: !root.vertical + sourceComponent: RowLayout { + anchors.fill: parent + + W.StyledText { + Layout.leftMargin: root.layoutParentTopLeftRadius * root.parentRadiusToPaddingRatio + Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter + horizontalAlignment: Text.AlignHCenter + font.pixelSize: C.Appearance.font.pixelSize.large + color: C.Appearance.colors.colOnLayer1 + text: S.DateTime.time + } + + W.StyledText { + Layout.alignment: Qt.AlignVCenter + font.pixelSize: C.Appearance.font.pixelSize.small + color: C.Appearance.colors.colOnLayer1 + text: "•" + } + + W.StyledText { + Layout.alignment: Qt.AlignVCenter + font.pixelSize: C.Appearance.font.pixelSize.small + color: C.Appearance.colors.colOnLayer1 + text: S.DateTime.longDate + } + } + } + + W.FadeLoader { + id: verticalContent + anchors.fill: parent + } +} diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HWorkspaces.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HWorkspaces.qml index 469de3155..4625ed9a6 100644 --- a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HWorkspaces.qml +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/HWorkspaces.qml @@ -36,8 +36,9 @@ Item { Layout.alignment: vertical ? Qt.AlignHCenter : Qt.AlignVCenter Layout.fillWidth: vertical Layout.fillHeight: !vertical - implicitWidth: vertical ? Appearance.sizes.verticalBarWidth : occupiedIndicators.implicitWidth - implicitHeight: vertical ? occupiedIndicators.implicitHeight : Appearance.sizes.barHeight + readonly property real barThickness: vertical ? Appearance.sizes.verticalBarWidth : Appearance.sizes.barHeight + implicitWidth: vertical ? barThickness : occupiedIndicators.implicitWidth + implicitHeight: vertical ? occupiedIndicators.implicitHeight : barThickness property real specialBlur: (wsModel.specialWorkspaceActive && !interactionMouseArea.containsMouse) ? 1 : 0 Behavior on specialBlur { @@ -316,8 +317,8 @@ Item { component WorkspaceItem: Item { required property int index readonly property int wsId: wsModel.getWorkspaceIdAt(index) - implicitWidth: root.vertical ? Appearance.sizes.verticalBarWidth : root.workspaceButtonWidth - implicitHeight: root.vertical ? root.workspaceButtonWidth : Appearance.sizes.barHeight + implicitWidth: root.vertical ? root.barThickness : root.workspaceButtonWidth + implicitHeight: root.vertical ? root.workspaceButtonWidth : root.barThickness } component NumberWorkspaceItem: WorkspaceItem { diff --git a/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/Invisible.qml b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/Invisible.qml new file mode 100644 index 000000000..08b2d0fb5 --- /dev/null +++ b/dots/.config/quickshell/ii/modules/hefty/topLayer/bar/widgets/Invisible.qml @@ -0,0 +1,6 @@ +pragma ComponentBehavior: Bound +import QtQuick + +Item { + visible: false +} diff --git a/dots/.config/quickshell/ii/modules/ii/bar/ClockWidget.qml b/dots/.config/quickshell/ii/modules/ii/bar/ClockWidget.qml index 1d4b9f865..eb63fc4c0 100644 --- a/dots/.config/quickshell/ii/modules/ii/bar/ClockWidget.qml +++ b/dots/.config/quickshell/ii/modules/ii/bar/ClockWidget.qml @@ -6,7 +6,6 @@ import QtQuick.Layouts Item { id: root - property bool borderless: Config.options.bar.borderless property bool showDate: Config.options.bar.verbose implicitWidth: rowLayout.implicitWidth implicitHeight: Appearance.sizes.barHeight