diff --git a/Modals/Spotlight/SpotlightContextMenu.qml b/Modals/Spotlight/SpotlightContextMenu.qml index ded34ccf..e4e05fba 100644 --- a/Modals/Spotlight/SpotlightContextMenu.qml +++ b/Modals/Spotlight/SpotlightContextMenu.qml @@ -12,6 +12,7 @@ Popup { property var currentApp: null property var appLauncher: 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) { currentApp = app @@ -92,10 +93,10 @@ Popup { DankIcon { name: { - if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) + if (!desktopEntry) 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" } size: Theme.iconSize - 2 @@ -106,10 +107,10 @@ Popup { StyledText { text: { - if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) + if (!desktopEntry) 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") } font.pixelSize: Theme.fontSizeSmall @@ -126,10 +127,10 @@ Popup { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: () => { - if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) + if (!desktopEntry) return - const appId = contextMenu.currentApp.desktopEntry.id || contextMenu.currentApp.desktopEntry.execString || "" + const appId = desktopEntry.id || desktopEntry.execString || "" if (SessionData.isPinnedApp(appId)) SessionData.removePinnedApp(appId) else @@ -154,7 +155,7 @@ Popup { } Repeater { - model: contextMenu.currentApp && contextMenu.currentApp.desktopEntry && contextMenu.currentApp.desktopEntry.actions ? contextMenu.currentApp.desktopEntry.actions : [] + model: desktopEntry && desktopEntry.actions ? desktopEntry.actions : [] Rectangle { implicitWidth: actionRow.implicitWidth + Theme.spacingS * 2 @@ -200,9 +201,9 @@ Popup { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - if (modelData && contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { - SessionService.launchDesktopAction(contextMenu.currentApp.desktopEntry, modelData) - if (appLauncher) { + if (modelData && desktopEntry) { + SessionService.launchDesktopAction(desktopEntry, modelData) + if (appLauncher && contextMenu.currentApp) { appLauncher.appLaunched(contextMenu.currentApp) } } @@ -213,7 +214,7 @@ Popup { } 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 height: 5 anchors.horizontalCenter: parent.horizontalCenter @@ -327,9 +328,9 @@ Popup { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: () => { - if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { - SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true) - if (appLauncher) { + if (desktopEntry) { + SessionService.launchDesktopEntry(desktopEntry, true) + if (appLauncher && contextMenu.currentApp) { appLauncher.appLaunched(contextMenu.currentApp) } } diff --git a/Modules/AppDrawer/AppDrawerPopout.qml b/Modules/AppDrawer/AppDrawerPopout.qml index 84ef1247..290e2cd8 100644 --- a/Modules/AppDrawer/AppDrawerPopout.qml +++ b/Modules/AppDrawer/AppDrawerPopout.qml @@ -665,8 +665,8 @@ DankPopout { id: contextMenu property var currentApp: null - - readonly property string appId: (currentApp && currentApp.desktopEntry) ? (currentApp.desktopEntry.id || currentApp.desktopEntry.execString || "") : "" + 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: desktopEntry ? (desktopEntry.id || desktopEntry.execString || "") : "" readonly property bool isPinned: appId && SessionData.isPinnedApp(appId) function show(x, y, app) { @@ -768,7 +768,7 @@ DankPopout { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - if (!contextMenu.currentApp || !contextMenu.currentApp.desktopEntry) { + if (!contextMenu.desktopEntry) { return } @@ -797,7 +797,7 @@ DankPopout { } 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 { width: Math.max(parent.width, actionRow.implicitWidth + Theme.spacingS * 2) @@ -842,9 +842,11 @@ DankPopout { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - if (modelData && contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { - SessionService.launchDesktopAction(contextMenu.currentApp.desktopEntry, modelData) - appLauncher.appLaunched(contextMenu.currentApp) + if (modelData && contextMenu.desktopEntry) { + SessionService.launchDesktopAction(contextMenu.desktopEntry, modelData) + if (contextMenu.currentApp) { + appLauncher.appLaunched(contextMenu.currentApp) + } } contextMenu.hide() } @@ -853,7 +855,7 @@ DankPopout { } 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 height: 5 anchors.horizontalCenter: parent.horizontalCenter @@ -963,9 +965,11 @@ DankPopout { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - if (contextMenu.currentApp && contextMenu.currentApp.desktopEntry) { - SessionService.launchDesktopEntry(contextMenu.currentApp.desktopEntry, true) - appLauncher.appLaunched(contextMenu.currentApp) + if (contextMenu.desktopEntry) { + SessionService.launchDesktopEntry(contextMenu.desktopEntry, true) + if (contextMenu.currentApp) { + appLauncher.appLaunched(contextMenu.currentApp) + } } contextMenu.hide() } diff --git a/Modules/AppDrawer/AppLauncher.qml b/Modules/AppDrawer/AppLauncher.qml index 702c6fda..f6af5eed 100644 --- a/Modules/AppDrawer/AppLauncher.qml +++ b/Modules/AppDrawer/AppLauncher.qml @@ -167,8 +167,7 @@ Item { "comment": app.comment || "", "categories": app.categories || [], "isPlugin": isPluginItem, - "appIndex": uniqueApps.length - 1, - "desktopEntry": isPluginItem ? null : app + "appIndex": uniqueApps.length - 1 }) } }) diff --git a/README.md b/README.md index cf0318e7..430d0b5d 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ DankMaterialShell particularly aims at supporting the **niri** and **Hyprland** **Niri**: ```bash # Arch Linux -paru -S niri-git +sudo pacman -S niri # Fedora sudo dnf copr enable yalter/niri && sudo dnf install niri