mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-18 09:05:24 -04:00
widgets: fix tooltip position mapping
This commit is contained in:
@@ -933,19 +933,17 @@ BasePill {
|
||||
tooltipLoader.active = true;
|
||||
if (tooltipLoader.item) {
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = delegateItem.mapToGlobal(0, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const localPos = delegateItem.mapToItem(null, 0, delegateItem.height / 2);
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
const tooltipX = isLeft ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
const screenRelativeY = globalPos.y - screenY + root.minTooltipY;
|
||||
tooltipLoader.item.show(appItem.tooltipText, screenX + tooltipX, screenRelativeY, root.parentScreen, isLeft, !isLeft);
|
||||
const screenRelativeY = localPos.y + root.minTooltipY;
|
||||
tooltipLoader.item.show(appItem.tooltipText, tooltipX, screenRelativeY, root.parentScreen, isLeft, !isLeft);
|
||||
} else {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height);
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height);
|
||||
const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height;
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS);
|
||||
tooltipLoader.item.show(appItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false);
|
||||
tooltipLoader.item.show(appItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -967,14 +965,12 @@ BasePill {
|
||||
contextMenuLoader.active = true;
|
||||
|
||||
if (contextMenuLoader.item) {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2);
|
||||
const isBarVertical = root.axis?.isVertical ?? false;
|
||||
const barEdge = root.axis?.edge ?? "top";
|
||||
|
||||
let x = globalPos.x - screenX;
|
||||
let y = globalPos.y - screenY;
|
||||
let x = localPos.x;
|
||||
let y = localPos.y;
|
||||
|
||||
switch (barEdge) {
|
||||
case "bottom":
|
||||
|
||||
@@ -276,15 +276,12 @@ BasePill {
|
||||
if (root.isVerticalOrientation && root.selectedMount) {
|
||||
tooltipLoader.active = true;
|
||||
if (tooltipLoader.item) {
|
||||
const globalPos = mapToGlobal(width / 2, height / 2);
|
||||
const localPos = mapToItem(null, width / 2, height / 2);
|
||||
const currentScreen = root.parentScreen || Screen;
|
||||
const screenX = currentScreen ? currentScreen.x : 0;
|
||||
const screenY = currentScreen ? currentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
tooltipLoader.item.show(root.selectedMount.mount, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
tooltipLoader.item.show(root.selectedMount.mount, tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,13 +304,9 @@ BasePill {
|
||||
if (root.isVerticalOrientation && activeWindow && activeWindow.appId && root.parentScreen) {
|
||||
tooltipLoader.active = true;
|
||||
if (tooltipLoader.item) {
|
||||
const globalPos = mapToGlobal(width / 2, height / 2);
|
||||
const localPos = mapToItem(null, width / 2, height / 2);
|
||||
const currentScreen = root.parentScreen;
|
||||
const screenX = currentScreen ? currentScreen.x : 0;
|
||||
const screenY = currentScreen ? currentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
// Add minTooltipY offset to account for top bar
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
const tooltipX = root.axis?.edge === "left" ? (Theme.barHeight + (barConfig?.spacing ?? 4) + Theme.spacingXS) : (currentScreen.width - Theme.barHeight - (barConfig?.spacing ?? 4) - Theme.spacingXS);
|
||||
|
||||
const appName = Paths.getAppName(activeWindow.appId, activeDesktopEntry);
|
||||
@@ -318,7 +314,7 @@ BasePill {
|
||||
const tooltipText = appName + (title ? " • " + title : "");
|
||||
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
tooltipLoader.item.show(tooltipText, tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,22 +424,16 @@ BasePill {
|
||||
windowContextMenuLoader.item.triggerBarThickness = root.barThickness;
|
||||
windowContextMenuLoader.item.triggerBarSpacing = root.barSpacing;
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
// Add minTooltipY offset to account for top bar
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2);
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
const xPos = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
windowContextMenuLoader.item.showAt(xPos, adjustedY, true, root.axis?.edge);
|
||||
} else {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const relativeX = globalPos.x - screenX;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, 0);
|
||||
const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height;
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const yPos = isBottom ? (screenHeight - root.barThickness - root.barSpacing - 32 - Theme.spacingXS) : (root.barThickness + root.barSpacing + Theme.spacingXS);
|
||||
windowContextMenuLoader.item.showAt(relativeX, yPos, false, root.axis?.edge);
|
||||
windowContextMenuLoader.item.showAt(localPos.x, yPos, false, root.axis?.edge);
|
||||
}
|
||||
}
|
||||
} else if (mouse.button === Qt.MiddleButton) {
|
||||
@@ -455,21 +449,17 @@ BasePill {
|
||||
tooltipLoader.active = true;
|
||||
if (tooltipLoader.item) {
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2);
|
||||
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const finalX = screenX + tooltipX;
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, finalX, adjustedY, root.parentScreen, isLeft, !isLeft);
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, tooltipX, adjustedY, root.parentScreen, isLeft, !isLeft);
|
||||
} else {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height);
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height);
|
||||
const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height;
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS);
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false);
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -677,22 +667,16 @@ BasePill {
|
||||
windowContextMenuLoader.item.triggerBarThickness = root.barThickness;
|
||||
windowContextMenuLoader.item.triggerBarSpacing = root.barSpacing;
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
// Add minTooltipY offset to account for top bar
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2);
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
const xPos = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
windowContextMenuLoader.item.showAt(xPos, adjustedY, true, root.axis?.edge);
|
||||
} else {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, 0);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const relativeX = globalPos.x - screenX;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, 0);
|
||||
const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height;
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const yPos = isBottom ? (screenHeight - root.barThickness - root.barSpacing - 32 - Theme.spacingXS) : (root.barThickness + root.barSpacing + Theme.spacingXS);
|
||||
windowContextMenuLoader.item.showAt(relativeX, yPos, false, root.axis?.edge);
|
||||
windowContextMenuLoader.item.showAt(localPos.x, yPos, false, root.axis?.edge);
|
||||
}
|
||||
}
|
||||
} else if (mouse.button === Qt.MiddleButton) {
|
||||
@@ -708,21 +692,17 @@ BasePill {
|
||||
tooltipLoader.active = true;
|
||||
if (tooltipLoader.item) {
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height / 2);
|
||||
const screenX = root.parentScreen ? root.parentScreen.x : 0;
|
||||
const screenY = root.parentScreen ? root.parentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height / 2);
|
||||
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (root.parentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const finalX = screenX + tooltipX;
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, finalX, adjustedY, root.parentScreen, isLeft, !isLeft);
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, tooltipX, adjustedY, root.parentScreen, isLeft, !isLeft);
|
||||
} else {
|
||||
const globalPos = delegateItem.mapToGlobal(delegateItem.width / 2, delegateItem.height);
|
||||
const localPos = delegateItem.mapToItem(null, delegateItem.width / 2, delegateItem.height);
|
||||
const screenHeight = root.parentScreen ? root.parentScreen.height : Screen.height;
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const tooltipY = isBottom ? (screenHeight - root.barThickness - root.barSpacing - Theme.spacingXS - 35) : (root.barThickness + root.barSpacing + Theme.spacingXS);
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, globalPos.x, tooltipY, root.parentScreen, false, false);
|
||||
tooltipLoader.item.show(delegateItem.tooltipText, localPos.x, tooltipY, root.parentScreen, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,18 +106,15 @@ BasePill {
|
||||
}
|
||||
|
||||
if (root.isVerticalOrientation) {
|
||||
const globalPos = mapToGlobal(width / 2, height / 2);
|
||||
const localPos = mapToItem(null, width / 2, height / 2);
|
||||
const currentScreen = root.parentScreen || Screen;
|
||||
const screenX = currentScreen ? currentScreen.x : 0;
|
||||
const screenY = currentScreen ? currentScreen.y : 0;
|
||||
const relativeY = globalPos.y - screenY;
|
||||
const adjustedY = relativeY + root.minTooltipY;
|
||||
const adjustedY = localPos.y + root.minTooltipY;
|
||||
const tooltipX = root.axis?.edge === "left" ? (root.barThickness + root.barSpacing + Theme.spacingXS) : (currentScreen.width - root.barThickness - root.barSpacing - Theme.spacingXS);
|
||||
const isLeft = root.axis?.edge === "left";
|
||||
tooltipLoader.item.show(tooltipText, screenX + tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
tooltipLoader.item.show(tooltipText, tooltipX, adjustedY, currentScreen, isLeft, !isLeft);
|
||||
} else {
|
||||
const isBottom = root.axis?.edge === "bottom";
|
||||
const globalPos = mapToGlobal(width / 2, 0);
|
||||
const localPos = mapToItem(null, width / 2, 0);
|
||||
const currentScreen = root.parentScreen || Screen;
|
||||
|
||||
let tooltipY;
|
||||
@@ -128,7 +125,7 @@ BasePill {
|
||||
tooltipY = root.barThickness + root.barSpacing + Theme.spacingXS;
|
||||
}
|
||||
|
||||
tooltipLoader.item.show(tooltipText, globalPos.x, tooltipY, currentScreen, false, false);
|
||||
tooltipLoader.item.show(tooltipText, localPos.x, tooltipY, currentScreen, false, false);
|
||||
}
|
||||
}
|
||||
onExited: {
|
||||
|
||||
Reference in New Issue
Block a user