diff --git a/bar/Bar.qml b/bar/Bar.qml index 519f750..bfde55d 100644 --- a/bar/Bar.qml +++ b/bar/Bar.qml @@ -1,11 +1,11 @@ import QtQuick import QtQuick.Layouts import Quickshell +import Quickshell.Widgets import "battery" -import "control" as Control import "systray" as SysTray -import "notifications" as Notifications import "popups" as Popup +import "mpris" as Mpris import "../widgets" as Widgets import ".." @@ -27,83 +27,94 @@ PanelWindow { bar: root } - // Left RowLayout { - spacing: 10 + spacing: 0 anchors { - top: parent.top - left: parent.left - bottom: parent.bottom - leftMargin: 4 + fill: parent + leftMargin: 5 + rightMargin: 5 } - HyprWorkspaces { - screen: root.screen - Layout.fillWidth: false - Layout.preferredHeight: parent.height - Layout.leftMargin: 4 + // Left side of bar + Item { + Layout.fillWidth: true + Layout.fillHeight: true + + RowLayout { + spacing: 10 + anchors.fill: parent + + HyprWorkspaces { + screen: root.screen + Layout.fillHeight: true + Layout.leftMargin: 4 + } + + Widgets.Separator { + visible: activeWindow.visible + Layout.leftMargin: 5 + Layout.rightMargin: 5 + } + + ActiveWindow { + id: activeWindow + Layout.preferredWidth: 400 + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } + } } - Widgets.Separator { - visible: activeWindow.visible - Layout.leftMargin: 5 - Layout.rightMargin: 5 + // Center of bar + WrapperItem { + topMargin: 2 + bottomMargin: 2 + Layout.fillHeight: true + + Mpris.Button { + bar: root + } } - ActiveWindow { - id: activeWindow - Layout.preferredWidth: 400 - } - } + // Right side of bar + Item { + Layout.fillWidth: true + Layout.fillHeight: true - // Right - RowLayout { - spacing: 10 + RowLayout { + anchors.fill: parent - anchors { - top: parent.top - bottom: parent.bottom - right: parent.right - rightMargin: 4 - } + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } - SysTray.SysTray { - id: sysTray - popup: root.popup - } + SysTray.SysTray { + id: sysTray + popup: root.popup + Layout.fillHeight: true + } - // Notifications.NotificationButton { - // implicitSize: 16 - // bar: root - // } + BatteryIndicator { + id: batteryIndicator + popup: root.popup + Layout.fillHeight: true + } - // Text { - // text: "home" - // color: "white" - // font.family: "Material Symbols Rounded" - // renderType: Text.NativeRendering - // textFormat: Text.PlainText - // font.pointSize: 14 - // - // font.variableAxes: { - // "FILL": 0 - // } - // } + Widgets.Separator { + Layout.leftMargin: 5 + Layout.rightMargin: 5 + } - BatteryIndicator { - id: batteryIndicator - popup: root.popup - } - - Widgets.Separator { - Layout.leftMargin: 5 - Layout.rightMargin: 5 - } - - Clock { - id: clock - color: ShellSettings.colors["inverse_surface"] + Clock { + id: clock + color: ShellSettings.colors["inverse_surface"] + } + } } } } diff --git a/bar/Controller.qml b/bar/Controller.qml new file mode 100644 index 0000000..9724241 --- /dev/null +++ b/bar/Controller.qml @@ -0,0 +1,10 @@ +import Quickshell + +Variants { + model: Quickshell.screens + + Bar { + required property var modelData + screen: modelData + } +} diff --git a/bar/HyprWorkspaces.qml b/bar/HyprWorkspaces.qml index 761b195..ee70c79 100644 --- a/bar/HyprWorkspaces.qml +++ b/bar/HyprWorkspaces.qml @@ -8,15 +8,15 @@ RowLayout { spacing: 6 visible: Hyprland.monitors.values.length != 0 - required property var screen + required property var screen Repeater { + id: workspaceButtons + model: ScriptModel { values: Hyprland.workspaces.values.slice().filter( workspace => workspace.monitor === Hyprland.monitorFor(screen) - ).sort((a,b) => { - return a.id - b.id; - }); + ) } Rectangle { @@ -26,7 +26,7 @@ RowLayout { Layout.alignment: Qt.AlignVCenter Layout.preferredHeight: 12 Layout.preferredWidth: { - if (Hyprland.focusedMonitor.activeWorkspace.id == modelData.id) + if (Hyprland.focusedMonitor?.activeWorkspace?.id === modelData?.id) return 25; return 12; @@ -40,7 +40,7 @@ RowLayout { if (workspaceButton.containsMouse) { value = ShellSettings.colors["on_primary"]; - } else if (Hyprland.focusedMonitor.activeWorkspace.id == modelData.id) { + } else if (Hyprland.focusedMonitor.activeWorkspace.id === modelData.id) { value = ShellSettings.colors["primary"]; } @@ -55,6 +55,13 @@ RowLayout { } } + Behavior on color { + ColorAnimation { + duration: 100 + easing.type: Easing.OutQuad + } + } + MouseArea { id: workspaceButton anchors.fill: parent diff --git a/bar/battery/BatteryIndicator.qml b/bar/battery/BatteryIndicator.qml index d2e97f5..0798823 100644 --- a/bar/battery/BatteryIndicator.qml +++ b/bar/battery/BatteryIndicator.qml @@ -10,8 +10,7 @@ import "../.." Item { id: root - implicitWidth: parent.height + 8 - implicitHeight: parent.height + implicitWidth: height + 8 // for margin visible: UPower.displayDevice.isLaptopBattery required property var popup diff --git a/bar/mpris/Button.qml b/bar/mpris/Button.qml new file mode 100644 index 0000000..b719923 --- /dev/null +++ b/bar/mpris/Button.qml @@ -0,0 +1,63 @@ +import Quickshell.Widgets +import QtQuick +import "../../mpris" as Mpris +import "../.." + +WrapperRectangle { + id: root + color: button.containsMouse ? ShellSettings.colors["primary"] : "transparent" + radius: 6 + leftMargin: 5 + rightMargin: 5 + + required property var bar + property var player: Mpris.Controller.trackedPlayer + + Text { + id: mediaInfo + text: root.player?.trackTitle ?? "" + color: button.containsMouse ? ShellSettings.colors["inverse_primary"] : ShellSettings.colors["inverse_surface"] + elide: Text.ElideRight + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + font.pointSize: 11 + anchors.verticalCenter: parent.verticalCenter + + MouseArea { + id: button + anchors.fill: parent + hoverEnabled: true + + onClicked: { + popup.visible = !popup.visible; + } + } + + WidgetWindow { + id: popup + visible: false + parentWindow: root.bar + + // anchor.window: root.bar + } + + // Item { + // id: menu + // visible: false + // implicitWidth: 250 + // implicitHeight: 80 + // } + + Behavior on color { + ColorAnimation { + duration: 100 + } + } + } + + Behavior on color { + ColorAnimation { + duration: 100 + } + } +} diff --git a/bar/mpris/WidgetWindow.qml b/bar/mpris/WidgetWindow.qml new file mode 100644 index 0000000..78126bd --- /dev/null +++ b/bar/mpris/WidgetWindow.qml @@ -0,0 +1,9 @@ +import Quickshell + +PopupWindow { + id: root + color: "red" + implicitWidth: 500 + implicitHeight: 500 + +} diff --git a/bar/popups/MenuWindow.qml b/bar/popups/MenuWindow.qml index abf2218..d7bb944 100644 --- a/bar/popups/MenuWindow.qml +++ b/bar/popups/MenuWindow.qml @@ -30,7 +30,6 @@ PopupWindow { property var content function set(item, content) { - // isOpen = false; root.item = item; root.content = content; popupContent.data = content; diff --git a/bar/systray/SysTray.qml b/bar/systray/SysTray.qml index 916af47..740e2e9 100644 --- a/bar/systray/SysTray.qml +++ b/bar/systray/SysTray.qml @@ -11,7 +11,6 @@ RowLayout { id: root spacing: 10 visible: SystemTray.items.values.length > 0 - implicitHeight: parent.height required property var popup @@ -20,8 +19,8 @@ RowLayout { delegate: Item { id: trayField - implicitHeight: parent.height - implicitWidth: trayContainer.width + Layout.preferredWidth: parent.height + Layout.fillHeight: true required property SystemTrayItem modelData MouseArea { @@ -79,14 +78,20 @@ RowLayout { id: trayContainer color: trayButton.containsMouse ? ShellSettings.colors["primary"] : "transparent" radius: width / 2 - implicitHeight: parent.height - 2 - implicitWidth: parent.height - 2 - anchors.centerIn: parent + implicitHeight: parent.height + implicitWidth: parent.height + + anchors { + fill: parent + margins: 1 + } IconImage { id: trayIcon source: { + // console.log(trayField.modelData.id); + switch (trayField.modelData.id) { case "obs": return "image://icon/obs-tray"; diff --git a/lockscreen/Controller.qml b/lockscreen/Controller.qml index d3ba238..b26e7ad 100644 --- a/lockscreen/Controller.qml +++ b/lockscreen/Controller.qml @@ -1,10 +1,11 @@ +pragma Singleton pragma ComponentBehavior: Bound import Quickshell import Quickshell.Io import Quickshell.Wayland -Scope { +Singleton { id: root PersistentProperties { @@ -38,4 +39,6 @@ Scope { } } } + + function init() {} } diff --git a/shell.qml b/shell.qml index f50189f..1372c45 100644 --- a/shell.qml +++ b/shell.qml @@ -14,35 +14,17 @@ import "wallpaper" as Wallpaper import "screencapture" as ScreenCapture ShellRoot { - // Singleton's that need to be loaded in some way + Bar.Controller {} + Wallpaper.Controller {} + Notifications.Controller {} + VolumeOSD.Controller {} + Component.onCompleted: { Launcher.Controller.init(); Settings.Controller.init(); ScreenCapture.Controller.init(); Mpris.Controller.init(); Notifications.NotificationCenter.init(); + LockScreen.Controller.init(); } - - // Elements that need context from all screens - Variants { - model: Quickshell.screens - - Scope { - id: scope - property var modelData - - Bar.Bar { - screen: scope.modelData - } - - LockScreen.Controller {} - } - } - - // On activation components - Notifications.Controller {} - VolumeOSD.Controller {} - - // this is an exception... - Wallpaper.Controller {} }