mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-03 20:32:07 -04:00
doctor: fix imageformats detection (#1811)
This commit is contained in:
@@ -652,16 +652,14 @@ func checkI2CAvailability() checkResult {
|
|||||||
func checkImageFormatPlugins() []checkResult {
|
func checkImageFormatPlugins() []checkResult {
|
||||||
url := doctorDocsURL + "#optional-features"
|
url := doctorDocsURL + "#optional-features"
|
||||||
|
|
||||||
pluginDir := findQtPluginDir()
|
pluginDirs := findQtPluginDirs()
|
||||||
if pluginDir == "" {
|
if len(pluginDirs) == 0 {
|
||||||
return []checkResult{
|
return []checkResult{
|
||||||
{catOptionalFeatures, "qt6-imageformats", statusInfo, "Cannot detect (plugin dir not found)", "WebP, TIFF, JP2 support", url},
|
{catOptionalFeatures, "qt6-imageformats", statusInfo, "Cannot detect (plugin dir not found)", "WebP, TIFF, JP2 support", url},
|
||||||
{catOptionalFeatures, "kimageformats", statusInfo, "Cannot detect (plugin dir not found)", "AVIF, HEIF, JXL support", url},
|
{catOptionalFeatures, "kimageformats", statusInfo, "Cannot detect (plugin dir not found)", "AVIF, HEIF, JXL support", url},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imageFormatsDir := filepath.Join(pluginDir, "imageformats")
|
|
||||||
|
|
||||||
type pluginCheck struct {
|
type pluginCheck struct {
|
||||||
name string
|
name string
|
||||||
desc string
|
desc string
|
||||||
@@ -695,9 +693,18 @@ func checkImageFormatPlugins() []checkResult {
|
|||||||
var results []checkResult
|
var results []checkResult
|
||||||
for _, c := range checks {
|
for _, c := range checks {
|
||||||
var found []string
|
var found []string
|
||||||
for _, p := range c.plugins {
|
var foundDirs []string
|
||||||
if _, err := os.Stat(filepath.Join(imageFormatsDir, p.file)); err == nil {
|
for _, pluginDir := range pluginDirs {
|
||||||
found = append(found, p.format)
|
imageFormatsDir := filepath.Join(pluginDir, "imageformats")
|
||||||
|
for _, p := range c.plugins {
|
||||||
|
if _, err := os.Stat(filepath.Join(imageFormatsDir, p.file)); err == nil {
|
||||||
|
if !slices.Contains(found, p.format) {
|
||||||
|
found = append(found, p.format)
|
||||||
|
}
|
||||||
|
if !slices.Contains(foundDirs, imageFormatsDir) {
|
||||||
|
foundDirs = append(foundDirs, imageFormatsDir)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -708,7 +715,7 @@ func checkImageFormatPlugins() []checkResult {
|
|||||||
default:
|
default:
|
||||||
details := ""
|
details := ""
|
||||||
if doctorVerbose {
|
if doctorVerbose {
|
||||||
details = fmt.Sprintf("Formats: %s (%s)", strings.Join(found, ", "), imageFormatsDir)
|
details = fmt.Sprintf("Formats: %s (%s)", strings.Join(found, ", "), strings.Join(foundDirs, ":"))
|
||||||
}
|
}
|
||||||
result = checkResult{catOptionalFeatures, c.name, statusOK, fmt.Sprintf("Installed (%d formats)", len(found)), details, url}
|
result = checkResult{catOptionalFeatures, c.name, statusOK, fmt.Sprintf("Installed (%d formats)", len(found)), details, url}
|
||||||
}
|
}
|
||||||
@@ -718,22 +725,28 @@ func checkImageFormatPlugins() []checkResult {
|
|||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
func findQtPluginDir() string {
|
func findQtPluginDirs() []string {
|
||||||
// Check QT_PLUGIN_PATH env var first (used by NixOS and custom setups)
|
var dirs []string
|
||||||
|
|
||||||
|
addDir := func(dir string) {
|
||||||
|
if dir != "" {
|
||||||
|
if _, err := os.Stat(filepath.Join(dir, "imageformats")); err == nil {
|
||||||
|
dirs = append(dirs, dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check all paths in QT_PLUGIN_PATH env var (used by NixOS and custom setups)
|
||||||
if envPath := os.Getenv("QT_PLUGIN_PATH"); envPath != "" {
|
if envPath := os.Getenv("QT_PLUGIN_PATH"); envPath != "" {
|
||||||
for dir := range strings.SplitSeq(envPath, ":") {
|
for dir := range strings.SplitSeq(envPath, ":") {
|
||||||
if _, err := os.Stat(filepath.Join(dir, "imageformats")); err == nil {
|
addDir(dir)
|
||||||
return dir
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try qtpaths
|
// Try qtpaths
|
||||||
for _, cmd := range []string{"qtpaths6", "qtpaths"} {
|
for _, cmd := range []string{"qtpaths6", "qtpaths"} {
|
||||||
if output, err := exec.Command(cmd, "-query", "QT_INSTALL_PLUGINS").Output(); err == nil {
|
if output, err := exec.Command(cmd, "-query", "QT_INSTALL_PLUGINS").Output(); err == nil {
|
||||||
if dir := strings.TrimSpace(string(output)); dir != "" {
|
addDir(strings.TrimSpace(string(output)))
|
||||||
return dir
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -744,12 +757,10 @@ func findQtPluginDir() string {
|
|||||||
"/usr/lib/x86_64-linux-gnu/qt6/plugins",
|
"/usr/lib/x86_64-linux-gnu/qt6/plugins",
|
||||||
"/usr/lib/aarch64-linux-gnu/qt6/plugins",
|
"/usr/lib/aarch64-linux-gnu/qt6/plugins",
|
||||||
} {
|
} {
|
||||||
if _, err := os.Stat(filepath.Join(dir, "imageformats")); err == nil {
|
addDir(dir)
|
||||||
return dir
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectNetworkBackend(stackResult *network.DetectResult) string {
|
func detectNetworkBackend(stackResult *network.DetectResult) string {
|
||||||
|
|||||||
Reference in New Issue
Block a user