Merge branch 'master' into move-to

This commit is contained in:
Levi Portenier 2026-02-17 11:30:50 -07:00 committed by GitHub
commit dd5db221e3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 694 additions and 390 deletions

View file

@ -424,6 +424,7 @@ pub enum Message {
SearchClear,
SearchInput(String),
SetShowDetails(bool),
SetShowRecents(bool),
SetTypeToSearch(TypeToSearch),
SystemThemeModeChange,
Size(window::Id, Size),
@ -842,12 +843,14 @@ impl App {
for path in paths {
match open::that_detached(&path) {
Ok(()) => {
let _ = recently_used_xbel::update_recently_used(
&path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
if self.config.show_recents {
let _ = recently_used_xbel::update_recently_used(
&path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
}
}
Err(err) => {
log::warn!("failed to open {}: {}", path.display(), err);
@ -911,13 +914,15 @@ impl App {
for (i, mut command) in commands.into_iter().enumerate() {
match spawn_detached(&mut command) {
Ok(()) => {
for path in paths {
let _ = recently_used_xbel::update_recently_used(
&path.into(),
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
if self.config.show_recents {
for path in paths {
let _ = recently_used_xbel::update_recently_used(
&path.into(),
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
}
}
return true;
@ -1548,11 +1553,13 @@ impl App {
fn update_nav_model(&mut self) {
let mut nav_model = segmented_button::ModelBuilder::default();
nav_model = nav_model.insert(|b| {
b.text(fl!("recents"))
.icon(icon::from_name("document-open-recent-symbolic"))
.data(Location::Recents)
});
if self.config.show_recents {
nav_model = nav_model.insert(|b| {
b.text(fl!("recents"))
.icon(icon::from_name("document-open-recent-symbolic"))
.data(Location::Recents)
});
}
for (favorite_i, favorite) in self.config.favorites.iter().enumerate() {
if let Some(path) = favorite.path_opt() {
@ -2059,6 +2066,10 @@ impl App {
},
)
})
.add({
widget::settings::item::builder(fl!("show-recents"))
.toggler(self.config.show_recents, Message::SetShowRecents)
})
.into(),
])
.into()
@ -2961,12 +2972,14 @@ impl Application for App {
{
match spawn_detached(&mut command) {
Ok(()) => {
let _ = recently_used_xbel::update_recently_used(
&path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
if self.config.show_recents {
let _ = recently_used_xbel::update_recently_used(
&path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
}
}
Err(err) => {
log::warn!(
@ -4029,6 +4042,10 @@ impl Application for App {
config_set!(show_details, show_details);
return self.update_config();
}
Message::SetShowRecents(show_recents) => {
config_set!(show_recents, show_recents);
return self.update_config();
}
Message::SetTypeToSearch(type_to_search) => {
config_set!(type_to_search, type_to_search);
return self.update_config();
@ -4831,7 +4848,9 @@ impl Application for App {
}
},
Message::Recents => {
return self.open_tab(Location::Recents, false, None);
if self.config.show_recents {
return self.open_tab(Location::Recents, false, None);
}
}
#[cfg(all(feature = "wayland", feature = "desktop-applet"))]
Message::OutputEvent(output_event, output) => {
@ -6346,12 +6365,15 @@ impl Application for App {
std::future::pending().await
}),
),
#[cfg(all(
not(feature = "desktop-applet"),
not(target_os = "ios"),
not(target_os = "android")
))]
Subscription::run_with_id(
];
#[cfg(all(
not(feature = "desktop-applet"),
not(target_os = "ios"),
not(target_os = "android")
))]
if self.config.show_recents {
subscriptions.push(Subscription::run_with_id(
TypeId::of::<RecentsWatcherSubscription>(),
stream::channel(1, |mut output| async move {
let Some(recents_path) = recently_used_xbel::dir() else {
@ -6411,8 +6433,8 @@ impl Application for App {
std::future::pending().await
}),
),
];
));
}
if let Some(scroll_speed) = self.auto_scroll_speed {
subscriptions.push(

View file

@ -167,6 +167,7 @@ pub struct Config {
pub thumb_cfg: ThumbCfg,
pub favorites: Vec<Favorite>,
pub show_details: bool,
pub show_recents: bool,
pub tab: TabConfig,
pub type_to_search: TypeToSearch,
}
@ -229,6 +230,7 @@ impl Default for Config {
Favorite::Videos,
],
show_details: false,
show_recents: true,
tab: TabConfig::default(),
type_to_search: TypeToSearch::Recursive,
}

View file

@ -1609,12 +1609,14 @@ impl Application for App {
&& let Some(path) = item.path_opt()
{
paths.push(path.clone());
let _ = update_recently_used(
path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
if self.flags.config.show_recents {
let _ = update_recently_used(
path,
Self::APP_ID.to_string(),
"cosmic-files".to_string(),
None,
);
}
}
}
}

View file

@ -123,7 +123,12 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
} else if &arg == "--trash" {
Location::Trash
} else if &arg == "--recents" {
Location::Recents
if config.show_recents {
Location::Recents
} else {
log::warn!("recents feature is disabled in config");
continue;
}
} else if &arg == "--network" {
Location::Network("network:///".to_string(), fl!("networks"), None)
} else {