1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2025-12-05 21:15:38 -05:00

launcher: fix crash in plugin action execution

This commit is contained in:
bbedward
2025-10-14 12:39:51 -04:00
parent 8aff381676
commit 50b28dc8ca
4 changed files with 32 additions and 28 deletions

View File

@@ -12,6 +12,7 @@ Popup {
property var currentApp: null property var currentApp: null
property var appLauncher: null property var appLauncher: null
property var parentHandler: null property var parentHandler: null
readonly property var desktopEntry: (currentApp && !currentApp.isPlugin && appLauncher && appLauncher._uniqueApps && currentApp.appIndex >= 0 && currentApp.appIndex < appLauncher._uniqueApps.length) ? appLauncher._uniqueApps[currentApp.appIndex] : null
function show(x, y, app) { function show(x, y, app) {
currentApp = app currentApp = app
@@ -92,10 +93,10 @@ Popup {
DankIcon { DankIcon {
name: { name: {
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) if (!desktopEntry)
return "push_pin" return "push_pin"
const appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" const appId = desktopEntry.id || desktopEntry.execString || ""
return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin" return SessionData.isPinnedApp(appId) ? "keep_off" : "push_pin"
} }
size: Theme.iconSize - 2 size: Theme.iconSize - 2
@@ -106,10 +107,10 @@ Popup {
StyledText { StyledText {
text: { text: {
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) if (!desktopEntry)
return I18n.tr("Pin to Dock") return I18n.tr("Pin to Dock")
const appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" const appId = desktopEntry.id || desktopEntry.execString || ""
return SessionData.isPinnedApp(appId) ? I18n.tr("Unpin from Dock") : I18n.tr("Pin to Dock") return SessionData.isPinnedApp(appId) ? I18n.tr("Unpin from Dock") : I18n.tr("Pin to Dock")
} }
font.pixelSize: Theme.fontSizeSmall font.pixelSize: Theme.fontSizeSmall
@@ -126,10 +127,10 @@ Popup {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: () => { onClicked: () => {
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) if (!desktopEntry)
return return
const appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" const appId = desktopEntry.id || desktopEntry.execString || ""
if (SessionData.isPinnedApp(appId)) if (SessionData.isPinnedApp(appId))
SessionData.removePinnedApp(appId) SessionData.removePinnedApp(appId)
else else
@@ -154,7 +155,7 @@ Popup {
} }
Repeater { Repeater {
model: contextMenu.currentApp && contextMenu.currentApp.desktopEntry && contextMenu.currentApp.desktopEntry.actions ? contextMenu.currentApp.desktopEntry.actions : [] model: desktopEntry && desktopEntry.actions ? desktopEntry.actions : []
Rectangle { Rectangle {
implicitWidth: actionRow.implicitWidth + Theme.spacingS * 2 implicitWidth: actionRow.implicitWidth + Theme.spacingS * 2
@@ -200,9 +201,9 @@ Popup {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (modelData && contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { if (modelData && desktopEntry) {
SessionService.launchDesktopAction(contextMenu.currentApp.desktopEntry, modelData) SessionService.launchDesktopAction(desktopEntry, modelData)
if (appLauncher) { if (appLauncher && contextMenu.currentApp) {
appLauncher.appLaunched(contextMenu.currentApp) appLauncher.appLaunched(contextMenu.currentApp)
} }
} }
@@ -213,7 +214,7 @@ Popup {
} }
Rectangle { Rectangle {
visible: contextMenu.currentApp && contextMenu.currentApp.desktopEntry && contextMenu.currentApp.desktopEntry.actions && contextMenu.currentApp.desktopEntry.actions.length > 0 visible: desktopEntry && desktopEntry.actions && desktopEntry.actions.length > 0
width: parent.width - Theme.spacingS * 2 width: parent.width - Theme.spacingS * 2
height: 5 height: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -327,9 +328,9 @@ Popup {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: () => { onClicked: () => {
if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { if (desktopEntry) {
SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true) SessionService.launchDesktopEntry(desktopEntry, true)
if (appLauncher) { if (appLauncher && contextMenu.currentApp) {
appLauncher.appLaunched(contextMenu.currentApp) appLauncher.appLaunched(contextMenu.currentApp)
} }
} }

View File

@@ -665,8 +665,8 @@ DankPopout {
id: contextMenu id: contextMenu
property var currentApp: null property var currentApp: null
readonly property var desktopEntry: (currentApp && !currentApp.isPlugin && appLauncher && appLauncher._uniqueApps && currentApp.appIndex >= 0 && currentApp.appIndex < appLauncher._uniqueApps.length) ? appLauncher._uniqueApps[currentApp.appIndex] : null
readonly property string appId: (currentApp && currentApp.desktopEntry) ? (currentApp.desktopEntry.id || currentApp.desktopEntry.execString || "") : "" readonly property string appId: desktopEntry ? (desktopEntry.id || desktopEntry.execString || "") : ""
readonly property bool isPinned: appId && SessionData.isPinnedApp(appId) readonly property bool isPinned: appId && SessionData.isPinnedApp(appId)
function show(x, y, app) { function show(x, y, app) {
@@ -768,7 +768,7 @@ DankPopout {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) { if (!contextMenu.desktopEntry) {
return return
} }
@@ -797,7 +797,7 @@ DankPopout {
} }
Repeater { Repeater {
model: contextMenu.currentApp && contextMenu.currentApp.desktopEntry && contextMenu.currentApp.desktopEntry.actions ? contextMenu.currentApp.desktopEntry.actions : [] model: contextMenu.desktopEntry && contextMenu.desktopEntry.actions ? contextMenu.desktopEntry.actions : []
Rectangle { Rectangle {
width: Math.max(parent.width, actionRow.implicitWidth + Theme.spacingS * 2) width: Math.max(parent.width, actionRow.implicitWidth + Theme.spacingS * 2)
@@ -842,9 +842,11 @@ DankPopout {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (modelData && contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { if (modelData && contextMenu.desktopEntry) {
SessionService.launchDesktopAction(contextMenu.currentApp.desktopEntry, modelData) SessionService.launchDesktopAction(contextMenu.desktopEntry, modelData)
appLauncher.appLaunched(contextMenu.currentApp) if (contextMenu.currentApp) {
appLauncher.appLaunched(contextMenu.currentApp)
}
} }
contextMenu.hide() contextMenu.hide()
} }
@@ -853,7 +855,7 @@ DankPopout {
} }
Rectangle { Rectangle {
visible: contextMenu.currentApp && contextMenu.currentApp.desktopEntry && contextMenu.currentApp.desktopEntry.actions && contextMenu.currentApp.desktopEntry.actions.length > 0 visible: contextMenu.desktopEntry && contextMenu.desktopEntry.actions && contextMenu.desktopEntry.actions.length > 0
width: parent.width - Theme.spacingS * 2 width: parent.width - Theme.spacingS * 2
height: 5 height: 5
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -963,9 +965,11 @@ DankPopout {
hoverEnabled: true hoverEnabled: true
cursorShape: Qt.PointingHandCursor cursorShape: Qt.PointingHandCursor
onClicked: { onClicked: {
if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { if (contextMenu.desktopEntry) {
SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true) SessionService.launchDesktopEntry(contextMenu.desktopEntry, true)
appLauncher.appLaunched(contextMenu.currentApp) if (contextMenu.currentApp) {
appLauncher.appLaunched(contextMenu.currentApp)
}
} }
contextMenu.hide() contextMenu.hide()
} }

View File

@@ -167,8 +167,7 @@ Item {
"comment": app.comment || "", "comment": app.comment || "",
"categories": app.categories || [], "categories": app.categories || [],
"isPlugin": isPluginItem, "isPlugin": isPluginItem,
"appIndex": uniqueApps.length - 1, "appIndex": uniqueApps.length - 1
"desktopEntry": isPluginItem ? null : app
}) })
} }
}) })

View File

@@ -139,7 +139,7 @@ DankMaterialShell particularly aims at supporting the **niri** and **Hyprland**
**Niri**: **Niri**:
```bash ```bash
# Arch Linux # Arch Linux
paru -S niri-git sudo pacman -S niri
# Fedora # Fedora
sudo dnf copr enable yalter/niri && sudo dnf install niri sudo dnf copr enable yalter/niri && sudo dnf install niri