mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
feat: Pinnable DMS coreApps w/Color options
This commit is contained in:
@@ -29,12 +29,29 @@ Item {
|
||||
property bool showTooltip: mouseArea.containsMouse && !dragging
|
||||
property var cachedDesktopEntry: null
|
||||
property real actualIconSize: 40
|
||||
readonly property string coreIconColorOverride: SettingsData.dockLauncherLogoColorOverride
|
||||
readonly property bool coreIconHasCustomColor: coreIconColorOverride !== "" && coreIconColorOverride !== "primary" && coreIconColorOverride !== "surface"
|
||||
readonly property color effectiveCoreIconColor: {
|
||||
if (coreIconColorOverride === "primary")
|
||||
return Theme.primary;
|
||||
if (coreIconColorOverride === "surface")
|
||||
return Theme.surfaceText;
|
||||
if (coreIconColorOverride !== "")
|
||||
return coreIconColorOverride;
|
||||
return Theme.surfaceText;
|
||||
}
|
||||
readonly property real effectiveCoreIconBrightness: coreIconHasCustomColor ? SettingsData.dockLauncherLogoBrightness : 0.0
|
||||
readonly property real effectiveCoreIconContrast: coreIconHasCustomColor ? SettingsData.dockLauncherLogoContrast : 0.0
|
||||
|
||||
function updateDesktopEntry() {
|
||||
if (!appData || appData.appId === "__SEPARATOR__") {
|
||||
cachedDesktopEntry = null;
|
||||
return;
|
||||
}
|
||||
if (appData.isCoreApp) {
|
||||
cachedDesktopEntry = null;
|
||||
return;
|
||||
}
|
||||
const moddedId = Paths.moddedAppId(appData.appId);
|
||||
cachedDesktopEntry = DesktopEntries.heuristicLookup(moddedId);
|
||||
}
|
||||
@@ -85,7 +102,12 @@ Item {
|
||||
return "";
|
||||
}
|
||||
|
||||
const appName = Paths.getAppName(appData.appId, cachedDesktopEntry);
|
||||
let appName;
|
||||
if (appData.isCoreApp && appData.coreAppData) {
|
||||
appName = appData.coreAppData.name || appData.appId;
|
||||
} else {
|
||||
appName = Paths.getAppName(appData.appId, cachedDesktopEntry);
|
||||
}
|
||||
|
||||
if ((appData.type === "window" && showWindowTitle) || (appData.type === "grouped" && appData.windowTitle)) {
|
||||
const title = appData.type === "window" ? windowTitle : appData.windowTitle;
|
||||
@@ -227,6 +249,10 @@ Item {
|
||||
case "pinned":
|
||||
if (!appData.appId)
|
||||
return;
|
||||
if (appData.isCoreApp && appData.coreAppData) {
|
||||
AppSearchService.executeCoreApp(appData.coreAppData);
|
||||
return;
|
||||
}
|
||||
const pinnedEntry = cachedDesktopEntry;
|
||||
if (pinnedEntry) {
|
||||
AppUsageHistoryData.addAppUsage({
|
||||
@@ -248,6 +274,10 @@ Item {
|
||||
if (appData.windowCount === 0) {
|
||||
if (!appData.appId)
|
||||
return;
|
||||
if (appData.isCoreApp && appData.coreAppData) {
|
||||
AppSearchService.executeCoreApp(appData.coreAppData);
|
||||
return;
|
||||
}
|
||||
const groupedEntry = cachedDesktopEntry;
|
||||
if (groupedEntry) {
|
||||
AppUsageHistoryData.addAppUsage({
|
||||
@@ -374,6 +404,19 @@ Item {
|
||||
z: -1
|
||||
}
|
||||
|
||||
AppIconRenderer {
|
||||
id: coreIcon
|
||||
|
||||
anchors.centerIn: parent
|
||||
iconSize: actualIconSize
|
||||
iconValue: appData && appData.isCoreApp && appData.coreAppData ? (appData.coreAppData.icon || "") : ""
|
||||
colorOverride: effectiveCoreIconColor
|
||||
brightnessOverride: effectiveCoreIconBrightness
|
||||
contrastOverride: effectiveCoreIconContrast
|
||||
fallbackText: "?"
|
||||
visible: iconValue !== ""
|
||||
}
|
||||
|
||||
IconImage {
|
||||
id: iconImg
|
||||
|
||||
@@ -383,12 +426,15 @@ Item {
|
||||
if (!appData || appData.appId === "__SEPARATOR__") {
|
||||
return "";
|
||||
}
|
||||
if (appData.isCoreApp && appData.coreAppData) {
|
||||
return "";
|
||||
}
|
||||
return Paths.getAppIcon(appData.appId, cachedDesktopEntry);
|
||||
}
|
||||
mipmap: true
|
||||
smooth: true
|
||||
asynchronous: true
|
||||
visible: status === Image.Ready
|
||||
visible: status === Image.Ready && !coreIcon.visible
|
||||
layer.enabled: appData && appData.appId === "org.quickshell"
|
||||
layer.smooth: true
|
||||
layer.mipmap: true
|
||||
@@ -403,7 +449,7 @@ Item {
|
||||
width: actualIconSize
|
||||
height: actualIconSize
|
||||
anchors.centerIn: parent
|
||||
visible: iconImg.status !== Image.Ready && appData && appData.appId && !Paths.isSteamApp(appData.appId)
|
||||
visible: !coreIcon.visible && iconImg.status !== Image.Ready && appData && appData.appId && !Paths.isSteamApp(appData.appId)
|
||||
color: Theme.surfaceLight
|
||||
radius: Theme.cornerRadius
|
||||
border.width: 1
|
||||
@@ -416,7 +462,12 @@ Item {
|
||||
return "?";
|
||||
}
|
||||
|
||||
const appName = Paths.getAppName(appData.appId, cachedDesktopEntry);
|
||||
let appName;
|
||||
if (appData.isCoreApp && appData.coreAppData) {
|
||||
appName = appData.coreAppData.name || appData.appId;
|
||||
} else {
|
||||
appName = Paths.getAppName(appData.appId, cachedDesktopEntry);
|
||||
}
|
||||
return appName.charAt(0).toUpperCase();
|
||||
}
|
||||
font.pixelSize: Math.max(8, parent.width * 0.35)
|
||||
@@ -430,7 +481,7 @@ Item {
|
||||
size: actualIconSize
|
||||
name: "sports_esports"
|
||||
color: Theme.surfaceText
|
||||
visible: iconImg.status !== Image.Ready && appData && appData.appId && Paths.isSteamApp(appData.appId)
|
||||
visible: !coreIcon.visible && iconImg.status !== Image.Ready && appData && appData.appId && Paths.isSteamApp(appData.appId)
|
||||
}
|
||||
|
||||
Loader {
|
||||
|
||||
@@ -91,6 +91,34 @@ Item {
|
||||
return false;
|
||||
}
|
||||
|
||||
function getCoreAppData(appId) {
|
||||
if (typeof AppSearchService === "undefined")
|
||||
return null;
|
||||
|
||||
const coreApps = AppSearchService.coreApps || [];
|
||||
for (let i = 0; i < coreApps.length; i++) {
|
||||
const app = coreApps[i];
|
||||
if (app.builtInPluginId === appId) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function getCoreAppDataByTitle(windowTitle) {
|
||||
if (typeof AppSearchService === "undefined" || !windowTitle)
|
||||
return null;
|
||||
|
||||
const coreApps = AppSearchService.coreApps || [];
|
||||
for (let i = 0; i < coreApps.length; i++) {
|
||||
const app = coreApps[i];
|
||||
if (app.name === windowTitle) {
|
||||
return app;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function insertLauncher(targetArray) {
|
||||
if (!SettingsData.dockLauncherEnabled)
|
||||
return;
|
||||
@@ -119,21 +147,35 @@ Item {
|
||||
|
||||
pinnedApps.forEach(rawAppId => {
|
||||
const appId = Paths.moddedAppId(rawAppId);
|
||||
const coreAppData = getCoreAppData(appId);
|
||||
appGroups.set(appId, {
|
||||
appId: appId,
|
||||
isPinned: true,
|
||||
windows: []
|
||||
windows: [],
|
||||
isCoreApp: coreAppData !== null,
|
||||
coreAppData: coreAppData
|
||||
});
|
||||
});
|
||||
|
||||
sortedToplevels.forEach((toplevel, index) => {
|
||||
const rawAppId = toplevel.appId || "unknown";
|
||||
const appId = Paths.moddedAppId(rawAppId);
|
||||
let appId = Paths.moddedAppId(rawAppId);
|
||||
|
||||
let coreAppData = null;
|
||||
if (rawAppId === "org.quickshell") {
|
||||
coreAppData = getCoreAppDataByTitle(toplevel.title);
|
||||
if (coreAppData) {
|
||||
appId = coreAppData.builtInPluginId;
|
||||
}
|
||||
}
|
||||
|
||||
if (!appGroups.has(appId)) {
|
||||
appGroups.set(appId, {
|
||||
appId: appId,
|
||||
isPinned: false,
|
||||
windows: []
|
||||
windows: [],
|
||||
isCoreApp: coreAppData !== null,
|
||||
coreAppData: coreAppData
|
||||
});
|
||||
}
|
||||
|
||||
@@ -157,7 +199,9 @@ Item {
|
||||
isPinned: group.isPinned,
|
||||
isRunning: group.windows.length > 0,
|
||||
windowCount: group.windows.length,
|
||||
allWindows: group.windows
|
||||
allWindows: group.windows,
|
||||
isCoreApp: group.isCoreApp || false,
|
||||
coreAppData: group.coreAppData || null
|
||||
};
|
||||
|
||||
if (group.isPinned) {
|
||||
@@ -187,13 +231,16 @@ Item {
|
||||
} else {
|
||||
pinnedApps.forEach(rawAppId => {
|
||||
const appId = Paths.moddedAppId(rawAppId);
|
||||
const coreAppData = getCoreAppData(appId);
|
||||
items.push({
|
||||
uniqueKey: "pinned_" + appId,
|
||||
type: "pinned",
|
||||
appId: appId,
|
||||
toplevel: null,
|
||||
isPinned: true,
|
||||
isRunning: false
|
||||
isRunning: false,
|
||||
isCoreApp: coreAppData !== null,
|
||||
coreAppData: coreAppData
|
||||
});
|
||||
});
|
||||
|
||||
@@ -224,13 +271,31 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
const rawAppId = toplevel.appId || "unknown";
|
||||
const moddedAppId = Paths.moddedAppId(rawAppId);
|
||||
|
||||
// Check if this is a core app window (e.g., Settings modal with appId "org.quickshell")
|
||||
let coreAppData = null;
|
||||
let isCoreApp = false;
|
||||
if (rawAppId === "org.quickshell") {
|
||||
coreAppData = getCoreAppDataByTitle(toplevel.title);
|
||||
if (coreAppData) {
|
||||
isCoreApp = true;
|
||||
}
|
||||
}
|
||||
|
||||
const finalAppId = isCoreApp ? coreAppData.builtInPluginId : moddedAppId;
|
||||
const isPinned = pinnedApps.indexOf(finalAppId) !== -1;
|
||||
|
||||
items.push({
|
||||
uniqueKey: uniqueKey,
|
||||
type: "window",
|
||||
appId: Paths.moddedAppId(toplevel.appId),
|
||||
appId: finalAppId,
|
||||
toplevel: toplevel,
|
||||
isPinned: false,
|
||||
isRunning: true
|
||||
isPinned: isPinned,
|
||||
isRunning: true,
|
||||
isCoreApp: isCoreApp,
|
||||
coreAppData: coreAppData
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user