mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
dock: repair context menu screens & tooltips
This commit is contained in:
@@ -110,10 +110,6 @@ Variants {
|
||||
item: dockMouseArea
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: appTooltip
|
||||
z: 1000
|
||||
|
||||
property var hoveredButton: {
|
||||
if (!dockApps.children[0]) {
|
||||
return null
|
||||
@@ -140,53 +136,6 @@ Variants {
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: tooltipLabel
|
||||
anchors.centerIn: parent
|
||||
text: appTooltip.tooltipText
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
color: Theme.surfaceText
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: dockCore
|
||||
anchors.fill: parent
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user