forked from Shinonome/dots-hyprland
hefty: bar: time widget
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
pragma ComponentBehavior: Bound
|
pragma ComponentBehavior: Bound
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
import qs.modules.common as C
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
@@ -7,7 +8,7 @@ Rectangle {
|
|||||||
property bool hover: false
|
property bool hover: false
|
||||||
property bool press: false
|
property bool press: false
|
||||||
property bool drag: false
|
property bool drag: false
|
||||||
property color contentColor: Appearance.m3colors.m3onBackground
|
property color contentColor: C.Appearance.m3colors.m3onBackground
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
|
|
||||||
FadeLoader {
|
FadeLoader {
|
||||||
@@ -15,9 +16,12 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
shown: root.hover
|
shown: root.hover
|
||||||
sourceComponent: StateLayer {
|
sourceComponent: StateLayer {
|
||||||
radius: root.radius
|
|
||||||
state: StateLayer.State.Hover
|
state: StateLayer.State.Hover
|
||||||
color: root.contentColor
|
color: root.contentColor
|
||||||
|
topLeftRadius: root.topLeftRadius
|
||||||
|
topRightRadius: root.topRightRadius
|
||||||
|
bottomLeftRadius: root.bottomLeftRadius
|
||||||
|
bottomRightRadius: root.bottomRightRadius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FadeLoader {
|
FadeLoader {
|
||||||
@@ -25,9 +29,12 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
shown: root.focus
|
shown: root.focus
|
||||||
sourceComponent: StateLayer {
|
sourceComponent: StateLayer {
|
||||||
radius: root.radius
|
|
||||||
state: StateLayer.State.Focus
|
state: StateLayer.State.Focus
|
||||||
color: root.contentColor
|
color: root.contentColor
|
||||||
|
topLeftRadius: root.topLeftRadius
|
||||||
|
topRightRadius: root.topRightRadius
|
||||||
|
bottomLeftRadius: root.bottomLeftRadius
|
||||||
|
bottomRightRadius: root.bottomRightRadius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FadeLoader {
|
FadeLoader {
|
||||||
@@ -35,9 +42,12 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
shown: root.press
|
shown: root.press
|
||||||
sourceComponent: StateLayer {
|
sourceComponent: StateLayer {
|
||||||
radius: root.radius
|
|
||||||
state: StateLayer.State.Press
|
state: StateLayer.State.Press
|
||||||
color: root.contentColor
|
color: root.contentColor
|
||||||
|
topLeftRadius: root.topLeftRadius
|
||||||
|
topRightRadius: root.topRightRadius
|
||||||
|
bottomLeftRadius: root.bottomLeftRadius
|
||||||
|
bottomRightRadius: root.bottomRightRadius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FadeLoader {
|
FadeLoader {
|
||||||
@@ -45,9 +55,12 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
shown: root.drag
|
shown: root.drag
|
||||||
sourceComponent: StateLayer {
|
sourceComponent: StateLayer {
|
||||||
radius: root.radius
|
|
||||||
state: StateLayer.State.Drag
|
state: StateLayer.State.Drag
|
||||||
color: root.contentColor
|
color: root.contentColor
|
||||||
|
topLeftRadius: root.topLeftRadius
|
||||||
|
topRightRadius: root.topRightRadius
|
||||||
|
bottomLeftRadius: root.bottomLeftRadius
|
||||||
|
bottomRightRadius: root.bottomRightRadius
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,19 @@ Item {
|
|||||||
property bool vertical: C.Config.options.bar.vertical
|
property bool vertical: C.Config.options.bar.vertical
|
||||||
property real spacing: 4
|
property real spacing: 4
|
||||||
|
|
||||||
|
property list<var> leftWidgets: C.Config.options.hefty.bar.leftWidgets
|
||||||
|
property list<var> centerLeftWidgets: C.Config.options.hefty.bar.centerLeftWidgets
|
||||||
|
property list<var> centerWidgets: C.Config.options.hefty.bar.centerWidgets
|
||||||
|
property list<var> centerRightWidgets: C.Config.options.hefty.bar.centerRightWidgets
|
||||||
|
property list<var> rightWidgets: C.Config.options.hefty.bar.rightWidgets
|
||||||
|
|
||||||
Side {
|
Side {
|
||||||
id: leftSide
|
id: leftSide
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
|
|
||||||
HBarUserFallbackComponentRepeater {
|
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.right: !root.vertical ? centerSide.left : parent.right
|
||||||
anchors.bottom: root.vertical ? parent.bottom : undefined
|
anchors.bottom: root.vertical ? parent.bottom : undefined
|
||||||
HBarUserFallbackComponentRepeater {
|
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.verticalCenter: root.vertical ? parent.verticalCenter : undefined
|
||||||
anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined
|
anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined
|
||||||
HBarUserFallbackComponentRepeater {
|
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.left: !root.vertical ? centerSide.right : parent.left
|
||||||
anchors.top: root.vertical ? parent.top : undefined
|
anchors.top: root.vertical ? parent.top : undefined
|
||||||
HBarUserFallbackComponentRepeater {
|
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.right: parent.right
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
HBarUserFallbackComponentRepeater {
|
HBarUserFallbackComponentRepeater {
|
||||||
componentNames: C.Config.options.hefty.bar.rightWidgets
|
componentNames: root.rightWidgets
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,17 @@ Item {
|
|||||||
implicitWidth: vertical ? barUndirectionalWidth : layout.implicitWidth + padding * 2
|
implicitWidth: vertical ? barUndirectionalWidth : layout.implicitWidth + padding * 2
|
||||||
implicitHeight: vertical ? layout.implicitHeight + padding * 2 : barUndirectionalWidth
|
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 {
|
W.AxisRectangle {
|
||||||
id: bg
|
id: bg
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
contentLayer: W.StyledRectangle.ContentLayer.Pane
|
contentLayer: W.StyledRectangle.ContentLayer.Group
|
||||||
|
|
||||||
width: root.vertical ? root.backgroundUndirectionalWidth : root.width
|
width: root.vertical ? root.backgroundUndirectionalWidth : root.width
|
||||||
height: root.vertical ? root.height : root.backgroundUndirectionalWidth
|
height: root.vertical ? root.height : root.backgroundUndirectionalWidth
|
||||||
|
|||||||
+11
-2
@@ -7,21 +7,25 @@ import qs.modules.common.widgets as W
|
|||||||
Repeater {
|
Repeater {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
readonly property string invisibleItem: "_invisible"
|
||||||
required property list<var> componentNames
|
required property list<var> componentNames
|
||||||
property string context: Quickshell.shellPath("modules/hefty/topLayer/bar/widgets")
|
property string context: Quickshell.shellPath("modules/hefty/topLayer/bar/widgets")
|
||||||
|
|
||||||
|
|
||||||
model: {
|
model: {
|
||||||
const m = componentNames.map(item => {
|
const m = componentNames.map(item => {
|
||||||
if (item instanceof Array)
|
if (item instanceof Array)
|
||||||
return ({"type": "container", "value": item});
|
return ({"type": "container", "value": item});
|
||||||
|
else if (item === root.invisibleItem)
|
||||||
|
return ({"type": "invisible", "value": item});
|
||||||
else
|
else
|
||||||
return ({"type": "component", "value": item});
|
return ({"type": "component", "value": item});
|
||||||
});
|
});
|
||||||
for (var i = 0;i < m.length; i++) {
|
for (var i = 0;i < m.length; i++) {
|
||||||
const item = m[i];
|
const item = m[i];
|
||||||
if (item.type === "container") {
|
if (item.type === "container") {
|
||||||
item.startSide = (i === 0) || (m[i - 1].type !== "container");
|
item.startSide = (i === 0) || (m[i - 1].type === "component");
|
||||||
item.endSide = (i + 1 >= m.length) || (m[i + 1].type !== "container");
|
item.endSide = (i + 1 >= m.length) || (m[i + 1].type === "component");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// print(JSON.stringify(m, null, 2));
|
// print(JSON.stringify(m, null, 2));
|
||||||
@@ -29,6 +33,11 @@ Repeater {
|
|||||||
}
|
}
|
||||||
delegate: DelegateChooser {
|
delegate: DelegateChooser {
|
||||||
role: "type"
|
role: "type"
|
||||||
|
|
||||||
|
DelegateChoice {
|
||||||
|
roleValue: root.invisibleItem
|
||||||
|
delegate: Item { visible: false }
|
||||||
|
}
|
||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: "component"
|
roleValue: "component"
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,8 +36,9 @@ Item {
|
|||||||
Layout.alignment: vertical ? Qt.AlignHCenter : Qt.AlignVCenter
|
Layout.alignment: vertical ? Qt.AlignHCenter : Qt.AlignVCenter
|
||||||
Layout.fillWidth: vertical
|
Layout.fillWidth: vertical
|
||||||
Layout.fillHeight: !vertical
|
Layout.fillHeight: !vertical
|
||||||
implicitWidth: vertical ? Appearance.sizes.verticalBarWidth : occupiedIndicators.implicitWidth
|
readonly property real barThickness: vertical ? Appearance.sizes.verticalBarWidth : Appearance.sizes.barHeight
|
||||||
implicitHeight: vertical ? occupiedIndicators.implicitHeight : Appearance.sizes.barHeight
|
implicitWidth: vertical ? barThickness : occupiedIndicators.implicitWidth
|
||||||
|
implicitHeight: vertical ? occupiedIndicators.implicitHeight : barThickness
|
||||||
|
|
||||||
property real specialBlur: (wsModel.specialWorkspaceActive && !interactionMouseArea.containsMouse) ? 1 : 0
|
property real specialBlur: (wsModel.specialWorkspaceActive && !interactionMouseArea.containsMouse) ? 1 : 0
|
||||||
Behavior on specialBlur {
|
Behavior on specialBlur {
|
||||||
@@ -316,8 +317,8 @@ Item {
|
|||||||
component WorkspaceItem: Item {
|
component WorkspaceItem: Item {
|
||||||
required property int index
|
required property int index
|
||||||
readonly property int wsId: wsModel.getWorkspaceIdAt(index)
|
readonly property int wsId: wsModel.getWorkspaceIdAt(index)
|
||||||
implicitWidth: root.vertical ? Appearance.sizes.verticalBarWidth : root.workspaceButtonWidth
|
implicitWidth: root.vertical ? root.barThickness : root.workspaceButtonWidth
|
||||||
implicitHeight: root.vertical ? root.workspaceButtonWidth : Appearance.sizes.barHeight
|
implicitHeight: root.vertical ? root.workspaceButtonWidth : root.barThickness
|
||||||
}
|
}
|
||||||
|
|
||||||
component NumberWorkspaceItem: WorkspaceItem {
|
component NumberWorkspaceItem: WorkspaceItem {
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
pragma ComponentBehavior: Bound
|
||||||
|
import QtQuick
|
||||||
|
|
||||||
|
Item {
|
||||||
|
visible: false
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ import QtQuick.Layouts
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
property bool borderless: Config.options.bar.borderless
|
|
||||||
property bool showDate: Config.options.bar.verbose
|
property bool showDate: Config.options.bar.verbose
|
||||||
implicitWidth: rowLayout.implicitWidth
|
implicitWidth: rowLayout.implicitWidth
|
||||||
implicitHeight: Appearance.sizes.barHeight
|
implicitHeight: Appearance.sizes.barHeight
|
||||||
|
|||||||
Reference in New Issue
Block a user