From 4d731c5a6508a1fa94bff2fd7736c599c1fb389b Mon Sep 17 00:00:00 2001 From: zach Date: Thu, 2 Jul 2026 11:33:43 +0200 Subject: [PATCH] feat: add option for recoloring tray icons + show popout on hover --- Config/BarConfig.qml | 2 ++ Drawers/Interactions.qml | 2 +- Drawers/Windows.qml | 2 +- Modules/Bar/Bar.qml | 17 ++-------------- Modules/Settings/Pages/Panels/Bar/BarTray.qml | 20 ++++++++++++++++++- Modules/SysTray/TrayItem.qml | 9 +++++---- Modules/SysTray/TrayWidget.qml | 6 +++--- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Config/BarConfig.qml b/Config/BarConfig.qml index 55a3d35..1219a17 100644 --- a/Config/BarConfig.qml +++ b/Config/BarConfig.qml @@ -72,10 +72,12 @@ JsonObject { property bool upower: true } component Tray: JsonObject { + property bool recolorIcons: false property bool showAudio: true property bool showBluetooth: false property bool showMicrophone: true property bool showNetwork: false + property bool showOnHover: false property bool showPower: true property bool showWifi: false property int trayIconSize: 24 diff --git a/Drawers/Interactions.qml b/Drawers/Interactions.qml index 363ab4e..3fd7ee2 100644 --- a/Drawers/Interactions.qml +++ b/Drawers/Interactions.qml @@ -170,7 +170,7 @@ Item { root.panels.osd.hovered = false; } - if (!root.popouts.currentName.startsWith("traymenu")) { + if (!root.popouts.currentName.startsWith("traymenu") || Config.bar.tray.showOnHover) { root.popouts.hasCurrent = false; } diff --git a/Drawers/Windows.qml b/Drawers/Windows.qml index 6d6842e..2be2e04 100644 --- a/Drawers/Windows.qml +++ b/Drawers/Windows.qml @@ -127,7 +127,7 @@ CustomWindow { HyprlandFocusGrab { id: focusGrab - active: visibilities.dock || visibilities.resources || visibilities.launcher || visibilities.sidebar || visibilities.dashboard || visibilities.settings || visibilities.clipboard || (panels.popouts.hasCurrent && panels.popouts.currentName.startsWith("traymenu")) + active: visibilities.dock || visibilities.resources || visibilities.launcher || visibilities.sidebar || visibilities.dashboard || visibilities.settings || visibilities.clipboard || (panels.popouts.hasCurrent && panels.popouts.currentName.startsWith("traymenu") && !Config.bar.tray.showOnHover) windows: [root] onCleared: { diff --git a/Modules/Bar/Bar.qml b/Modules/Bar/Bar.qml index 6c3550b..18bfc1f 100644 --- a/Modules/Bar/Bar.qml +++ b/Modules/Bar/Bar.qml @@ -48,7 +48,7 @@ RowLayout { return; } - if (!popouts.currentName.startsWith("traymenu")) + if (!popouts.currentName.startsWith("traymenu") || Config.bar.tray.showOnHover) popouts.hasCurrent = false; } @@ -57,19 +57,7 @@ RowLayout { const item = ch.item; const itemWidth = item.implicitWidth; - if (id === "audio" && Config.bar.popouts.audio) { - popouts.currentName = "audio"; - popouts.currentCenter = Qt.binding(() => item.mapToItem(root, itemWidth / 2, 0).x); - popouts.hasCurrent = true; - } else if (id === "network" && Config.bar.popouts.network) { - popouts.currentName = "network"; - popouts.currentCenter = Qt.binding(() => item.mapToItem(root, itemWidth / 2, 0).x); - popouts.hasCurrent = true; - } else if (id === "upower" && Config.bar.popouts.upower) { - popouts.currentName = "upower"; - popouts.currentCenter = Qt.binding(() => item.mapToItem(root, itemWidth / 2, 0).x); - popouts.hasCurrent = true; - } else if (id === "updates") { + if (id === "updates") { popouts.currentName = "updates"; popouts.currentCenter = Qt.binding(() => item.mapToItem(root, itemWidth / 2, 0).x); popouts.hasCurrent = true; @@ -81,7 +69,6 @@ RowLayout { Repeater { id: repeater - // model: Config.bar.entries.filted(n => n.index > 50).sort(n => n.index) model: Config.bar.entries DelegateChooser { diff --git a/Modules/Settings/Pages/Panels/Bar/BarTray.qml b/Modules/Settings/Pages/Panels/Bar/BarTray.qml index 2fe962c..023640d 100644 --- a/Modules/Settings/Pages/Panels/Bar/BarTray.qml +++ b/Modules/Settings/Pages/Panels/Bar/BarTray.qml @@ -19,7 +19,6 @@ PageBase { SpinRow { first: true from: 12 - last: true settingAnchor: "bar-tray-iconsize" stepSize: 1 text: qsTr("Icon size") @@ -28,5 +27,24 @@ PageBase { onMoved: value => Config.bar.tray.trayIconSize = value } + + ToggleRow { + checked: Config.bar.tray.showOnHover + settingAnchor: "bar-tray-show-popout-on-hover" + subtext: Config.bar.tray.showOnHover ? qsTr("Will show context menu on hover") : qsTr("Will show context menu on right-click") + text: qsTr("Show popout on hover") + + onToggled: Config.bar.tray.showOnHover = checked + } + + ToggleRow { + checked: Config.bar.tray.recolorIcons + last: true + settingAnchor: "bar-tray-recolor-icons" + subtext: qsTr("Recolors icons to fit current scheme") + text: qsTr("Recolor icons") + + onToggled: Config.bar.tray.recolorIcons = checked + } } } diff --git a/Modules/SysTray/TrayItem.qml b/Modules/SysTray/TrayItem.qml index c0f80bc..dc017c4 100644 --- a/Modules/SysTray/TrayItem.qml +++ b/Modules/SysTray/TrayItem.qml @@ -45,7 +45,8 @@ Item { CustomRect { anchors.fill: parent anchors.margins: 3 - color: icon.layer.enabled && root.current ? DynamicColors.palette.m3primary : "transparent" + color: icon.layer.enabled && enabled && root.current ? DynamicColors.palette.m3primary : "transparent" + enabled: !Config.bar.tray.showOnHover radius: Appearance.rounding.full StateLayer { @@ -57,7 +58,7 @@ Item { if (mouse.button === Qt.LeftButton) { root.item.activate(); console.log(icon.source + "\n" + root.item.id); - } else if (mouse.button === Qt.RightButton && Config.bar.popouts.tray) { + } else if (mouse.button === Qt.RightButton && Config.bar.popouts.tray && !Config.bar.tray.showOnHover) { root.popouts.currentName = `traymenu${root.ind}`; root.popouts.currentCenter = Qt.binding(() => root.mapToItem(root.loader, root.implicitWidth / 2, 0).x); root.popouts.hasCurrent = true; @@ -76,9 +77,9 @@ Item { anchors.centerIn: parent antialiasing: true - color: root.current ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface + color: root.current && !Config.bar.tray.showOnHover ? DynamicColors.palette.m3onPrimary : DynamicColors.palette.m3onSurface implicitSize: Config.bar.tray.trayIconSize * root.dpr - layer.enabled: Config.general.color.smart || Config.general.color.scheduleDark + layer.enabled: Config.bar.tray.recolorIcons scale: 1 / root.dpr source: root.resolveIcon(root.item.id, root.item.icon) } diff --git a/Modules/SysTray/TrayWidget.qml b/Modules/SysTray/TrayWidget.qml index 1fdf5dc..f4be726 100644 --- a/Modules/SysTray/TrayWidget.qml +++ b/Modules/SysTray/TrayWidget.qml @@ -61,12 +61,12 @@ RowLayout { } let trayPos = mapToItem(sysTray, localX, localY); - if (sysTray.contains(Qt.point(trayPos.x, trayPos.y))) { + if (Config.bar.tray.showOnHover && sysTray.contains(Qt.point(trayPos.x, trayPos.y))) { let trayRowPos = sysTray.mapToItem(sysRow, trayPos.x, trayPos.y); let child = sysRow.childAt(trayRowPos.x, trayRowPos.y); - if (child && child.hasOwnProperty("popoutId")) { + if (child && child.hasOwnProperty("ind")) { return { - id: child.popoutId, + id: `traymenu${child.ind}`, item: child }; }