diff options
Diffstat (limited to 'modules/bar')
| -rw-r--r-- | modules/bar/Bar.qml | 158 | ||||
| -rw-r--r-- | modules/bar/Content.qml | 174 | ||||
| -rw-r--r-- | modules/bar/components/workspaces/Workspaces.qml | 2 |
3 files changed, 145 insertions, 189 deletions
diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index 8860e47..914ee24 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -1,30 +1,158 @@ import "root:/widgets" +import "root:/services" import "root:/config" +import "components" +import "components/workspaces" import Quickshell import QtQuick -Variants { - model: Quickshell.screens +Item { + id: root - StyledWindow { - id: win + required property ShellScreen screen - required property ShellScreen modelData + function checkPopout(y: real): void { + const spacing = Appearance.spacing.small; + const aw = activeWindow.child; + const awy = activeWindow.y + aw.y; - screen: modelData - name: "bar" + const ty = tray.y; + const th = tray.implicitHeight; + const trayItems = tray.items; - implicitWidth: content.implicitWidth - exclusiveZone: content.implicitWidth + const n = statusIconsInner.network; + const ny = statusIcons.y + statusIconsInner.y + n.y - spacing / 2; - anchors.top: true - anchors.bottom: true - anchors.left: true + const bls = statusIcons.y + statusIconsInner.y + statusIconsInner.bs - spacing / 2; + const ble = statusIcons.y + statusIconsInner.y + statusIconsInner.be + spacing / 2; - Content { - id: content + const b = statusIconsInner.battery; + const by = statusIcons.y + statusIconsInner.y + b.y - spacing / 2; - screen: win.modelData + if (y >= awy && y <= awy + aw.implicitHeight) { + Popouts.currentName = "activewindow"; + Popouts.currentCenter = Qt.binding(() => activeWindow.y + aw.y + aw.implicitHeight / 2); + Popouts.hasCurrent = true; + } else if (y > ty && y < ty + th) { + const index = Math.floor(((y - ty) / th) * trayItems.count); + const item = trayItems.itemAt(index); + + Popouts.currentName = `traymenu${index}`; + Popouts.currentCenter = Qt.binding(() => tray.y + item.y + item.implicitHeight / 2); + Popouts.hasCurrent = true; + } else if (y >= ny && y <= ny + n.implicitHeight + spacing) { + Popouts.currentName = "network"; + Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + n.y + n.implicitHeight / 2); + Popouts.hasCurrent = true; + } else if (y >= bls && y <= ble) { + Popouts.currentName = "bluetooth"; + Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + statusIconsInner.bs + (statusIconsInner.be - statusIconsInner.bs) / 2); + Popouts.hasCurrent = true; + } else if (y >= by && y <= by + b.implicitHeight + spacing) { + Popouts.currentName = "battery"; + Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + b.y + b.implicitHeight / 2); + Popouts.hasCurrent = true; + } else { + Popouts.hasCurrent = false; + } + } + + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + + implicitWidth: child.implicitWidth + BorderConfig.thickness * 2 + + Item { + id: child + + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.horizontalCenter: parent.horizontalCenter + + implicitWidth: Math.max(osIcon.implicitWidth, workspaces.implicitWidth, activeWindow.implicitWidth, tray.implicitWidth, clock.implicitWidth, statusIcons.implicitWidth, power.implicitWidth) + + OsIcon { + id: osIcon + + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: parent.top + anchors.topMargin: Appearance.padding.large + } + + StyledClippingRect { + id: workspaces + + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: osIcon.bottom + anchors.topMargin: Appearance.spacing.normal + + radius: Appearance.rounding.full + color: Colours.palette.m3surfaceContainer + + implicitWidth: workspacesInner.implicitWidth + Appearance.padding.small * 2 + implicitHeight: workspacesInner.implicitHeight + Appearance.padding.small * 2 + + Workspaces { + id: workspacesInner + + anchors.centerIn: parent + } + } + + ActiveWindow { + id: activeWindow + + anchors.horizontalCenter: parent.horizontalCenter + anchors.top: workspaces.bottom + anchors.bottom: tray.top + anchors.margins: Appearance.spacing.large + + monitor: Brightness.getMonitorForScreen(root.screen) + } + + Tray { + id: tray + + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: clock.top + anchors.bottomMargin: Appearance.spacing.larger + } + + Clock { + id: clock + + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: statusIcons.top + anchors.bottomMargin: Appearance.spacing.normal + } + + StyledRect { + id: statusIcons + + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: power.top + anchors.bottomMargin: Appearance.spacing.normal + + radius: Appearance.rounding.full + color: Colours.palette.m3surfaceContainer + + implicitHeight: statusIconsInner.implicitHeight + Appearance.padding.normal * 2 + + StatusIcons { + id: statusIconsInner + + anchors.centerIn: parent + } + } + + Power { + id: power + + anchors.horizontalCenter: parent.horizontalCenter + anchors.bottom: parent.bottom + anchors.bottomMargin: Appearance.padding.large } } } diff --git a/modules/bar/Content.qml b/modules/bar/Content.qml deleted file mode 100644 index 54879fa..0000000 --- a/modules/bar/Content.qml +++ /dev/null @@ -1,174 +0,0 @@ -import "root:/widgets" -import "root:/services" -import "root:/config" -import "components" -import "components/workspaces" -import Quickshell -import QtQuick - -StyledRect { - id: root - - required property ShellScreen screen - - function checkPopout(y: real): var { - const spacing = Appearance.spacing.small; - const aw = activeWindow.child; - const awy = activeWindow.y + aw.y; - - const ty = tray.y; - const th = tray.implicitHeight; - const trayItems = tray.items; - - const n = statusIconsInner.network; - const ny = statusIcons.y + statusIconsInner.y + n.y - spacing / 2; - - const bls = statusIcons.y + statusIconsInner.y + statusIconsInner.bs - spacing / 2; - const ble = statusIcons.y + statusIconsInner.y + statusIconsInner.be + spacing / 2; - - const b = statusIconsInner.battery; - const by = statusIcons.y + statusIconsInner.y + b.y - spacing / 2; - - if (y >= awy && y <= awy + aw.implicitHeight) { - Popouts.currentName = "activewindow"; - Popouts.currentCenter = Qt.binding(() => activeWindow.y + aw.y + aw.implicitHeight / 2); - Popouts.hasCurrent = true; - } else if (y > ty && y < ty + th) { - const index = Math.floor(((y - ty) / th) * trayItems.count); - const item = trayItems.itemAt(index); - - Popouts.currentName = `traymenu${index}`; - Popouts.currentCenter = Qt.binding(() => tray.y + item.y + item.implicitHeight / 2); - Popouts.hasCurrent = true; - } else if (y >= ny && y <= ny + n.implicitHeight + spacing) { - Popouts.currentName = "network"; - Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + n.y + n.implicitHeight / 2); - Popouts.hasCurrent = true; - } else if (y >= bls && y <= ble) { - Popouts.currentName = "bluetooth"; - Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + statusIconsInner.bs + (statusIconsInner.be - statusIconsInner.bs) / 2); - Popouts.hasCurrent = true; - } else if (y >= by && y <= by + b.implicitHeight + spacing) { - Popouts.currentName = "battery"; - Popouts.currentCenter = Qt.binding(() => statusIcons.y + statusIconsInner.y + b.y + b.implicitHeight / 2); - Popouts.hasCurrent = true; - } else { - Popouts.hasCurrent = false; - } - } - - anchors.top: parent.top - anchors.bottom: parent.bottom - - implicitWidth: child.implicitWidth + BorderConfig.thickness - - color: BorderConfig.colour - - Component.onCompleted: Visibilities.bars[screen] = this - - MouseArea { - anchors.fill: parent - - hoverEnabled: true - - onPositionChanged: event => root.checkPopout(event.y) - - onContainsMouseChanged: { - if (!containsMouse) - Popouts.hasCurrent = false; - } - } - - Item { - id: child - - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.right: parent.right - - implicitWidth: Math.max(osIcon.implicitWidth, workspaces.implicitWidth, activeWindow.implicitWidth, tray.implicitWidth, clock.implicitWidth, statusIcons.implicitWidth, power.implicitWidth) - - OsIcon { - id: osIcon - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: parent.top - anchors.topMargin: Appearance.padding.large - } - - StyledClippingRect { - id: workspaces - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: osIcon.bottom - anchors.topMargin: Appearance.spacing.normal - - radius: Appearance.rounding.full - color: Colours.palette.m3surfaceContainer - - implicitWidth: workspacesInner.implicitWidth + Appearance.spacing.small - implicitHeight: workspacesInner.implicitHeight + Appearance.spacing.small * 2 - - Workspaces { - id: workspacesInner - - anchors.centerIn: parent - } - } - - ActiveWindow { - id: activeWindow - - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: workspaces.bottom - anchors.bottom: tray.top - anchors.margins: Appearance.spacing.large - - monitor: Brightness.getMonitorForScreen(root.screen) - } - - Tray { - id: tray - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: clock.top - anchors.bottomMargin: Appearance.spacing.larger - } - - Clock { - id: clock - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: statusIcons.top - anchors.bottomMargin: Appearance.spacing.normal - } - - StyledRect { - id: statusIcons - - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: power.top - anchors.bottomMargin: Appearance.spacing.normal - - radius: Appearance.rounding.full - color: Colours.palette.m3surfaceContainer - - implicitHeight: statusIconsInner.implicitHeight + Appearance.padding.normal * 2 - - StatusIcons { - id: statusIconsInner - - anchors.centerIn: parent - } - } - - Power { - id: power - - anchors.horizontalCenter: parent.horizontalCenter - anchors.bottom: parent.bottom - anchors.bottomMargin: Appearance.padding.large - } - } -} diff --git a/modules/bar/components/workspaces/Workspaces.qml b/modules/bar/components/workspaces/Workspaces.qml index 86392ec..8a1c49c 100644 --- a/modules/bar/components/workspaces/Workspaces.qml +++ b/modules/bar/components/workspaces/Workspaces.qml @@ -65,6 +65,8 @@ Item { MouseArea { anchors.fill: parent + anchors.leftMargin: -(Appearance.padding.small + BorderConfig.thickness) + anchors.rightMargin: -(Appearance.padding.small + BorderConfig.thickness) onPressed: event => { const ws = layout.childAt(event.x, event.y).index + root.groupOffset + 1; |