1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-31 08:52:49 -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 target: Theme
function onIsLightModeChanged() { root.requestRepaint() } function onIsLightModeChanged() { root.requestRepaint() }
function onSurfaceChanged() { root.requestRepaint() } function onSurfaceChanged() { root.requestRepaint() }
function onStateLayerOpacityChanged() { root.requestRepaint() }
} }
onPaint: { onPaint: {

View File

@@ -17,67 +17,37 @@ Item {
property bool fontsEnumerated: false property bool fontsEnumerated: false
function enumerateFonts() { function enumerateFonts() {
var fonts = ["Default"] var fonts = []
var availableFonts = Qt.fontFamilies() var availableFonts = Qt.fontFamilies()
var rootFamilies = []
var seenFamilies = new Set()
for (var i = 0; i < availableFonts.length; i++) { for (var i = 0; i < availableFonts.length; i++) {
var fontName = availableFonts[i] var fontName = availableFonts[i]
if (fontName.startsWith(".")) if (fontName.startsWith("."))
continue continue
fonts.push(fontName)
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)
}
} }
cachedFontFamilies = fonts.concat(rootFamilies.sort()) fonts.sort()
var monoFonts = ["Default"] fonts.unshift("Default")
var monoFamilies = [] cachedFontFamilies = fonts
var seenMonoFamilies = new Set()
var monoFonts = []
for (var j = 0; j < availableFonts.length; j++) { for (var j = 0; j < availableFonts.length; j++) {
var fontName2 = availableFonts[j] var fontName2 = availableFonts[j]
if (fontName2.startsWith(".")) if (fontName2.startsWith("."))
continue continue
if (fontName2 === SettingsData.defaultMonoFontFamily)
continue
var lowerName = fontName2.toLowerCase() var lowerName = fontName2.toLowerCase()
if (lowerName.includes("mono") || lowerName.includes( if (lowerName.includes("mono") || lowerName.includes("code") ||
"code") || lowerName.includes( lowerName.includes("console") || lowerName.includes("terminal") ||
"console") || lowerName.includes( lowerName.includes("courier") || lowerName.includes("jetbrains") ||
"terminal") || lowerName.includes( lowerName.includes("fira") || lowerName.includes("hack") ||
"courier") || lowerName.includes( lowerName.includes("source code") || lowerName.includes("cascadia")) {
"dejavu sans mono") || lowerName.includes( monoFonts.push(fontName2)
"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)
}
} }
} }
cachedMonoFamilies = monoFonts.concat(monoFamilies.sort()) monoFonts.sort()
monoFonts.unshift("Default")
cachedMonoFamilies = monoFonts
} }
Component.onCompleted: { Component.onCompleted: {
@@ -1064,7 +1034,7 @@ Item {
enableFuzzySearch: true enableFuzzySearch: true
popupWidthOffset: 100 popupWidthOffset: 100
maxPopupHeight: 400 maxPopupHeight: 400
options: cachedFontFamilies options: cachedMonoFamilies
onValueChanged: value => { onValueChanged: value => {
if (value === "Default") if (value === "Default")
SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily) SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily)

View File

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

View File

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