From 95faefa8eb49be829bb2e7b6b518ff248e65e500 Mon Sep 17 00:00:00 2001 From: ItsLemmy Date: Mon, 20 Oct 2025 21:56:59 -0400 Subject: [PATCH] Pill: cleanup - removed duality between disableOpen and forceClose - renamed rightOpen to oppositeDirection - wifi+bt: for vertical bar, use tooltip rather than the classic pill opening as text will most likely never fit. --- Modules/Bar/Extras/BarPill.qml | 9 +++------ Modules/Bar/Extras/BarPillHorizontal.qml | 23 +++++++++++------------ Modules/Bar/Extras/BarPillVertical.qml | 11 +++++------ Modules/Bar/Widgets/Battery.qml | 5 ++--- Modules/Bar/Widgets/Bluetooth.qml | 13 +++++++++---- Modules/Bar/Widgets/Brightness.qml | 2 +- Modules/Bar/Widgets/CustomButton.qml | 5 ++--- Modules/Bar/Widgets/KeyboardLayout.qml | 2 +- Modules/Bar/Widgets/Microphone.qml | 2 +- Modules/Bar/Widgets/Volume.qml | 2 +- Modules/Bar/Widgets/WiFi.qml | 13 +++++++++---- 11 files changed, 45 insertions(+), 42 deletions(-) diff --git a/Modules/Bar/Extras/BarPill.qml b/Modules/Bar/Extras/BarPill.qml index ba1601d3..aef33339 100644 --- a/Modules/Bar/Extras/BarPill.qml +++ b/Modules/Bar/Extras/BarPill.qml @@ -16,8 +16,7 @@ Item { property bool autoHide: false property bool forceOpen: false property bool forceClose: false - property bool disableOpen: false - property bool rightOpen: false + property bool oppositeDirection: false property bool hovered: false readonly property string barPosition: Settings.data.bar.position @@ -51,8 +50,7 @@ Item { autoHide: root.autoHide forceOpen: root.forceOpen forceClose: root.forceClose - disableOpen: root.disableOpen - rightOpen: root.rightOpen + oppositeDirection: root.oppositeDirection hovered: root.hovered density: root.density onShown: root.shown() @@ -76,8 +74,7 @@ Item { autoHide: root.autoHide forceOpen: root.forceOpen forceClose: root.forceClose - disableOpen: root.disableOpen - rightOpen: root.rightOpen + oppositeDirection: root.oppositeDirection hovered: root.hovered density: root.density onShown: root.shown() diff --git a/Modules/Bar/Extras/BarPillHorizontal.qml b/Modules/Bar/Extras/BarPillHorizontal.qml index 5a732263..e5e5ccda 100644 --- a/Modules/Bar/Extras/BarPillHorizontal.qml +++ b/Modules/Bar/Extras/BarPillHorizontal.qml @@ -18,8 +18,7 @@ Item { property bool autoHide: false property bool forceOpen: false property bool forceClose: false - property bool disableOpen: false - property bool rightOpen: false + property bool oppositeDirection: false property bool hovered: false // Effective shown state (true if hovered/animated open or forced) @@ -79,18 +78,18 @@ Item { width: revealed ? pillMaxWidth : 1 height: pillHeight - x: rightOpen ? (iconCircle.x + iconCircle.width / 2) : // Opens right - (iconCircle.x + iconCircle.width / 2) - width // Opens left + x: oppositeDirection ? (iconCircle.x + iconCircle.width / 2) : // Opens right + (iconCircle.x + iconCircle.width / 2) - width // Opens left opacity: revealed ? Style.opacityFull : Style.opacityNone color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent readonly property int halfPillHeight: Math.round(pillHeight * 0.5) - topLeftRadius: rightOpen ? 0 : halfPillHeight - bottomLeftRadius: rightOpen ? 0 : halfPillHeight - topRightRadius: rightOpen ? halfPillHeight : 0 - bottomRightRadius: rightOpen ? halfPillHeight : 0 + topLeftRadius: oppositeDirection ? 0 : halfPillHeight + bottomLeftRadius: oppositeDirection ? 0 : halfPillHeight + topRightRadius: oppositeDirection ? halfPillHeight : 0 + bottomRightRadius: oppositeDirection ? halfPillHeight : 0 anchors.verticalCenter: parent.verticalCenter NText { @@ -99,10 +98,10 @@ Item { x: { // Better text horizontal centering var centerX = (parent.width - width) / 2 - var offset = rightOpen ? Style.marginXS : -Style.marginXS + var offset = oppositeDirection ? Style.marginXS : -Style.marginXS if (forceOpen) { // If its force open, the icon disc background is the same color as the bg pill move text slightly - offset += rightOpen ? -Style.marginXXS : Style.marginXXS + offset += oppositeDirection ? -Style.marginXXS : Style.marginXXS } return centerX + offset } @@ -139,7 +138,7 @@ Item { color: hovered ? Color.mTertiary : Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent anchors.verticalCenter: parent.verticalCenter - x: rightOpen ? 0 : (parent.width - width) + x: oppositeDirection ? 0 : (parent.width - width) Behavior on color { ColorAnimation { @@ -245,7 +244,7 @@ Item { hovered = true root.entered() TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong) - if (disableOpen || forceClose) { + if (forceClose) { return } if (!forceOpen) { diff --git a/Modules/Bar/Extras/BarPillVertical.qml b/Modules/Bar/Extras/BarPillVertical.qml index 485d9732..fe94a534 100644 --- a/Modules/Bar/Extras/BarPillVertical.qml +++ b/Modules/Bar/Extras/BarPillVertical.qml @@ -16,8 +16,7 @@ Item { property bool autoHide: false property bool forceOpen: false property bool forceClose: false - property bool disableOpen: false - property bool rightOpen: false + property bool oppositeDirection: false property bool hovered: false // Bar position detection for pill direction @@ -25,8 +24,8 @@ Item { readonly property bool isVerticalBar: barPosition === "left" || barPosition === "right" // Determine pill direction based on section position - readonly property bool openDownward: rightOpen - readonly property bool openUpward: !rightOpen + readonly property bool openDownward: oppositeDirection + readonly property bool openUpward: !oppositeDirection // Effective shown state (true if animated open or forced, but not if force closed) readonly property bool revealed: !forceClose && (forceOpen || showPill) @@ -114,7 +113,7 @@ Item { var offset = openDownward ? Math.round(pillPaddingVertical * 0.75) : -Math.round(pillPaddingVertical * 0.75) if (forceOpen) { // If its force open, the icon disc background is the same color as the bg pill move text slightly - offset += rightOpen ? -Style.marginXXS : Style.marginXXS + offset += oppositeDirection ? -Style.marginXXS : Style.marginXXS } return offset } @@ -284,7 +283,7 @@ Item { hovered = true root.entered() TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong) - if (disableOpen || forceClose) { + if (forceClose) { return } if (!forceOpen) { diff --git a/Modules/Bar/Widgets/Battery.qml b/Modules/Bar/Widgets/Battery.qml index d29c817e..e19e564f 100644 --- a/Modules/Bar/Widgets/Battery.qml +++ b/Modules/Bar/Widgets/Battery.qml @@ -87,14 +87,13 @@ Item { id: pill density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: testMode ? BatteryService.getIcon(testPercent, testCharging, true) : BatteryService.getIcon(percent, charging, isReady) text: (isReady || testMode) ? Math.round(percent) : "-" suffix: "%" autoHide: false forceOpen: isReady && (testMode || battery.isLaptopBattery) && displayMode === "alwaysShow" - forceClose: displayMode === "alwaysHide" - disableOpen: (!isReady || (!testMode && !battery.isLaptopBattery)) + forceClose: displayMode === "alwaysHide" || !isReady || (!testMode && !battery.isLaptopBattery) onClicked: PanelService.getPanel("batteryPanel")?.toggle(this) tooltipText: { let lines = [] diff --git a/Modules/Bar/Widgets/Bluetooth.qml b/Modules/Bar/Widgets/Bluetooth.qml index e58d5e43..1c3fd2b0 100644 --- a/Modules/Bar/Widgets/Bluetooth.qml +++ b/Modules/Bar/Widgets/Bluetooth.qml @@ -36,7 +36,7 @@ Item { id: pill density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: BluetoothService.enabled ? "bluetooth" : "bluetooth-off" text: { if (BluetoothService.connectedDevices && BluetoothService.connectedDevices.length > 0) { @@ -52,10 +52,15 @@ Item { return "" } autoHide: false - forceOpen: root.displayMode === "alwaysShow" - forceClose: root.displayMode === "alwaysHide" || BluetoothService.connectedDevices.length === 0 + forceOpen: !isBarVertical && root.displayMode === "alwaysShow" + forceClose: isBarVertical || root.displayMode === "alwaysHide" || BluetoothService.connectedDevices.length === 0 onClicked: PanelService.getPanel("bluetoothPanel")?.toggle(this) onRightClicked: PanelService.getPanel("bluetoothPanel")?.toggle(this) - tooltipText: I18n.tr("tooltips.bluetooth-devices") + tooltipText: { + if (pill.text !== "") { + return pill.text + } + return I18n.tr("tooltips.bluetooth-devices") + } } } diff --git a/Modules/Bar/Widgets/Brightness.qml b/Modules/Bar/Widgets/Brightness.qml index 5c02e490..60efc609 100644 --- a/Modules/Bar/Widgets/Brightness.qml +++ b/Modules/Bar/Widgets/Brightness.qml @@ -77,7 +77,7 @@ Item { id: pill density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: getIcon() autoHide: false // Important to be false so we can hover as long as we want text: { diff --git a/Modules/Bar/Widgets/CustomButton.qml b/Modules/Bar/Widgets/CustomButton.qml index 4015c4f4..652d391a 100644 --- a/Modules/Bar/Widgets/CustomButton.qml +++ b/Modules/Bar/Widgets/CustomButton.qml @@ -45,14 +45,13 @@ Item { BarPill { id: pill - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: customIcon text: _dynamicText density: Settings.data.bar.density autoHide: false forceOpen: _dynamicText !== "" - forceClose: false - disableOpen: true + forceClose: true tooltipText: { if (!hasExec) { return "Custom button, configure in settings." diff --git a/Modules/Bar/Widgets/KeyboardLayout.qml b/Modules/Bar/Widgets/KeyboardLayout.qml index 6d597227..41ffd027 100644 --- a/Modules/Bar/Widgets/KeyboardLayout.qml +++ b/Modules/Bar/Widgets/KeyboardLayout.qml @@ -43,7 +43,7 @@ Item { anchors.verticalCenter: parent.verticalCenter density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: "keyboard" autoHide: false // Important to be false so we can hover as long as we want text: currentLayout.toUpperCase() diff --git a/Modules/Bar/Widgets/Microphone.qml b/Modules/Bar/Widgets/Microphone.qml index 86338210..6fe3d709 100644 --- a/Modules/Bar/Widgets/Microphone.qml +++ b/Modules/Bar/Widgets/Microphone.qml @@ -89,7 +89,7 @@ Item { BarPill { id: pill - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: getIcon() density: Settings.data.bar.density autoHide: false // Important to be false so we can hover as long as we want diff --git a/Modules/Bar/Widgets/Volume.qml b/Modules/Bar/Widgets/Volume.qml index 10018771..edf75b9d 100644 --- a/Modules/Bar/Widgets/Volume.qml +++ b/Modules/Bar/Widgets/Volume.qml @@ -75,7 +75,7 @@ Item { id: pill density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: getIcon() autoHide: false // Important to be false so we can hover as long as we want text: Math.round(AudioService.volume * 100) diff --git a/Modules/Bar/Widgets/WiFi.qml b/Modules/Bar/Widgets/WiFi.qml index 5a6a6901..25de98ae 100644 --- a/Modules/Bar/Widgets/WiFi.qml +++ b/Modules/Bar/Widgets/WiFi.qml @@ -36,7 +36,7 @@ Item { id: pill density: Settings.data.bar.density - rightOpen: BarService.getPillDirection(root) + oppositeDirection: BarService.getPillDirection(root) icon: { try { if (NetworkService.ethernetConnected) { @@ -74,10 +74,15 @@ Item { } } autoHide: false - forceOpen: root.displayMode === "alwaysShow" - forceClose: root.displayMode === "alwaysHide" || !pill.text + forceOpen: !isBarVertical && root.displayMode === "alwaysShow" + forceClose: isBarVertical || root.displayMode === "alwaysHide" || !pill.text onClicked: PanelService.getPanel("wifiPanel")?.toggle(this) onRightClicked: PanelService.getPanel("wifiPanel")?.toggle(this) - tooltipText: I18n.tr("tooltips.manage-wifi") + tooltipText: { + if (pill.text !== "") { + return pill.text + } + return I18n.tr("tooltips.manage-wifi") + } } }