Remove unused icon sizes argument from preview

This commit is contained in:
Jeremy Soller 2025-04-30 08:27:55 -06:00
parent 6fa890e3f3
commit 037190babd
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA
3 changed files with 21 additions and 49 deletions

View file

@ -1605,22 +1605,16 @@ impl App {
let military_time = self.config.tab.military_time;
match kind {
PreviewKind::Custom(PreviewItem(item)) => {
children.push(item.preview_view(
Some(&self.mime_app_cache),
IconSizes::default(),
military_time,
));
children.push(item.preview_view(Some(&self.mime_app_cache), military_time));
}
PreviewKind::Location(location) => {
if let Some(tab) = self.tab_model.data::<Tab>(entity) {
if let Some(items) = tab.items_opt() {
for item in items.iter() {
if item.location_opt.as_ref() == Some(location) {
children.push(item.preview_view(
Some(&self.mime_app_cache),
tab.config.icon_sizes,
military_time,
));
children.push(
item.preview_view(Some(&self.mime_app_cache), military_time),
);
// Only show one property view to avoid issues like hangs when generating
// preview images on thousands of files
break;
@ -1634,11 +1628,9 @@ impl App {
if let Some(items) = tab.items_opt() {
for item in items.iter() {
if item.selected {
children.push(item.preview_view(
Some(&self.mime_app_cache),
tab.config.icon_sizes,
military_time,
));
children.push(
item.preview_view(Some(&self.mime_app_cache), military_time),
);
// Only show one property view to avoid issues like hangs when generating
// preview images on thousands of files
break;
@ -1646,11 +1638,9 @@ impl App {
}
if children.is_empty() {
if let Some(item) = &tab.parent_item_opt {
children.push(item.preview_view(
Some(&self.mime_app_cache),
tab.config.icon_sizes,
military_time,
));
children.push(
item.preview_view(Some(&self.mime_app_cache), military_time),
);
}
}
}
@ -4799,11 +4789,11 @@ impl Application for App {
.title(fl!("replace-title", filename = to.name.as_str()))
.body(fl!("replace-warning-operation"))
.control(
to.replace_view(fl!("original-file"), IconSizes::default(), military_time)
to.replace_view(fl!("original-file"), military_time)
.map(|x| Message::TabMessage(None, x)),
)
.control(
from.replace_view(fl!("replace-with"), IconSizes::default(), military_time)
from.replace_view(fl!("replace-with"), military_time)
.map(|x| Message::TabMessage(None, x)),
)
.primary_action(widget::button::suggested(fl!("replace")).on_press(

View file

@ -36,7 +36,7 @@ use std::{
use crate::{
app::{Action, ContextPage, Message as AppMessage, PreviewItem, PreviewKind},
config::{Config, Favorite, IconSizes, TabConfig, TimeConfig, TIME_CONFIG_ID},
config::{Config, Favorite, TabConfig, TimeConfig, TIME_CONFIG_ID},
fl, home_dir,
key_bind::key_binds,
localize::LANGUAGE_SORTER,
@ -576,17 +576,13 @@ impl App {
let mut children = Vec::with_capacity(1);
match kind {
PreviewKind::Custom(PreviewItem(item)) => {
children.push(item.preview_view(None, IconSizes::default(), military_time));
children.push(item.preview_view(None, military_time));
}
PreviewKind::Location(location) => {
if let Some(items) = self.tab.items_opt() {
for item in items.iter() {
if item.location_opt.as_ref() == Some(location) {
children.push(item.preview_view(
None,
self.tab.config.icon_sizes,
military_time,
));
children.push(item.preview_view(None, military_time));
// Only show one property view to avoid issues like hangs when generating
// preview images on thousands of files
break;
@ -598,11 +594,7 @@ impl App {
if let Some(items) = self.tab.items_opt() {
for item in items.iter() {
if item.selected {
children.push(item.preview_view(
None,
self.tab.config.icon_sizes,
military_time,
));
children.push(item.preview_view(None, military_time));
// Only show one property view to avoid issues like hangs when generating
// preview images on thousands of files
break;
@ -610,11 +602,7 @@ impl App {
}
if children.is_empty() {
if let Some(item) = &self.tab.parent_item_opt {
children.push(item.preview_view(
None,
self.tab.config.icon_sizes,
military_time,
));
children.push(item.preview_view(None, military_time));
}
}
}

View file

@ -1605,7 +1605,7 @@ impl Item {
self.mime.type_() == mime::IMAGE || self.mime.type_() == mime::TEXT
}
fn preview(&self, sizes: IconSizes) -> Element<'_, Message> {
fn preview(&self) -> Element<'_, Message> {
let spacing = cosmic::theme::active().cosmic().spacing;
// This loads the image only if thumbnailing worked
let icon = widget::icon::icon(self.icon_handle_grid.clone())
@ -1665,7 +1665,6 @@ impl Item {
pub fn preview_view<'a>(
&'a self,
mime_app_cache_opt: Option<&'a mime_app::MimeAppCache>,
sizes: IconSizes,
military_time: bool,
) -> Element<'a, Message> {
let cosmic_theme::Spacing {
@ -1677,7 +1676,7 @@ impl Item {
let mut column = widget::column().spacing(space_m);
column = column.push(
widget::container(self.preview(sizes))
widget::container(self.preview())
.center_x(Length::Fill)
.max_height(THUMBNAIL_SIZE as f32),
);
@ -1824,16 +1823,11 @@ impl Item {
column.into()
}
pub fn replace_view(
&self,
heading: String,
sizes: IconSizes,
military_time: bool,
) -> Element<'_, Message> {
pub fn replace_view(&self, heading: String, military_time: bool) -> Element<'_, Message> {
let cosmic_theme::Spacing { space_xxxs, .. } = theme::active().cosmic().spacing;
let mut row = widget::row().spacing(space_xxxs);
row = row.push(self.preview(sizes));
row = row.push(self.preview());
let mut column = widget::column().spacing(space_xxxs);
column = column.push(widget::text::heading(heading));