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

Simplify font picking and elide contents

This commit is contained in:
bbedward
2025-10-13 14:58:24 -04:00
parent 6814b140fc
commit d63c0fc6f0
4 changed files with 30 additions and 78 deletions

View File

@@ -155,7 +155,6 @@ Item {
target: Theme
function onIsLightModeChanged() { root.requestRepaint() }
function onSurfaceChanged() { root.requestRepaint() }
function onStateLayerOpacityChanged() { root.requestRepaint() }
}
onPaint: {

View File

@@ -17,67 +17,37 @@ Item {
property bool fontsEnumerated: false
function enumerateFonts() {
var fonts = ["Default"]
var fonts = []
var availableFonts = Qt.fontFamilies()
var rootFamilies = []
var seenFamilies = new Set()
for (var i = 0; i < availableFonts.length; i++) {
var fontName = availableFonts[i]
if (fontName.startsWith("."))
continue
if (fontName === SettingsData.defaultFontFamily)
continue
var rootName = fontName.replace(
/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i,
"").replace(
/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i,
"").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i,
function (match, suffix) {
return match
}).trim()
if (!seenFamilies.has(rootName) && rootName !== "") {
seenFamilies.add(rootName)
rootFamilies.push(rootName)
}
fonts.push(fontName)
}
cachedFontFamilies = fonts.concat(rootFamilies.sort())
var monoFonts = ["Default"]
var monoFamilies = []
var seenMonoFamilies = new Set()
fonts.sort()
fonts.unshift("Default")
cachedFontFamilies = fonts
var monoFonts = []
for (var j = 0; j < availableFonts.length; j++) {
var fontName2 = availableFonts[j]
if (fontName2.startsWith("."))
continue
if (fontName2 === SettingsData.defaultMonoFontFamily)
continue
var lowerName = fontName2.toLowerCase()
if (lowerName.includes("mono") || lowerName.includes(
"code") || lowerName.includes(
"console") || lowerName.includes(
"terminal") || lowerName.includes(
"courier") || lowerName.includes(
"dejavu sans mono") || lowerName.includes(
"jetbrains") || lowerName.includes(
"fira") || lowerName.includes(
"hack") || lowerName.includes(
"source code") || lowerName.includes(
"ubuntu mono") || lowerName.includes("cascadia")) {
var rootName2 = fontName2.replace(
/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i,
"").replace(
/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i,
"").trim()
if (!seenMonoFamilies.has(rootName2) && rootName2 !== "") {
seenMonoFamilies.add(rootName2)
monoFamilies.push(rootName2)
}
if (lowerName.includes("mono") || lowerName.includes("code") ||
lowerName.includes("console") || lowerName.includes("terminal") ||
lowerName.includes("courier") || lowerName.includes("jetbrains") ||
lowerName.includes("fira") || lowerName.includes("hack") ||
lowerName.includes("source code") || lowerName.includes("cascadia")) {
monoFonts.push(fontName2)
}
}
cachedMonoFamilies = monoFonts.concat(monoFamilies.sort())
monoFonts.sort()
monoFonts.unshift("Default")
cachedMonoFamilies = monoFonts
}
Component.onCompleted: {
@@ -1064,7 +1034,7 @@ Item {
enableFuzzySearch: true
popupWidthOffset: 100
maxPopupHeight: 400
options: cachedFontFamilies
options: cachedMonoFamilies
onValueChanged: value => {
if (value === "Default")
SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily)

View File

@@ -249,21 +249,18 @@ Singleton {
// Plugin launcher support functions
function getPluginCategories() {
if (typeof PluginService === "undefined") {
console.log("AppSearchService: PluginService undefined")
return []
}
const categories = []
const launchers = PluginService.getLauncherPlugins()
for (const pluginId in launchers) {
const plugin = launchers[pluginId]
const categoryName = plugin.name || pluginId
console.log("AppSearchService: Adding plugin category:", categoryName, "for plugin:", pluginId)
categories.push(categoryName)
}
console.log("AppSearchService: Returning plugin categories:", categories)
return categories
}
@@ -282,23 +279,18 @@ Singleton {
function getAllPluginItems() {
if (typeof PluginService === "undefined") {
console.log("AppSearchService: PluginService undefined in getAllPluginItems")
return []
}
let allItems = []
const launchers = PluginService.getLauncherPlugins()
console.log("AppSearchService: getAllPluginItems() processing", Object.keys(launchers).length, "launcher plugins")
for (const pluginId in launchers) {
const categoryName = launchers[pluginId].name || pluginId
console.log("AppSearchService: Getting items for plugin:", pluginId, "category:", categoryName)
const items = getPluginItems(categoryName, "")
console.log("AppSearchService: Plugin", pluginId, "returned", items.length, "items")
allItems = allItems.concat(items)
}
console.log("AppSearchService: getAllPluginItems() returning", allItems.length, "total items")
return allItems
}
@@ -316,41 +308,31 @@ Singleton {
}
function getPluginItemsForPlugin(pluginId, query) {
console.log("AppSearchService: getPluginItemsForPlugin called for", pluginId, "with query:", query)
if (typeof PluginService === "undefined") {
console.log("AppSearchService: PluginService undefined")
return []
}
const component = PluginService.pluginLauncherComponents[pluginId]
console.log("AppSearchService: Component for", pluginId, ":", component ? "found" : "not found")
if (!component) return []
try {
console.log("AppSearchService: Creating instance for", pluginId)
const instance = component.createObject(root, {
"pluginService": PluginService
})
console.log("AppSearchService: Instance created:", instance ? "success" : "failed")
if (instance && typeof instance.getItems === "function") {
console.log("AppSearchService: Calling getItems on", pluginId)
const items = instance.getItems(query || "")
console.log("AppSearchService: Got", items ? items.length : 0, "items from", pluginId)
instance.destroy()
return items || []
} else {
console.log("AppSearchService: Instance has no getItems function")
}
if (instance) {
instance.destroy()
}
} catch (e) {
console.warn("AppSearchService: Error getting items from plugin", pluginId, ":", e)
}
console.log("AppSearchService: Returning empty array for", pluginId)
return []
}

View File

@@ -143,6 +143,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
width: contentRow.width - (contentRow.children[0].visible ? contentRow.children[0].width + contentRow.spacing : 0)
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
}