Add previous, next, and open to preview
This commit is contained in:
parent
bdd3450614
commit
60009324c8
3 changed files with 85 additions and 36 deletions
|
|
@ -157,7 +157,7 @@ impl Action {
|
||||||
Action::MoveToTrash => Message::MoveToTrash(entity_opt),
|
Action::MoveToTrash => Message::MoveToTrash(entity_opt),
|
||||||
Action::NewFile => Message::NewItem(entity_opt, false),
|
Action::NewFile => Message::NewItem(entity_opt, false),
|
||||||
Action::NewFolder => Message::NewItem(entity_opt, true),
|
Action::NewFolder => Message::NewItem(entity_opt, true),
|
||||||
Action::Open => Message::TabMessage(entity_opt, tab::Message::Open),
|
Action::Open => Message::TabMessage(entity_opt, tab::Message::Open(None)),
|
||||||
Action::OpenInNewTab => Message::OpenInNewTab(entity_opt),
|
Action::OpenInNewTab => Message::OpenInNewTab(entity_opt),
|
||||||
Action::OpenInNewWindow => Message::OpenInNewWindow(entity_opt),
|
Action::OpenInNewWindow => Message::OpenInNewWindow(entity_opt),
|
||||||
Action::OpenItemLocation => Message::OpenItemLocation(entity_opt),
|
Action::OpenItemLocation => Message::OpenItemLocation(entity_opt),
|
||||||
|
|
@ -969,14 +969,14 @@ impl App {
|
||||||
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
let entity = entity_opt.unwrap_or_else(|| self.tab_model.active());
|
||||||
match kind {
|
match kind {
|
||||||
PreviewKind::Custom(PreviewItem(item)) => {
|
PreviewKind::Custom(PreviewItem(item)) => {
|
||||||
children.push(item.property_view(IconSizes::default()));
|
children.push(item.preview_view(IconSizes::default()));
|
||||||
}
|
}
|
||||||
PreviewKind::Location(location) => {
|
PreviewKind::Location(location) => {
|
||||||
if let Some(tab) = self.tab_model.data::<Tab>(entity) {
|
if let Some(tab) = self.tab_model.data::<Tab>(entity) {
|
||||||
if let Some(items) = tab.items_opt() {
|
if let Some(items) = tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.location_opt.as_ref() == Some(location) {
|
if item.location_opt.as_ref() == Some(location) {
|
||||||
children.push(item.property_view(tab.config.icon_sizes));
|
children.push(item.preview_view(tab.config.icon_sizes));
|
||||||
// Only show one property view to avoid issues like hangs when generating
|
// Only show one property view to avoid issues like hangs when generating
|
||||||
// preview images on thousands of files
|
// preview images on thousands of files
|
||||||
break;
|
break;
|
||||||
|
|
@ -990,7 +990,7 @@ impl App {
|
||||||
if let Some(items) = tab.items_opt() {
|
if let Some(items) = tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.selected {
|
if item.selected {
|
||||||
children.push(item.property_view(tab.config.icon_sizes));
|
children.push(item.preview_view(tab.config.icon_sizes));
|
||||||
// Only show one property view to avoid issues like hangs when generating
|
// Only show one property view to avoid issues like hangs when generating
|
||||||
// preview images on thousands of files
|
// preview images on thousands of files
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -393,13 +393,13 @@ impl App {
|
||||||
let mut children = Vec::with_capacity(1);
|
let mut children = Vec::with_capacity(1);
|
||||||
match kind {
|
match kind {
|
||||||
PreviewKind::Custom(PreviewItem(item)) => {
|
PreviewKind::Custom(PreviewItem(item)) => {
|
||||||
children.push(item.property_view(IconSizes::default()));
|
children.push(item.preview_view(IconSizes::default()));
|
||||||
}
|
}
|
||||||
PreviewKind::Location(location) => {
|
PreviewKind::Location(location) => {
|
||||||
if let Some(items) = self.tab.items_opt() {
|
if let Some(items) = self.tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.location_opt.as_ref() == Some(location) {
|
if item.location_opt.as_ref() == Some(location) {
|
||||||
children.push(item.property_view(self.tab.config.icon_sizes));
|
children.push(item.preview_view(self.tab.config.icon_sizes));
|
||||||
// Only show one property view to avoid issues like hangs when generating
|
// Only show one property view to avoid issues like hangs when generating
|
||||||
// preview images on thousands of files
|
// preview images on thousands of files
|
||||||
break;
|
break;
|
||||||
|
|
@ -411,7 +411,7 @@ impl App {
|
||||||
if let Some(items) = self.tab.items_opt() {
|
if let Some(items) = self.tab.items_opt() {
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
if item.selected {
|
if item.selected {
|
||||||
children.push(item.property_view(self.tab.config.icon_sizes));
|
children.push(item.preview_view(self.tab.config.icon_sizes));
|
||||||
// Only show one property view to avoid issues like hangs when generating
|
// Only show one property view to avoid issues like hangs when generating
|
||||||
// preview images on thousands of files
|
// preview images on thousands of files
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
107
src/tab.rs
107
src/tab.rs
|
|
@ -845,7 +845,7 @@ pub enum Message {
|
||||||
ItemUp,
|
ItemUp,
|
||||||
Location(Location),
|
Location(Location),
|
||||||
LocationUp,
|
LocationUp,
|
||||||
Open,
|
Open(Option<PathBuf>),
|
||||||
RightClick(Option<usize>),
|
RightClick(Option<usize>),
|
||||||
MiddleClick(usize),
|
MiddleClick(usize),
|
||||||
Scroll(Viewport),
|
Scroll(Viewport),
|
||||||
|
|
@ -1025,10 +1025,40 @@ impl Item {
|
||||||
column.into()
|
column.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn property_view(&self, sizes: IconSizes) -> Element<'static, app::Message> {
|
pub fn preview_view(&self, sizes: IconSizes) -> Element<'static, app::Message> {
|
||||||
let cosmic_theme::Spacing { space_xxxs, .. } = theme::active().cosmic().spacing;
|
let cosmic_theme::Spacing {
|
||||||
|
space_xxxs,
|
||||||
|
space_xxs,
|
||||||
|
space_m,
|
||||||
|
..
|
||||||
|
} = theme::active().cosmic().spacing;
|
||||||
|
|
||||||
let mut column = widget::column().spacing(space_xxxs);
|
let mut column = widget::column().spacing(space_m);
|
||||||
|
|
||||||
|
let mut row = widget::row::with_capacity(3).spacing(space_xxs);
|
||||||
|
row = row.push(
|
||||||
|
widget::button::icon(widget::icon::from_name("go-previous-symbolic"))
|
||||||
|
.on_press(app::Message::TabMessage(None, Message::ItemLeft)),
|
||||||
|
);
|
||||||
|
row = row.push(
|
||||||
|
widget::button::icon(widget::icon::from_name("go-next-symbolic"))
|
||||||
|
.on_press(app::Message::TabMessage(None, Message::ItemRight)),
|
||||||
|
);
|
||||||
|
/*
|
||||||
|
match self
|
||||||
|
.thumbnail_opt
|
||||||
|
.as_ref()
|
||||||
|
.unwrap_or(&ItemThumbnail::NotImage)
|
||||||
|
{
|
||||||
|
ItemThumbnail::NotImage => {}
|
||||||
|
_ => {
|
||||||
|
row = row.push(widget::button::icon(widget::icon::from_name(
|
||||||
|
"window-maximize-symbolic",
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
column = column.push(row);
|
||||||
|
|
||||||
column = column.push(widget::row::with_children(vec![
|
column = column.push(widget::row::with_children(vec![
|
||||||
widget::horizontal_space(Length::Fill).into(),
|
widget::horizontal_space(Length::Fill).into(),
|
||||||
|
|
@ -1036,37 +1066,38 @@ impl Item {
|
||||||
widget::horizontal_space(Length::Fill).into(),
|
widget::horizontal_space(Length::Fill).into(),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
column = column.push(widget::text::heading(self.name.clone()));
|
let mut details = widget::column().spacing(space_xxxs);
|
||||||
|
details = details.push(widget::text::heading(self.name.clone()));
|
||||||
column = column.push(widget::text(format!("Type: {}", self.mime)));
|
details = details.push(widget::text(format!("Type: {}", self.mime)));
|
||||||
|
|
||||||
//TODO: translate!
|
//TODO: translate!
|
||||||
//TODO: correct display of folder size?
|
//TODO: correct display of folder size?
|
||||||
match &self.metadata {
|
match &self.metadata {
|
||||||
ItemMetadata::Path { metadata, children } => {
|
ItemMetadata::Path { metadata, children } => {
|
||||||
if metadata.is_dir() {
|
if metadata.is_dir() {
|
||||||
column = column.push(widget::text(format!("Items: {}", children)));
|
details = details.push(widget::text(format!("Items: {}", children)));
|
||||||
} else {
|
} else {
|
||||||
column = column.push(widget::text(format!(
|
details = details.push(widget::text(format!(
|
||||||
"Size: {}",
|
"Size: {}",
|
||||||
format_size(metadata.len())
|
format_size(metadata.len())
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(time) = metadata.created() {
|
if let Ok(time) = metadata.created() {
|
||||||
column = column.push(widget::text(format!("Created: {}", format_time(time))));
|
details = details.push(widget::text(format!("Created: {}", format_time(time))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(time) = metadata.modified() {
|
if let Ok(time) = metadata.modified() {
|
||||||
column = column.push(widget::text(format!("Modified: {}", format_time(time))));
|
details =
|
||||||
|
details.push(widget::text(format!("Modified: {}", format_time(time))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(time) = metadata.accessed() {
|
if let Ok(time) = metadata.accessed() {
|
||||||
column = column.push(widget::text(format!("Accessed: {}", format_time(time))));
|
details =
|
||||||
|
details.push(widget::text(format!("Accessed: {}", format_time(time))));
|
||||||
}
|
}
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
{
|
{
|
||||||
column = column.push(
|
details = details.push(
|
||||||
widget::Row::new()
|
widget::Row::new()
|
||||||
.push(widget::text(format!("{}:", fl!("owner"))))
|
.push(widget::text(format!("{}:", fl!("owner"))))
|
||||||
.push(widget::text(format_permissions_owner(
|
.push(widget::text(format_permissions_owner(
|
||||||
|
|
@ -1080,7 +1111,7 @@ impl Item {
|
||||||
.spacing(10),
|
.spacing(10),
|
||||||
);
|
);
|
||||||
|
|
||||||
column = column.push(
|
details = details.push(
|
||||||
widget::Row::new()
|
widget::Row::new()
|
||||||
.push(widget::text(format!("{}:", fl!("group"))))
|
.push(widget::text(format!("{}:", fl!("group"))))
|
||||||
.push(widget::text(format_permissions_owner(
|
.push(widget::text(format_permissions_owner(
|
||||||
|
|
@ -1094,7 +1125,7 @@ impl Item {
|
||||||
.spacing(10),
|
.spacing(10),
|
||||||
);
|
);
|
||||||
|
|
||||||
column = column.push(
|
details = details.push(
|
||||||
widget::Row::new()
|
widget::Row::new()
|
||||||
.push(widget::text(format!("{}", fl!("other"))))
|
.push(widget::text(format!("{}", fl!("other"))))
|
||||||
.push(widget::text(format!(
|
.push(widget::text(format!(
|
||||||
|
|
@ -1109,6 +1140,13 @@ impl Item {
|
||||||
//TODO: other metadata types
|
//TODO: other metadata types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
column = column.push(details);
|
||||||
|
|
||||||
|
if let Some(path) = self.path_opt() {
|
||||||
|
column = column.push(widget::button::standard(fl!("open")).on_press(
|
||||||
|
app::Message::TabMessage(None, Message::Open(Some(path.to_path_buf()))),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
column.into()
|
column.into()
|
||||||
}
|
}
|
||||||
|
|
@ -2031,21 +2069,32 @@ impl Tab {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Message::Open => {
|
Message::Open(path_opt) => {
|
||||||
if let Some(ref mut items) = self.items_opt {
|
match path_opt {
|
||||||
for item in items.iter() {
|
Some(path) => {
|
||||||
if item.selected {
|
if path.is_dir() {
|
||||||
if let Some(location) = &item.location_opt {
|
cd = Some(Location::Path(path));
|
||||||
if item.metadata.is_dir() {
|
} else {
|
||||||
//TODO: allow opening multiple tabs?
|
commands.push(Command::OpenFile(path));
|
||||||
cd = Some(location.clone());
|
}
|
||||||
} else {
|
}
|
||||||
if let Location::Path(path) = location {
|
None => {
|
||||||
commands.push(Command::OpenFile(path.clone()));
|
if let Some(ref mut items) = self.items_opt {
|
||||||
|
for item in items.iter() {
|
||||||
|
if item.selected {
|
||||||
|
if let Some(location) = &item.location_opt {
|
||||||
|
if item.metadata.is_dir() {
|
||||||
|
//TODO: allow opening multiple tabs?
|
||||||
|
cd = Some(location.clone());
|
||||||
|
} else {
|
||||||
|
if let Location::Path(path) = location {
|
||||||
|
commands.push(Command::OpenFile(path.clone()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//TODO: open properties?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
//TODO: open properties?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue