1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 23:42:51 -05:00

launcher: support for plugins to define context menus

fixes #1279
This commit is contained in:
bbedward
2026-01-06 10:07:46 -05:00
parent 1c8ce46f25
commit 45818b202f
6 changed files with 179 additions and 45 deletions

View File

@@ -39,22 +39,39 @@ Rectangle {
anchors.centerIn: parent
spacing: Theme.spacingS
AppIconRenderer {
property int computedIconSize: Math.min(root.maxIconSize, Math.max(root.minIconSize, root.cellWidth * root.iconSizeRatio))
width: computedIconSize
height: computedIconSize
Item {
width: iconRenderer.computedIconSize
height: iconRenderer.computedIconSize
anchors.horizontalCenter: parent.horizontalCenter
iconValue: (model.icon && model.icon !== "") ? model.icon : ""
iconSize: computedIconSize
fallbackText: (model.name && model.name.length > 0) ? model.name.charAt(0).toUpperCase() : "A"
materialIconSizeAdjustment: root.iconMaterialSizeAdjustment
unicodeIconScale: root.iconUnicodeScale
fallbackTextScale: Math.min(28, computedIconSize * 0.5) / computedIconSize
iconMargins: 0
fallbackLeftMargin: root.iconFallbackLeftMargin
fallbackRightMargin: root.iconFallbackRightMargin
fallbackBottomMargin: root.iconFallbackBottomMargin
AppIconRenderer {
id: iconRenderer
property int computedIconSize: Math.min(root.maxIconSize, Math.max(root.minIconSize, root.cellWidth * root.iconSizeRatio))
width: computedIconSize
height: computedIconSize
iconValue: (model.icon && model.icon !== "") ? model.icon : ""
iconSize: computedIconSize
fallbackText: (model.name && model.name.length > 0) ? model.name.charAt(0).toUpperCase() : "A"
materialIconSizeAdjustment: root.iconMaterialSizeAdjustment
unicodeIconScale: root.iconUnicodeScale
fallbackTextScale: Math.min(28, computedIconSize * 0.5) / computedIconSize
iconMargins: 0
fallbackLeftMargin: root.iconFallbackLeftMargin
fallbackRightMargin: root.iconFallbackRightMargin
fallbackBottomMargin: root.iconFallbackBottomMargin
}
DankIcon {
visible: model.pinned === true
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.rightMargin: -4
anchors.bottomMargin: -4
name: "push_pin"
size: 14
color: Theme.primary
}
}
StyledText {
@@ -95,13 +112,11 @@ Rectangle {
}
}
onPressAndHold: mouse => {
if (!root.isPlugin) {
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
}
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
}
onPressed: mouse => {
if (mouse.button === Qt.RightButton && !root.isPlugin) {
if (mouse.button === Qt.RightButton) {
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
mouse.accepted = true;

View File

@@ -62,16 +62,31 @@ Rectangle {
width: (model.icon !== undefined && model.icon !== "") ? (parent.width - root.iconSize - Theme.spacingL) : parent.width
spacing: Theme.spacingXS
StyledText {
Row {
width: parent.width
text: model.name || ""
font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText
font.weight: Font.Medium
elide: Text.ElideRight
horizontalAlignment: Text.AlignLeft
wrapMode: Text.NoWrap
maximumLineCount: 1
spacing: Theme.spacingXS
StyledText {
width: parent.width - (pinIcon.visible ? pinIcon.width + Theme.spacingXS : 0)
text: model.name || ""
font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText
font.weight: Font.Medium
elide: Text.ElideRight
horizontalAlignment: Text.AlignLeft
wrapMode: Text.NoWrap
maximumLineCount: 1
anchors.verticalCenter: parent.verticalCenter
}
DankIcon {
id: pinIcon
visible: model.pinned === true
name: "push_pin"
size: Theme.fontSizeMedium
color: Theme.primary
anchors.verticalCenter: parent.verticalCenter
}
}
StyledText {
@@ -111,13 +126,11 @@ Rectangle {
}
}
onPressAndHold: mouse => {
if (!root.isPlugin) {
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
}
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
}
onPressed: mouse => {
if (mouse.button === Qt.RightButton && !root.isPlugin) {
if (mouse.button === Qt.RightButton) {
const globalPos = mapToItem(null, mouse.x, mouse.y);
root.itemRightClicked(root.index, root.model, globalPos.x, globalPos.y);
mouse.accepted = true;