mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-14 09:42:10 -04:00
dock: repair context menu screens & tooltips
This commit is contained in:
@@ -110,81 +110,30 @@ Variants {
|
|||||||
item: dockMouseArea
|
item: dockMouseArea
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
property var hoveredButton: {
|
||||||
id: appTooltip
|
if (!dockApps.children[0]) {
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
const layoutItem = dockApps.children[0]
|
||||||
property string tooltipText: hoveredButton ? hoveredButton.tooltipText : ""
|
const flowLayout = layoutItem.children[0]
|
||||||
|
let repeater = null
|
||||||
visible: hoveredButton !== null && tooltipText !== ""
|
for (var i = 0; i < flowLayout.children.length; i++) {
|
||||||
width: px(tooltipLabel.implicitWidth + 24)
|
const child = flowLayout.children[i]
|
||||||
height: px(tooltipLabel.implicitHeight + 12)
|
if (child && typeof child.count !== "undefined" && typeof child.itemAt === "function") {
|
||||||
|
repeater = child
|
||||||
color: Theme.surfaceContainer
|
break
|
||||||
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 (!repeater || !repeater.itemAt) {
|
||||||
if (!hoveredButton) return 0
|
return null
|
||||||
const buttonPos = hoveredButton.mapToItem(dock.contentItem, 0, 0)
|
}
|
||||||
if (!dock.isVertical) {
|
for (var i = 0; i < repeater.count; i++) {
|
||||||
if (SettingsData.dockPosition === SettingsData.Position.Bottom) {
|
const item = repeater.itemAt(i)
|
||||||
return buttonPos.y - height - Theme.spacingS
|
if (item && item.dockButton && item.dockButton.showTooltip) {
|
||||||
} else {
|
return item.dockButton
|
||||||
return buttonPos.y + hoveredButton.height + Theme.spacingS
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return buttonPos.y + hoveredButton.height / 2 - height / 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return null
|
||||||
StyledText {
|
|
||||||
id: tooltipLabel
|
|
||||||
anchors.centerIn: parent
|
|
||||||
text: appTooltip.tooltipText
|
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
|
||||||
color: Theme.surfaceText
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -256,6 +205,62 @@ Variants {
|
|||||||
id: dockContainer
|
id: dockContainer
|
||||||
anchors.fill: parent
|
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 {
|
transform: Translate {
|
||||||
id: dockSlide
|
id: dockSlide
|
||||||
x: {
|
x: {
|
||||||
@@ -281,6 +286,7 @@ Variants {
|
|||||||
|
|
||||||
Behavior on x {
|
Behavior on x {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
id: slideXAnimation
|
||||||
duration: 200
|
duration: 200
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
@@ -288,6 +294,7 @@ Variants {
|
|||||||
|
|
||||||
Behavior on y {
|
Behavior on y {
|
||||||
NumberAnimation {
|
NumberAnimation {
|
||||||
|
id: slideYAnimation
|
||||||
duration: 200
|
duration: 200
|
||||||
easing.type: Easing.OutCubic
|
easing.type: Easing.OutCubic
|
||||||
}
|
}
|
||||||
@@ -344,6 +351,7 @@ Variants {
|
|||||||
contextMenu: dockVariants.contextMenu
|
contextMenu: dockVariants.contextMenu
|
||||||
groupByApp: dock.groupByApp
|
groupByApp: dock.groupByApp
|
||||||
isVertical: dock.isVertical
|
isVertical: dock.isVertical
|
||||||
|
dockScreen: dock.screen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ Item {
|
|||||||
property var contextMenu: null
|
property var contextMenu: null
|
||||||
property var dockApps: null
|
property var dockApps: null
|
||||||
property int index: -1
|
property int index: -1
|
||||||
|
property var parentDockScreen: null
|
||||||
property bool longPressing: false
|
property bool longPressing: false
|
||||||
property bool dragging: false
|
property bool dragging: false
|
||||||
property point dragStartPos: Qt.point(0, 0)
|
property point dragStartPos: Qt.point(0, 0)
|
||||||
@@ -317,7 +318,7 @@ Item {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (contextMenu) {
|
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") {
|
} else if (appData && appData.type === "grouped") {
|
||||||
if (contextMenu) {
|
if (contextMenu) {
|
||||||
contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry)
|
contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry, parentDockScreen)
|
||||||
}
|
}
|
||||||
} else if (appData && appData.appId) {
|
} else if (appData && appData.appId) {
|
||||||
const desktopEntry = cachedDesktopEntry
|
const desktopEntry = cachedDesktopEntry
|
||||||
@@ -351,7 +352,7 @@ Item {
|
|||||||
}
|
}
|
||||||
} else if (mouse.button === Qt.RightButton) {
|
} else if (mouse.button === Qt.RightButton) {
|
||||||
if (contextMenu && appData) {
|
if (contextMenu && appData) {
|
||||||
contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry)
|
contextMenu.showForButton(root, appData, 40, false, cachedDesktopEntry, parentDockScreen)
|
||||||
} else {
|
} else {
|
||||||
console.warn("No context menu or appData available")
|
console.warn("No context menu or appData available")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Item {
|
|||||||
property int pinnedAppCount: 0
|
property int pinnedAppCount: 0
|
||||||
property bool groupByApp: false
|
property bool groupByApp: false
|
||||||
property bool isVertical: false
|
property bool isVertical: false
|
||||||
|
property var dockScreen: null
|
||||||
|
|
||||||
implicitWidth: isVertical ? appLayout.height : appLayout.width
|
implicitWidth: isVertical ? appLayout.height : appLayout.width
|
||||||
implicitHeight: isVertical ? appLayout.width : appLayout.height
|
implicitHeight: isVertical ? appLayout.width : appLayout.height
|
||||||
@@ -217,6 +218,7 @@ Item {
|
|||||||
contextMenu: root.contextMenu
|
contextMenu: root.contextMenu
|
||||||
dockApps: root
|
dockApps: root
|
||||||
index: model.index
|
index: model.index
|
||||||
|
parentDockScreen: root.dockScreen
|
||||||
|
|
||||||
// Override tooltip for windows to show window title
|
// Override tooltip for windows to show window title
|
||||||
showWindowTitle: model.type === "window" || model.type === "grouped"
|
showWindowTitle: model.type === "window" || model.type === "grouped"
|
||||||
|
|||||||
@@ -17,22 +17,15 @@ PanelWindow {
|
|||||||
property bool hidePin: false
|
property bool hidePin: false
|
||||||
property var desktopEntry: null
|
property var desktopEntry: null
|
||||||
|
|
||||||
function showForButton(button, data, dockHeight, hidePinOption, entry) {
|
function showForButton(button, data, dockHeight, hidePinOption, entry, dockScreen) {
|
||||||
anchorItem = button
|
anchorItem = button
|
||||||
appData = data
|
appData = data
|
||||||
dockVisibleHeight = dockHeight || 40
|
dockVisibleHeight = dockHeight || 40
|
||||||
hidePin = hidePinOption || false
|
hidePin = hidePinOption || false
|
||||||
desktopEntry = entry || null
|
desktopEntry = entry || null
|
||||||
|
|
||||||
const dockWindow = button.Window.window
|
if (dockScreen) {
|
||||||
if (dockWindow) {
|
root.screen = dockScreen
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showContextMenu = true
|
showContextMenu = true
|
||||||
|
|||||||
Reference in New Issue
Block a user