Add icons to TUI.

This commit is contained in:
2026-02-22 11:35:25 -05:00
parent 5b356781ba
commit 2e67c01377
7 changed files with 24 additions and 12 deletions

View File

@@ -3,7 +3,6 @@
// SPDX-License-Identifier: GNU General Public License v3.0 or later
use cxx_qt_lib::{QModelIndex, QString};
use devicons::FileIcon;
use dirs;
use std::fs;
use std::path::Path;
@@ -142,13 +141,6 @@ impl qobject::FileSystem {
}
fn icon(self: std::pin::Pin<&mut Self>, path: &QString) -> QString {
let str = path.to_string();
if Path::new(&str).is_dir() {
// Ensures directories are given a folder icon and not mistakenly resolved to a language.
// For example, a directory named `cpp` would otherwise return a C++ icon.
return QString::from(FileIcon::from("dir/").to_string());
}
let icon = FileIcon::from(str);
QString::from(icon.to_string())
QString::from(libclide::fs::icon(path.to_string().as_str()).to_string())
}
}

View File

@@ -63,7 +63,7 @@ impl<'a> Explorer<'a> {
} else {
children.push(TreeItem::new_leaf(
entry_meta.abs_path.clone(),
entry_meta.file_name.clone(),
format!("{} {}", entry_meta.icon.icon, entry_meta.file_name.as_str()),
));
}
}
@@ -73,7 +73,7 @@ impl<'a> Explorer<'a> {
// For a file tree this is fine because we shouldn't list the same object twice.
TreeItem::new(
path_meta.abs_path.clone(),
path_meta.file_name.clone(),
format!("{} {}", path_meta.icon.icon, path_meta.file_name.as_str()),
children,
)
.context(format!(