Improvements to breadcrumbs, say Home instead of folder name
This commit is contained in:
parent
1bb2d3afca
commit
af6af1cf35
3 changed files with 32 additions and 24 deletions
|
|
@ -1,6 +1,7 @@
|
|||
empty-folder = Empty folder
|
||||
empty-folder-hidden = Empty folder (has hidden items)
|
||||
filesystem = Filesystem
|
||||
home = Home
|
||||
trash = Trash
|
||||
|
||||
# List view
|
||||
|
|
|
|||
23
src/main.rs
23
src/main.rs
|
|
@ -321,9 +321,15 @@ impl Application for App {
|
|||
let app_themes = vec![fl!("match-desktop"), fl!("dark"), fl!("light")];
|
||||
|
||||
let mut nav_model = segmented_button::ModelBuilder::default();
|
||||
if let Some(dir) = dirs::home_dir() {
|
||||
nav_model = nav_model.insert(move |b| {
|
||||
b.text(fl!("home"))
|
||||
.icon(widget::icon::icon(tab::folder_icon_symbolic(&dir, 16)).size(16))
|
||||
.data(Location::Path(dir.clone()))
|
||||
});
|
||||
}
|
||||
//TODO: Sort by name?
|
||||
for dir_opt in &[
|
||||
dirs::home_dir(),
|
||||
dirs::document_dir(),
|
||||
dirs::download_dir(),
|
||||
dirs::audio_dir(),
|
||||
|
|
@ -669,21 +675,6 @@ impl Application for App {
|
|||
]
|
||||
}
|
||||
|
||||
fn header_center(&self) -> Vec<Element<Self::Message>> {
|
||||
let cosmic_theme::Spacing { space_xxs, .. } = self.core().system_theme().cosmic().spacing;
|
||||
|
||||
let entity = self.tab_model.active();
|
||||
let tab = match self.tab_model.data::<Tab>(entity) {
|
||||
Some(some) => some,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
||||
vec![tab
|
||||
.breadcrumbs_view(&self.core)
|
||||
.map(move |message| Message::TabMessage(Some(entity), message))
|
||||
.into()]
|
||||
}
|
||||
|
||||
fn header_end(&self) -> Vec<Element<Self::Message>> {
|
||||
vec![
|
||||
//TODO: use defined space
|
||||
|
|
|
|||
32
src/tab.rs
32
src/tab.rs
|
|
@ -4,7 +4,11 @@ use cosmic::{
|
|||
iced::{
|
||||
alignment::{Horizontal, Vertical},
|
||||
keyboard::Modifiers,
|
||||
Alignment, Length, Point,
|
||||
//TODO: export in cosmic::widget
|
||||
widget::horizontal_rule,
|
||||
Alignment,
|
||||
Length,
|
||||
Point,
|
||||
},
|
||||
theme, widget, Element,
|
||||
};
|
||||
|
|
@ -626,9 +630,11 @@ impl Tab {
|
|||
widget::icon::icon(folder_icon_symbolic(&ancestor, 16))
|
||||
.size(16),
|
||||
);
|
||||
row = row.push(widget::text(fl!("home")));
|
||||
found_home = true;
|
||||
} else {
|
||||
row = row.push(widget::text(name.to_string_lossy().to_string()));
|
||||
}
|
||||
row = row.push(widget::text(name.to_string_lossy().to_string()));
|
||||
}
|
||||
None => {
|
||||
row = row.push(
|
||||
|
|
@ -641,14 +647,19 @@ impl Tab {
|
|||
}
|
||||
|
||||
if !children.is_empty() {
|
||||
children.push(widget::text("/").into());
|
||||
children.push(
|
||||
widget::icon::from_name("go-next-symbolic")
|
||||
.size(16)
|
||||
.icon()
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
children.push(
|
||||
widget::button(row)
|
||||
.padding(space_xxxs)
|
||||
.on_press(Message::Location(Location::Path(ancestor)))
|
||||
.style(theme::Button::Text)
|
||||
.style(theme::Button::Link)
|
||||
.into(),
|
||||
);
|
||||
|
||||
|
|
@ -676,8 +687,8 @@ impl Tab {
|
|||
}
|
||||
children.push(widget::horizontal_space(Length::Fill).into());
|
||||
|
||||
widget::container(widget::row::with_children(children).align_items(Alignment::Center))
|
||||
.style(theme::Container::Primary)
|
||||
widget::row::with_children(children)
|
||||
.align_items(Alignment::Center)
|
||||
.into()
|
||||
}
|
||||
|
||||
|
|
@ -765,6 +776,8 @@ impl Tab {
|
|||
|
||||
let mut children: Vec<Element<_>> = Vec::new();
|
||||
|
||||
children.push(self.breadcrumbs_view(core));
|
||||
|
||||
children.push(
|
||||
widget::row::with_children(vec![
|
||||
widget::text::heading(fl!("name"))
|
||||
|
|
@ -784,8 +797,7 @@ impl Tab {
|
|||
.into(),
|
||||
);
|
||||
|
||||
//TODO: export in cosmic::widget
|
||||
children.push(cosmic::iced::widget::horizontal_rule(1).into());
|
||||
children.push(horizontal_rule(1).into());
|
||||
|
||||
if let Some(ref items) = self.items_opt {
|
||||
let mut count = 0;
|
||||
|
|
@ -797,6 +809,10 @@ impl Tab {
|
|||
continue;
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
children.push(horizontal_rule(1).into());
|
||||
}
|
||||
|
||||
let modified_text = match &item.metadata {
|
||||
ItemMetadata::Path(metadata, _children) => match metadata.modified() {
|
||||
Ok(time) => chrono::DateTime::<chrono::Local>::from(time)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue