From 0e4bdc7ed815ef389d9ca95fc4865f46701b1aaf Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Fri, 11 Jul 2025 21:49:53 +0800 Subject: activewindow --- bar/ActiveWindow.qml | 23 +++++++++++++++++++++++ bar/Bar.qml | 8 ++------ bar/Workspace.qml | 12 ++++++------ 3 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 bar/ActiveWindow.qml (limited to 'bar') diff --git a/bar/ActiveWindow.qml b/bar/ActiveWindow.qml new file mode 100644 index 0000000..efdbfd9 --- /dev/null +++ b/bar/ActiveWindow.qml @@ -0,0 +1,23 @@ +import QtQuick +import Quickshell +import Quickshell.Wayland +import Quickshell.Widgets +import qs.utils + +Item { + id: root + property var toplevel: ToplevelManager.activeToplevel + property var icon: Quickshell.iconPath(AppSearch.guessIcon(toplevel?.appId), "image-missing") + + IconImage { + source: root.icon + implicitWidth: 32 + implicitHeight: 32 + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 8 + } + Text { + text: root.toplevel?.title + } +} diff --git a/bar/Bar.qml b/bar/Bar.qml index 8bef666..0dc49f5 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -43,7 +43,7 @@ Scope { id: leftRow Layout.preferredWidth: 1 Layout.fillWidth: true - spacing: 40 + spacing: 0 // Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter Workspace { @@ -64,11 +64,7 @@ Scope { Layout.fillWidth: true Layout.fillHeight: true Layout.preferredWidth: 1 - Rectangle { - Layout.fillWidth: true - implicitHeight: 1 - color: "#000000" - } + ActiveWindow {} } RowLayout { id: rightRow diff --git a/bar/Workspace.qml b/bar/Workspace.qml index de63eba..04ad537 100644 --- a/bar/Workspace.qml +++ b/bar/Workspace.qml @@ -1,7 +1,7 @@ import QtQuick.Layouts import QtQuick import Quickshell -import qs.services +import Quickshell.Hyprland import qs.config Item { @@ -11,23 +11,23 @@ Item { function updateWorkspaceOccupied() { // workspaceOccupied = Array.from({ length: Config.options.bar.workspaces.shown }, (_, i) => { - // return SHyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1); + // return Hyprland.workspaces.values.some(ws => ws.id === workspaceGroup * Config.options.bar.workspaces.shown + i + 1); // }) workspaceOccupied = Array.from({ length: Bar.workspaces }, (_, i) => { - return SHyprland.workspaces.values.some(ws => ws.id === (i + 1)); + return Hyprland.workspaces.values.some(ws => ws?.id === (i + 1)); }); } function isActive(index: int): bool { - SHyprland.focusedWorkspace.id.toString() == (index + 1).toString(); + Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString(); } function isOccupied(index: int): bool { return workspaceOccupied[index] === true; } Connections { - target: SHyprland.workspaces + target: Hyprland.workspaces function onValuesChanged() { updateWorkspaceOccupied(); } @@ -47,7 +47,7 @@ Item { Rectangle { Text { - text: SHyprland.focusedWorkspace?.id.toString() == (index + 1).toString() + text: Hyprland.focusedWorkspace?.id.toString() == (index + 1).toString() // text: isActive(index) } implicitWidth: 10 -- cgit v1.2.3