diff --git a/.config/quickshell/modules/bar/ActiveWindow.qml b/.config/quickshell/modules/bar/ActiveWindow.qml index 3a23182ac..e2ab07c91 100644 --- a/.config/quickshell/modules/bar/ActiveWindow.qml +++ b/.config/quickshell/modules/bar/ActiveWindow.qml @@ -5,7 +5,7 @@ import QtQuick.Layouts import Quickshell.Wayland import Quickshell.Hyprland -Rectangle { +Item { required property var bar readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) readonly property Toplevel activeWindow: ToplevelManager.activeToplevel @@ -13,7 +13,6 @@ Rectangle { height: parent.height width: colLayout.width - color: "transparent" Layout.leftMargin: Appearance.rounding.screenRounding diff --git a/.config/quickshell/modules/bar/Bar.qml b/.config/quickshell/modules/bar/Bar.qml index 3cb2ce7c8..a6d3b1ebb 100644 --- a/.config/quickshell/modules/bar/Bar.qml +++ b/.config/quickshell/modules/bar/Bar.qml @@ -1,4 +1,5 @@ import "../common" +import "../common/widgets" import QtQuick import QtQuick.Controls import QtQuick.Layouts @@ -30,8 +31,8 @@ Scope { ActiveWindow { bar: barRoot } - // Scroll to switch workspaces + // Scroll to change brightness WheelHandler { onWheel: (event) => { if (event.angleDelta.y < 0) @@ -100,6 +101,30 @@ Scope { // Right section RowLayout { anchors.right: parent.right + implicitHeight: barHeight + spacing: 20 + + SysTray { + bar: barRoot + } + + Item { // TODO make this wifi & bluetooth + Layout.leftMargin: Appearance.rounding.screenRounding + } + + // Scroll to change volume + WheelHandler { + onWheel: (event) => { + const currentVolume = Audio.sink?.audio.volume; + const step = currentVolume < 0.1 ? 0.01 : 0.02 || 0.2; + if (event.angleDelta.y < 0) + Audio.sink.audio.volume -= step; + else if (event.angleDelta.y > 0) + Audio.sink.audio.volume += step; + } + acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad + } + } anchors { diff --git a/.config/quickshell/modules/bar/Media.qml b/.config/quickshell/modules/bar/Media.qml index e681140ad..268ea1042 100644 --- a/.config/quickshell/modules/bar/Media.qml +++ b/.config/quickshell/modules/bar/Media.qml @@ -6,14 +6,13 @@ import Quickshell import Quickshell.Io import Quickshell.Services.Mpris -Rectangle { +Item { readonly property MprisPlayer activePlayer: MprisController.activePlayer readonly property string cleanedTitle: activePlayer?.trackTitle.replace(/【[^】]*】/, "") || "No media" Layout.fillHeight: true implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitHeight: 40 - color: "transparent" // Background Rectangle { diff --git a/.config/quickshell/modules/bar/Resource.qml b/.config/quickshell/modules/bar/Resource.qml index 3b7f83bfc..fd9a0b87a 100644 --- a/.config/quickshell/modules/bar/Resource.qml +++ b/.config/quickshell/modules/bar/Resource.qml @@ -5,14 +5,13 @@ import QtQuick.Layouts import Quickshell import Quickshell.Io -Rectangle { +Item { required property string iconName required property double percentage property bool shown: true clip: true implicitWidth: resourceRowLayout.x < 0 ? 0 : childrenRect.width implicitHeight: childrenRect.height - color: "transparent" RowLayout { spacing: 4 diff --git a/.config/quickshell/modules/bar/SysTray.qml b/.config/quickshell/modules/bar/SysTray.qml new file mode 100644 index 000000000..27d4e456e --- /dev/null +++ b/.config/quickshell/modules/bar/SysTray.qml @@ -0,0 +1,39 @@ +import "../common" +import "../common/widgets" +import QtQuick +import QtQuick.Layouts +import Quickshell.Hyprland +import Quickshell.Services.SystemTray +import Quickshell.Wayland +import Quickshell.Widgets + +Item { + id: root + + required property var bar + + height: parent.height + implicitWidth: rowLayout.implicitWidth + Layout.leftMargin: Appearance.rounding.screenRounding + + RowLayout { + id: rowLayout + + anchors.fill: parent + spacing: 15 + + Repeater { + model: SystemTray.items + + SysTrayItem { + required property SystemTrayItem modelData + + bar: root.bar + item: modelData + } + + } + + } + +} diff --git a/.config/quickshell/modules/bar/SysTrayItem.qml b/.config/quickshell/modules/bar/SysTrayItem.qml new file mode 100644 index 000000000..83eb267a5 --- /dev/null +++ b/.config/quickshell/modules/bar/SysTrayItem.qml @@ -0,0 +1,49 @@ +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Services.SystemTray +import Quickshell.Widgets + +MouseArea { + id: root + + required property var bar + required property SystemTrayItem item + property bool targetMenuOpen: false + property int trayItemWidth: 16 + + acceptedButtons: Qt.LeftButton | Qt.RightButton + Layout.fillHeight: true + implicitWidth: trayItemWidth + onClicked: (event) => { + switch (event.button) { + case Qt.LeftButton: + item.activate(); + break; + case Qt.RightButton: + item.hasMenu && menu.open(); + break; + default: + console.log("Buttonevent unhandled"); + } + } + + QsMenuAnchor { + id: menu + + menu: root.item.menu + anchor.window: bar + anchor.rect.x: root.x + bar.width + anchor.rect.y: root.y + anchor.rect.height: root.height * 3 + anchor.edges: Edges.Left | Edges.Bottom + } + + IconImage { + source: root.item.icon + anchors.centerIn: parent + width: parent.width + height: parent.height + } + +} diff --git a/.config/quickshell/modules/bar/Workspaces.qml b/.config/quickshell/modules/bar/Workspaces.qml index 1fd13c42c..1df21c8be 100644 --- a/.config/quickshell/modules/bar/Workspaces.qml +++ b/.config/quickshell/modules/bar/Workspaces.qml @@ -8,7 +8,7 @@ import Quickshell.Wayland import Quickshell.Hyprland import Quickshell.Io -Rectangle { +Item { required property var bar readonly property HyprlandMonitor monitor: Hyprland.monitorFor(bar.screen) readonly property Toplevel activeWindow: ToplevelManager.activeToplevel @@ -48,7 +48,6 @@ Rectangle { Layout.fillHeight: true implicitWidth: rowLayout.implicitWidth + rowLayout.spacing * 2 implicitHeight: 40 - color: "transparent" // Background Rectangle { @@ -176,8 +175,7 @@ Rectangle { } - background: Rectangle { - color: "transparent" // Transparent background + background: Item { implicitWidth: workspaceButtonWidth implicitHeight: workspaceButtonWidth } diff --git a/.config/quickshell/modules/common/Audio.qml b/.config/quickshell/modules/common/Audio.qml new file mode 100644 index 000000000..292efbf43 --- /dev/null +++ b/.config/quickshell/modules/common/Audio.qml @@ -0,0 +1,16 @@ +import QtQuick +import Quickshell +import Quickshell.Services.Pipewire +pragma Singleton + +Singleton { + id: root + + property var sink: Pipewire.defaultAudioSink + property var source: Pipewire.defaultAudioSource + + PwObjectTracker { + objects: [Pipewire.defaultAudioSink, Pipewire.defaultAudioSource] + } + +} diff --git a/.config/quickshell/shell.qml b/.config/quickshell/shell.qml index ceec43fd5..211e56d8d 100644 --- a/.config/quickshell/shell.qml +++ b/.config/quickshell/shell.qml @@ -1,3 +1,5 @@ +//@ pragma UseQApplication +//@ pragma IconTheme OneUI import QtQuick import QtQuick.Controls import QtQuick.Layouts