1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-08-01 19:18:28 -04:00

notepad: make dentry NoDisplay

This commit is contained in:
bbedward
2026-07-04 17:00:43 -04:00
parent 57a04cf409
commit ea0c235d6e
4 changed files with 29 additions and 14 deletions
+28
View File
@@ -1,4 +1,5 @@
import QtQuick
import Quickshell
import qs.Common
import qs.Modals.Common
import qs.Widgets
@@ -23,6 +24,7 @@ DankModal {
property var rememberMimeTypes: []
property bool rememberChoice: false
property var mimeMatchedAppIds: []
property var mimeMatchedRawIds: []
signal applicationSelected(var app, string targetData)
@@ -61,6 +63,7 @@ DankModal {
function fetchMimeMatches() {
mimeMatchedAppIds = [];
mimeMatchedRawIds = [];
const queriedMime = mimeType;
if (queriedMime.length === 0)
return;
@@ -74,6 +77,7 @@ DankModal {
return;
}
const ids = (response.result && response.result.desktopIds) || [];
mimeMatchedRawIds = ids;
mimeMatchedAppIds = ids.map(_normAppId);
updateApplicationList();
});
@@ -93,11 +97,13 @@ DankModal {
const hasMimeMatches = mimeMatchedAppIds.length > 0;
const lowerQuery = searchQuery.toLowerCase();
let filteredApps = [];
const listedIds = new Set();
for (const app of apps) {
if (!app)
continue;
const appId = _normAppId(app.id || app.execString || app.exec || "");
listedIds.add(appId);
const mimeIdMatch = hasMimeMatches && mimeMatchedAppIds.includes(appId);
const mimeFieldMatch = hasMime && _appMatchesMime(app, mimeType);
const mimeMatch = mimeIdMatch || mimeFieldMatch;
@@ -135,6 +141,28 @@ DankModal {
});
}
// NoDisplay entries are excluded from DesktopEntries.applications but
// remain valid mime handlers; resolve them by id so they stay pickable
for (const rawId of mimeMatchedRawIds) {
const normId = _normAppId(rawId);
if (normId === "dms-open" || listedIds.has(normId))
continue;
const entry = DesktopEntries.byId(rawId) || DesktopEntries.heuristicLookup(rawId);
if (!entry)
continue;
const name = entry.name || "";
if (searchQuery !== "" && !name.toLowerCase().includes(lowerQuery))
continue;
filteredApps.push({
name: name,
icon: entry.icon || "application-x-executable",
exec: entry.execString || "",
startupClass: entry.startupClass || "",
appData: entry,
mimeMatch: true
});
}
filteredApps.sort((a, b) => {
if (a.mimeMatch !== b.mimeMatch) {
return a.mimeMatch ? -1 : 1;