multi-bar: removed all globals bar properties

This commit is contained in:
ItsLemmy
2025-11-05 00:33:47 -05:00
parent 8c8ee2def3
commit 569a5ba8df
52 changed files with 532 additions and 438 deletions
+6 -4
View File
@@ -2,6 +2,7 @@ import QtQuick
import Quickshell
import Quickshell.Wayland
import qs.Commons
import qs.Services
/**
@@ -23,6 +24,7 @@ PanelWindow {
readonly property bool barFloating: monitorConfig.floating || false
readonly property real barMarginH: barFloating ? monitorConfig.marginHorizontal * Style.marginXL : 0
readonly property real barMarginV: barFloating ? monitorConfig.marginVertical * Style.marginXL : 0
readonly property real barHeight: BarService.getBarHeight(monitorConfig.density, barPosition)
// Invisible - just reserves space
color: "transparent"
@@ -49,9 +51,9 @@ PanelWindow {
// Vertical bar: reserve bar height + margin on the anchored edge only
if (barFloating) {
// For left bar, reserve left margin; for right bar, reserve right margin
return Style.barHeight + barMarginH
return barHeight + barMarginH
}
return Style.barHeight
return barHeight
}
return 0 // Auto-width when left/right anchors are true
}
@@ -61,9 +63,9 @@ PanelWindow {
// Horizontal bar: reserve bar height + margin on the anchored edge only
if (barFloating) {
// For top bar, reserve top margin; for bottom bar, reserve bottom margin
return Style.barHeight + barMarginV
return barHeight + barMarginV
}
return Style.barHeight
return barHeight
}
return 0 // Auto-height when top/bottom anchors are true
}
+3 -1
View File
@@ -19,7 +19,9 @@ Item {
property bool oppositeDirection: false
property bool hovered: false
readonly property string barPosition: Settings.data.bar.position
property string barPosition: "top" // Passed from parent widget
property string barDensity: "default" // Passed from parent
property bool barShowCapsule: true // Passed from parent
readonly property bool isVerticalBar: barPosition === "left" || barPosition === "right"
signal shown
+10 -6
View File
@@ -21,6 +21,10 @@ Item {
property bool oppositeDirection: false
property bool hovered: false
// Compute capsuleHeight based on density and screen
readonly property var _barConfig: screen ? Settings.getMonitorBarConfig(screen.name) : Settings.getDefaultBarConfig()
readonly property real capsuleHeight: BarService.getCapsuleHeight(density || _barConfig.density, _barConfig.position)
// Effective shown state (true if hovered/animated open or forced)
readonly property bool revealed: !forceClose && (forceOpen || showPill)
@@ -37,9 +41,9 @@ Item {
property bool showPill: false
property bool shouldAnimateHide: false
readonly property int pillHeight: Style.capsuleHeight
readonly property int pillPaddingHorizontal: Math.round(Style.capsuleHeight * 0.2)
readonly property int pillOverlap: Math.round(Style.capsuleHeight * 0.5)
readonly property int pillHeight: capsuleHeight
readonly property int pillPaddingHorizontal: Math.round(capsuleHeight * 0.2)
readonly property int pillOverlap: Math.round(capsuleHeight * 0.5)
readonly property int pillMaxWidth: Math.max(1, Math.round(textItem.implicitWidth + pillPaddingHorizontal * 2 + pillOverlap))
readonly property real iconSize: {
@@ -82,7 +86,7 @@ Item {
(iconCircle.x + iconCircle.width / 2) - width // Opens left
opacity: revealed ? Style.opacityFull : Style.opacityNone
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
color: barShowCapsule ? Color.mSurfaceVariant : Color.transparent
readonly property int halfPillHeight: Math.round(pillHeight * 0.5)
@@ -135,7 +139,7 @@ Item {
width: pillHeight
height: pillHeight
radius: width * 0.5
color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
color: hovered ? Color.mHover : barShowCapsule ? Color.mSurfaceVariant : Color.transparent
anchors.verticalCenter: parent.verticalCenter
x: oppositeDirection ? 0 : (parent.width - width)
@@ -243,7 +247,7 @@ Item {
onEntered: {
hovered = true
root.entered()
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(barPosition), Style.tooltipDelayLong)
if (forceClose) {
return
}
+9 -5
View File
@@ -20,7 +20,11 @@ Item {
property bool hovered: false
// Bar position detection for pill direction
readonly property string barPosition: Settings.data.bar.position
property string barPosition: "top" // Passed from parent widget
property string barDensity: "default" // Passed from parent
property bool barShowCapsule: true // Passed from parent
readonly property real barHeight: BarService.getBarHeight(barDensity, barPosition)
readonly property real capsuleHeight: BarService.getCapsuleHeight(barDensity, barPosition)
readonly property bool isVerticalBar: barPosition === "left" || barPosition === "right"
// Determine pill direction based on section position
@@ -44,7 +48,7 @@ Item {
property bool shouldAnimateHide: false
// Sizing logic for vertical bars
readonly property int buttonSize: Style.capsuleHeight
readonly property int buttonSize: capsuleHeight
readonly property int pillHeight: buttonSize
readonly property int pillPaddingVertical: 3 * 2 // Very precise adjustment don't replace by Style.margin
readonly property int pillOverlap: Math.round(buttonSize * 0.5)
@@ -93,7 +97,7 @@ Item {
y: openUpward ? (iconCircle.y + iconCircle.height / 2 - height) : (iconCircle.y + iconCircle.height / 2)
opacity: revealed ? Style.opacityFull : Style.opacityNone
color: Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
color: barShowCapsule ? Color.mSurfaceVariant : Color.transparent
readonly property int halfButtonSize: Math.round(buttonSize * 0.5)
@@ -156,7 +160,7 @@ Item {
width: buttonSize
height: buttonSize
radius: width * 0.5
color: hovered ? Color.mHover : Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent
color: hovered ? Color.mHover : barShowCapsule ? Color.mSurfaceVariant : Color.transparent
// Icon positioning based on direction
x: 0
@@ -282,7 +286,7 @@ Item {
onEntered: {
hovered = true
root.entered()
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(), Style.tooltipDelayLong)
TooltipService.show(Screen, pill, root.tooltipText, BarService.getTooltipDirection(barPosition), Style.tooltipDelayLong)
if (forceClose) {
return
}
+6 -5
View File
@@ -26,10 +26,9 @@ NPanel {
var _ = root.settingsVersion
if (widgetSection === "" || widgetIndex < 0)
return {}
var widgets = Settings.data.bar.widgets[widgetSection]
if (!widgets || widgetIndex >= widgets.length)
if (!screen)
return {}
var settings = widgets[widgetIndex]
var settings = Settings.getWidgetSettings(screen.name, widgetSection, widgetIndex)
if (!settings || settings.id !== "Tray")
return {}
return settings
@@ -69,7 +68,9 @@ NPanel {
})
readonly property int itemCount: trayValues.length
readonly property int maxColumns: 8
readonly property real cellSize: Math.round(Style.capsuleHeight * 0.65)
readonly property var _barConfig: screen ? Settings.getMonitorBarConfig(screen.name) : Settings.getDefaultBarConfig()
readonly property real capsuleHeight: BarService.getCapsuleHeight(_barConfig.density, _barConfig.position)
readonly property real cellSize: Math.round(capsuleHeight * 0.65)
readonly property real outerPadding: Style.marginM
readonly property real innerSpacing: Style.marginM
readonly property int columns: Math.max(1, Math.min(maxColumns, itemCount))
@@ -170,7 +171,7 @@ NPanel {
modelData?.scrollDown()
}
onEntered: TooltipService.show(Screen, trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection())
onEntered: TooltipService.show(Screen, trayIcon, modelData.tooltipTitle || modelData.name || modelData.id || "Tray Item", BarService.getTooltipDirection(barPosition))
onExited: TooltipService.hide()
}
}
+7 -24
View File
@@ -19,6 +19,7 @@ PopupWindow {
property var trayItem: null
property string widgetSection: ""
property int widgetIndex: -1
property string barPosition: "top" // Passed from Tray widget
readonly property int menuWidth: 240
@@ -216,7 +217,6 @@ PopupWindow {
let openLeft = false
// Check bar position first
const barPosition = Settings.data.bar.position
const globalPos = entry.mapToItem(null, 0, 0)
if (barPosition === "right") {
@@ -303,16 +303,13 @@ PopupWindow {
// Check if item is already a favorite
readonly property bool isFavorite: {
if (!root.trayItem || root.widgetSection === "" || root.widgetIndex < 0)
if (!root.trayItem || !root.screen || root.widgetSection === "" || root.widgetIndex < 0)
return false
const itemName = root.trayItem.tooltipTitle || root.trayItem.name || root.trayItem.id || ""
if (!itemName)
return false
var widgets = Settings.data.bar.widgets[root.widgetSection]
if (!widgets || root.widgetIndex >= widgets.length)
return false
var widgetSettings = widgets[root.widgetIndex]
var widgetSettings = Settings.getWidgetSettings(root.screen.name, root.widgetSection, root.widgetIndex)
if (!widgetSettings || widgetSettings.id !== "Tray")
return false
@@ -390,13 +387,7 @@ PopupWindow {
}
// Get current widget settings
var widgets = Settings.data.bar.widgets[widgetSection]
if (!widgets || widgetIndex >= widgets.length) {
Logger.w("TrayMenu", "Cannot add as favorite: invalid widget index")
return
}
var widgetSettings = widgets[widgetIndex]
var widgetSettings = Settings.getWidgetSettings(screen.name, widgetSection, widgetIndex)
if (!widgetSettings || widgetSettings.id !== "Tray") {
Logger.w("TrayMenu", "Cannot add as favorite: widget is not a Tray widget")
return
@@ -414,8 +405,7 @@ PopupWindow {
newSettings.favorites = newFavorites
// Update settings
widgets[widgetIndex] = newSettings
Settings.data.bar.widgets[widgetSection] = widgets
Settings.setWidgetSettings(screen.name, widgetSection, widgetIndex, newSettings)
Settings.saveImmediate()
Logger.i("TrayMenu", "Added", itemName, "as favorite")
@@ -443,13 +433,7 @@ PopupWindow {
}
// Get current widget settings
var widgets = Settings.data.bar.widgets[widgetSection]
if (!widgets || widgetIndex >= widgets.length) {
Logger.w("TrayMenu", "Cannot remove from favorites: invalid widget index")
return
}
var widgetSettings = widgets[widgetIndex]
var widgetSettings = Settings.getWidgetSettings(screen.name, widgetSection, widgetIndex)
if (!widgetSettings || widgetSettings.id !== "Tray") {
Logger.w("TrayMenu", "Cannot remove from favorites: widget is not a Tray widget")
return
@@ -471,8 +455,7 @@ PopupWindow {
newSettings.favorites = newFavorites
// Update settings
widgets[widgetIndex] = newSettings
Settings.data.bar.widgets[widgetSection] = widgets
Settings.setWidgetSettings(screen.name, widgetSection, widgetIndex, newSettings)
Settings.saveImmediate()
Logger.i("TrayMenu", "Removed", itemName, "from favorites")