From e6b0bda07fd8cb704fe24a7ab2a6ae7d0465ce04 Mon Sep 17 00:00:00 2001 From: lucy Date: Sun, 8 Mar 2026 13:44:57 +0100 Subject: [PATCH] add basic functionality, mpris, workspaces and active window title --- Ws.qml | 50 +++++++++++++++++++++++++++++++++ modules/Bar/Bar.qml | 51 ++++++++++++++++++++++++++++------ modules/Bar/MPris.qml | 31 +++++++++++++++++++++ modules/Bar/Title.qml | 21 ++++++++++++++ settings/Settings.qml | 4 +-- {Widgets => widgets}/CIcon.qml | 0 {Widgets => widgets}/CText.qml | 1 - 7 files changed, 147 insertions(+), 11 deletions(-) create mode 100644 Ws.qml create mode 100644 modules/Bar/MPris.qml create mode 100644 modules/Bar/Title.qml rename {Widgets => widgets}/CIcon.qml (100%) rename {Widgets => widgets}/CText.qml (90%) diff --git a/Ws.qml b/Ws.qml new file mode 100644 index 0000000..96c07c1 --- /dev/null +++ b/Ws.qml @@ -0,0 +1,50 @@ +pragma ComponentBehavior: Bound +import Quickshell +import Quickshell.Hyprland +import QtQuick +import QtQuick.Layouts +import qs +import qs.settings +import qs.widgets + +Rectangle { + id: wsWrap + required property ShellScreen barScreen + color: ThemeLoader.colors.base03 + radius: Settings.config.rounding + implicitWidth: wsLayout.implicitWidth + 6 + implicitHeight: wsLayout.implicitHeight + 6 + RowLayout { + id: wsLayout + spacing: 0 + anchors.centerIn: parent + Repeater { + id: wsRep + model: Hyprland.workspaces + delegate: Rectangle { + id: wsRect + implicitWidth: Settings.config.barHeight / 2 + implicitHeight: Settings.config.barHeight / 2 + visible: modelData.monitor?.name == wsWrap.barScreen.name + required property var modelData + color: modelData.focused ? ThemeLoader.colors.base05 : ThemeLoader.colors.base03 + radius: Settings.config.rounding + CText { + id: wsText + anchors.centerIn: parent + text: wsRect.modelData.id + color: parent.modelData.focused ? ThemeLoader.colors.base00 : ThemeLoader.colors.base05 + } + MouseArea { + id: mouseHandler + acceptedButtons: Qt.LeftButton + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: { + wsRect.modelData.activate(); + } + } + } + } + } +} diff --git a/modules/Bar/Bar.qml b/modules/Bar/Bar.qml index 994026d..1b80b0e 100644 --- a/modules/Bar/Bar.qml +++ b/modules/Bar/Bar.qml @@ -1,15 +1,50 @@ import Quickshell import QtQuick +import QtQuick.Layouts import qs.settings import qs -PanelWindow { - id: root - anchors { - top: true - left: true - right: true +Variants { + model: Quickshell.screens + delegate: PanelWindow { + required property ShellScreen modelData + screen: modelData + id: root + anchors { + top: true + left: true + right: true + } + implicitHeight: Settings.config.barHeight + color: "transparent" + Rectangle { + id: bar + anchors.fill: parent + color: ThemeLoader.colors.base00 + RowLayout { + id: left + anchors.leftMargin: 10 + anchors { + left: parent.left + verticalCenter: parent.verticalCenter + } + Ws {barScreen: root.modelData} + MPris {} + } + RowLayout { + id: center + anchors { + centerIn: parent + } + Title {} + } + RowLayout { + id: right + anchors { + right: parent.right + verticalCenter: parent.verticalCenter + } + } + } } - implicitHeight: Settings.config.barHeight - color: ThemeLoader.colors.base00 } diff --git a/modules/Bar/MPris.qml b/modules/Bar/MPris.qml new file mode 100644 index 0000000..e0ba464 --- /dev/null +++ b/modules/Bar/MPris.qml @@ -0,0 +1,31 @@ +import Quickshell +import Quickshell.Services.Mpris +import QtQuick +import QtQuick.Layouts +import qs +import qs.settings +import qs.widgets + +Rectangle { + id: root + color: ThemeLoader.colors.base03 + implicitWidth: playingSong.implicitWidth + 14 + implicitHeight: Settings.config.barHeight / 2 + 6 + radius: Settings.config.rounding + property var spotify: root.getSpotify() + + function getSpotify() { + for (var i = 0; i < Mpris.players.values.length; i++) { + console.log(Mpris.players.values[i].identity); + if (Mpris.players.values[i].identity == "spotify" || "Spotify") { + return Mpris.players.values[i]; + } + } + return null; + } + CText { + id: playingSong + anchors.centerIn: parent + text: root.spotify.trackTitle + " - " + root.spotify.trackArtist + } +} diff --git a/modules/Bar/Title.qml b/modules/Bar/Title.qml new file mode 100644 index 0000000..1c6d7bf --- /dev/null +++ b/modules/Bar/Title.qml @@ -0,0 +1,21 @@ +import Quickshell +import Quickshell.Wayland +import QtQuick +import qs +import qs.widgets +import qs.settings + +Rectangle { + id: root + property var activeWindow: ToplevelManager.activeToplevel + property bool active: activeWindow ? activeWindow.activated ? true : false : false + radius: Settings.config.rounding + color: active ? ThemeLoader.colors.base03 : "transparent" + implicitHeight: Settings.config.barHeight / 2 + 6 + implicitWidth: titleText.implicitWidth + 14 + CText { + anchors.centerIn: parent + id: titleText + text: root.activeWindow ? root.activeWindow.activated ? root.activeWindow.title : "" : "" + } +} diff --git a/settings/Settings.qml b/settings/Settings.qml index 1ba1048..b425699 100644 --- a/settings/Settings.qml +++ b/settings/Settings.qml @@ -13,10 +13,10 @@ Singleton { adapter: JsonAdapter { id: settingsAdapter property int barHeight: 40 - property int rounding + property int rounding: 16 property bool floating property string font - property string fontSize + property int fontSize: 14 } } } diff --git a/Widgets/CIcon.qml b/widgets/CIcon.qml similarity index 100% rename from Widgets/CIcon.qml rename to widgets/CIcon.qml diff --git a/Widgets/CText.qml b/widgets/CText.qml similarity index 90% rename from Widgets/CText.qml rename to widgets/CText.qml index 8a2648b..bc20ca7 100644 --- a/Widgets/CText.qml +++ b/widgets/CText.qml @@ -1,4 +1,3 @@ -import Quickshell import QtQuick import qs import qs.settings