diff --git a/Modules/Dock/Dock.qml b/Modules/Dock/Dock.qml index 53937d19..731686d5 100644 --- a/Modules/Dock/Dock.qml +++ b/Modules/Dock/Dock.qml @@ -110,81 +110,30 @@ Variants { item: dockMouseArea } - Rectangle { - id: appTooltip - z: 1000 - - property var hoveredButton: { - if (!dockApps.children[0]) { - return null - } - const layoutItem = dockApps.children[0] - const flowLayout = layoutItem.children[0] - let repeater = null - for (var i = 0; i < flowLayout.children.length; i++) { - const child = flowLayout.children[i] - if (child && typeof child.count !== "undefined" && typeof child.itemAt === "function") { - repeater = child - break - } - } - if (!repeater || !repeater.itemAt) { - return null - } - for (var i = 0; i < repeater.count; i++) { - const item = repeater.itemAt(i) - if (item && item.dockButton && item.dockButton.showTooltip) { - return item.dockButton - } - } + property var hoveredButton: { + if (!dockApps.children[0]) { return null } - - property string tooltipText: hoveredButton ? hoveredButton.tooltipText : "" - - visible: hoveredButton !== null && tooltipText !== "" - width: px(tooltipLabel.implicitWidth + 24) - height: px(tooltipLabel.implicitHeight + 12) - - color: Theme.surfaceContainer - radius: Theme.cornerRadius - border.width: 1 - border.color: Theme.outlineMedium - - x: { - if (!hoveredButton) return 0 - const buttonPos = hoveredButton.mapToItem(dock.contentItem, 0, 0) - if (!dock.isVertical) { - return buttonPos.x + hoveredButton.width / 2 - width / 2 - } else { - if (SettingsData.dockPosition === SettingsData.Position.Right) { - return buttonPos.x - width - Theme.spacingS - } else { - return buttonPos.x + hoveredButton.width + Theme.spacingS - } + const layoutItem = dockApps.children[0] + const flowLayout = layoutItem.children[0] + let repeater = null + for (var i = 0; i < flowLayout.children.length; i++) { + const child = flowLayout.children[i] + if (child && typeof child.count !== "undefined" && typeof child.itemAt === "function") { + repeater = child + break } } - y: { - if (!hoveredButton) return 0 - const buttonPos = hoveredButton.mapToItem(dock.contentItem, 0, 0) - if (!dock.isVertical) { - if (SettingsData.dockPosition === SettingsData.Position.Bottom) { - return buttonPos.y - height - Theme.spacingS - } else { - return buttonPos.y + hoveredButton.height + Theme.spacingS - } - } else { - return buttonPos.y + hoveredButton.height / 2 - height / 2 + if (!repeater || !repeater.itemAt) { + return null + } + for (var i = 0; i < repeater.count; i++) { + const item = repeater.itemAt(i) + if (item && item.dockButton && item.dockButton.showTooltip) { + return item.dockButton } } - - StyledText { - id: tooltipLabel - anchors.centerIn: parent - text: appTooltip.tooltipText - font.pixelSize: Theme.fontSizeSmall - color: Theme.surfaceText - } + return null } Item { @@ -256,6 +205,62 @@ Variants { id: dockContainer anchors.fill: parent + Item { + id: appTooltip + z: 1000 + anchors.fill: parent + + property string tooltipText: dock.hoveredButton ? dock.hoveredButton.tooltipText : "" + property bool shouldShow: dock.hoveredButton !== null && tooltipText !== "" && dock.reveal && !slideXAnimation.running && !slideYAnimation.running + + Rectangle { + id: tooltipBackground + width: tooltipLabel.contentWidth + 24 + height: tooltipLabel.contentHeight + 12 + + visible: appTooltip.shouldShow && tooltipLabel.contentWidth > 0 + color: Theme.surfaceContainer + radius: Theme.cornerRadius + border.width: 1 + border.color: Theme.outlineMedium + + x: { + if (!dock.hoveredButton || !visible) return 0 + const buttonPos = dock.hoveredButton.mapToItem(dockContainer, 0, 0) + if (!dock.isVertical) { + return buttonPos.x + dock.hoveredButton.width / 2 - width / 2 + } else { + if (SettingsData.dockPosition === SettingsData.Position.Right) { + return buttonPos.x - width - Theme.spacingS + } else { + return buttonPos.x + dock.hoveredButton.width + Theme.spacingS + } + } + } + y: { + if (!dock.hoveredButton || !visible) return 0 + const buttonPos = dock.hoveredButton.mapToItem(dockContainer, 0, 0) + if (!dock.isVertical) { + if (SettingsData.dockPosition === SettingsData.Position.Bottom) { + return buttonPos.y - height - Theme.spacingS + } else { + return buttonPos.y + dock.hoveredButton.height + Theme.spacingS + } + } else { + return buttonPos.y + dock.hoveredButton.height / 2 - height / 2 + } + } + + StyledText { + id: tooltipLabel + anchors.centerIn: parent + text: appTooltip.tooltipText + font.pixelSize: Theme.fontSizeSmall + color: Theme.surfaceText + } + } + } + transform: Translate { id: dockSlide x: { @@ -281,6 +286,7 @@ Variants { Behavior on x { NumberAnimation { + id: slideXAnimation duration: 200 easing.type: Easing.OutCubic } @@ -288,6 +294,7 @@ Variants { Behavior on y { NumberAnimation { + id: slideYAnimation duration: 200 easing.type: Easing.OutCubic } @@ -344,6 +351,7 @@ Variants { contextMenu: dockVariants.contextMenu groupByApp: dock.groupByApp isVertical: dock.isVertical + dockScreen: dock.screen } } } diff --git a/Modules/Dock/DockAppButton.qml b/Modules/Dock/DockAppButton.qml index fdb49114..781d3711 100644 --- a/Modules/Dock/DockAppButton.qml +++ b/Modules/Dock/DockAppButton.qml @@ -15,6 +15,7 @@ Item { property var contextMenu: null property var dockApps: null property int index: -1 + property var parentDockScreen: null property bool longPressing: false property bool dragging: false property point dragStartPos: Qt.point(0, 0) @@ -317,7 +318,7 @@ Item { } } else { if (contextMenu) { - contextMenu.showForButton(root, appData, 65, true, cachedDesktopEntry) + contextMenu.showForButton(root, appData, 65, true, cachedDesktopEntry, parentDockScreen) } } } @@ -334,7 +335,7 @@ Item { } } else if (appData && appData.type === "grouped") { if (contextMenu) { - contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry) + contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry, parentDockScreen) } } else if (appData && appData.appId) { const desktopEntry = cachedDesktopEntry @@ -351,7 +352,7 @@ Item { } } else if (mouse.button === Qt.RightButton) { if (contextMenu && appData) { - contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry) + contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry, parentDockScreen) } else { console.warn("No context menu or appData available") } diff --git a/Modules/Dock/DockApps.qml b/Modules/Dock/DockApps.qml index 092bf946..5680c4b8 100644 --- a/Modules/Dock/DockApps.qml +++ b/Modules/Dock/DockApps.qml @@ -14,6 +14,7 @@ Item { property int pinnedAppCount: 0 property bool groupByApp: false property bool isVertical: false + property var dockScreen: null implicitWidth: isVertical ? appLayout.height : appLayout.width implicitHeight: isVertical ? appLayout.width : appLayout.height @@ -217,6 +218,7 @@ Item { contextMenu: root.contextMenu dockApps: root index: model.index + parentDockScreen: root.dockScreen // Override tooltip for windows to show window title showWindowTitle: model.type === "window" || model.type === "grouped" diff --git a/Modules/Dock/DockContextMenu.qml b/Modules/Dock/DockContextMenu.qml index 636af430..fbc9ca0b 100644 --- a/Modules/Dock/DockContextMenu.qml +++ b/Modules/Dock/DockContextMenu.qml @@ -17,22 +17,15 @@ PanelWindow { property bool hidePin: false property var desktopEntry: null - function showForButton(button, data, dockHeight, hidePinOption, entry) { + function showForButton(button, data, dockHeight, hidePinOption, entry, dockScreen) { anchorItem = button appData = data dockVisibleHeight = dockHeight || 40 hidePin = hidePinOption || false desktopEntry = entry || null - const dockWindow = button.Window.window - if (dockWindow) { - for (var i = 0; i < Quickshell.screens.length; i++) { - const s = Quickshell.screens[i] - if (dockWindow.x >= s.x && dockWindow.x < s.x + s.width) { - root.screen = s - break - } - } + if (dockScreen) { + root.screen = dockScreen } showContextMenu = true