summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-07-14 19:08:58 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-07-14 19:08:58 +0800
commita521a82030cdf0a89a62250b429209992f948824 (patch)
tree698e93af0cbe855737585b4bc0c48fec78175b9f
parent47c142bb3682a161c5f81bf0f9d0dece27ae924e (diff)
timedate: use 12hr
fuck u qt
-rw-r--r--bar/TimeDate.qml2
-rw-r--r--bar/Workspace.qml94
-rw-r--r--services/TimeDate.qml11
3 files changed, 88 insertions, 19 deletions
diff --git a/bar/TimeDate.qml b/bar/TimeDate.qml
index 1a952c7..fe6a5c0 100644
--- a/bar/TimeDate.qml
+++ b/bar/TimeDate.qml
@@ -28,7 +28,7 @@ Item {
Layout.fillWidth: true
}
anchors.fill: parent
- spacing: Bar.resourceIconTextSpacing
+ spacing: Bar.resourceIconTextSpacing / 2
Icon {
text: Icons.resource.clock
diff --git a/bar/Workspace.qml b/bar/Workspace.qml
index ccfcd57..e545b24 100644
--- a/bar/Workspace.qml
+++ b/bar/Workspace.qml
@@ -8,29 +8,45 @@ import qs.components
Item {
id: root
-
- // required property ShellScreen screen // multi monitor
property var ws: Hyprland.workspaces
-
- // readonly property HyprlandMonitor monitor: Hyprland.monitorFor(screen) // multi monitor
- // dont work no more for some reason
-
function getWorkspaceStats(index) {
const w = ws.values.find(i => i.id === index + 1);
return {
- isOccupied: w?.toplevels?.values?.length,
- isActive: w?.active,
- isUrgent: w?.urgent
+ isOccupied: Boolean(w?.toplevels?.values?.length),
+ isActive: Boolean(w?.active),
+ isUrgent: Boolean(w?.urgent)
};
}
-
implicitWidth: layout.implicitWidth
+ property int activeIndex: 0
+ property int prevIndex: 0
+
+ Rectangle {
+ id: activeRect
+ anchors.verticalCenter: parent.verticalCenter
+ height: Bar.workspaceIconSize - Bar.workspaceHorizontalSpacing
+ width: Bar.workspaceIconSize
+ radius: Bar.workspaceRounding
+ color: Colors.alt
+ opacity: Bar.workspaceActiveOpacity
+ Behavior on x {
+ NumberAnimation {
+ duration: Bar.workspaceAnimationTransition
+ easing.type: Easing.OutQuad
+ }
+ }
+ Behavior on width {
+ NumberAnimation {
+ duration: Bar.workspaceAnimationExpand
+ easing.type: Easing.OutQuad
+ }
+ }
+ }
RowLayout {
id: layout
implicitWidth: childrenRect.width
anchors.verticalCenter: parent.verticalCenter
-
spacing: Bar.workspaceSpacing
Repeater {
@@ -39,21 +55,65 @@ Item {
Rectangle {
id: workspaceRect
property var st: getWorkspaceStats(index)
+ property bool active: st.isActive
+ property bool shouldExpand: false
- implicitWidth: !st.isActive ? Bar.workspaceIconSize : Bar.workspaceActiveIconSize
+ implicitWidth: shouldExpand ? Bar.workspaceActiveIconSize : Bar.workspaceIconSize
implicitHeight: Bar.workspaceIconSize - Bar.workspaceHorizontalSpacing
radius: Bar.workspaceRounding
+
+ Behavior on implicitWidth {
+ NumberAnimation {
+ duration: shouldExpand ? Bar.workspaceAnimationExpand : Bar.workspaceAnimationShrink
+ easing.type: Easing.OutQuad
+ }
+ }
+
+ SequentialAnimation {
+ id: activeRectAnimation
+ PauseAnimation {
+ duration: Bar.workspaceAnimationTransition
+ }
+ ScriptAction {
+ script: {
+ activeRect.x = workspaceRect.x;
+ activeRect.width = Bar.workspaceActiveIconSize;
+ workspaceRect.shouldExpand = true;
+ }
+ }
+ }
+
+ Component.onCompleted: {
+ if (active) {
+ root.activeIndex = index;
+ root.prevIndex = index;
+ shouldExpand = true;
+ activeRect.x = x;
+ activeRect.width = Bar.workspaceActiveIconSize;
+ }
+ }
+
+ onActiveChanged: {
+ if (active) {
+ root.prevIndex = root.activeIndex;
+ root.activeIndex = index;
+ activeRect.width = Bar.workspaceIconSize;
+ layout.children[root.prevIndex].shouldExpand = false;
+ activeRect.x = layout.children[root.prevIndex].x;
+ activeRectAnimation.start();
+ }
+ }
+
Icon {
anchors.centerIn: parent
- text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent'] // TODO: urgent = red
+ text: !st.isUrgent ? Icons.ws[index + 1] : Icons.ws['urgent']
font.pixelSize: Bar.workspaceIconSize / 2
- color: Colors.foreground // TODO make IText w/ ts default color
- opacity: !st.isOccupied ? 0 : 1 // less contrast
- // opacity: isActive(index) ? Bar.workspaceActiveOpacity : isOccupied(index) ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity
+ color: Colors.foreground
+ opacity: st.isOccupied ? 1 : 0
}
color: st.isOccupied ? Colors.alt : Colors.foreground
- opacity: st.isActive && st.isOccupied ? Bar.workspaceActiveOpacity : st.isOccupied ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity
+ opacity: st.isOccupied ? Bar.workspaceOpacity : Bar.workspaceEmptyOpacity
}
}
}
diff --git a/services/TimeDate.qml b/services/TimeDate.qml
index ff9343b..9c5b8df 100644
--- a/services/TimeDate.qml
+++ b/services/TimeDate.qml
@@ -5,7 +5,16 @@ import QtQuick
Singleton {
id: root
- readonly property string time: Qt.formatDateTime(clock.date, "hh:mm:ss")
+ readonly property string time: {
+ // fuck you qt give me my 12 hr time
+ var h = clock.date.getHours();
+ var m = clock.date.getMinutes();
+ var s = clock.date.getSeconds();
+ h = h % 12;
+ if (h === 0)
+ h = 12;
+ return (h < 10 ? "0" : "") + h + ":" + (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
+ }
readonly property string date: Qt.formatDateTime(clock.date, "dddd dd/MM")
SystemClock {