Skip to content

A fast file manager for Windows and macOS that never freezes: tabs, dual panes, archives as folders, Quick Look-style previews. A File Explorer and Finder alternative written in Rust.

Toolbar: no More button while all it holds is unavailable (406)

gelenmedya30d1044c959a
diff --git a/crates/rf-app/src/ctx_menu.rs b/crates/rf-app/src/ctx_menu.rs
index 59b8d9dd..e7e41908 100644
--- a/crates/rf-app/src/ctx_menu.rs
+++ b/crates/rf-app/src/ctx_menu.rs
@@ -2099,10 +2099,36 @@ pub fn more_is_empty(st: &crate::settings::Settings) -> bool {
MORE_KEYS.iter().all(|k| more_left_out(st, k))
}
+/// Whether nothing the More menu holds right now can be used: then the toolbar leaves its button out as well (issue 406: with Select
+/// all and Invert selection on the bar, the menu held only a greyed "Select none"). Only Undo, Redo and Select none are ever unavailable.
+pub fn more_all_disabled(st: &crate::settings::Settings, can_undo: bool, can_redo: bool, any_selected: bool) -> bool {
+ MORE_KEYS.iter().filter(|k| !more_left_out(st, k)).all(|&k| match k {
+ "undo" => !can_undo,
+ "redo" => !can_redo,
+ "selectnone" => !any_selected,
+ _ => false,
+ })
+}
+
#[cfg(test)]
mod more_tests {
use super::{MORE_EXIT, more_is_empty, more_left_out};
+ #[test]
+ fn the_more_button_goes_when_all_it_holds_is_unavailable() {
+ let mut s = crate::settings::Settings::default();
+ assert!(!super::more_all_disabled(&s, false, false, false), "Settings and the rest are always there");
+ // everything but Undo, Redo and Select none elsewhere
+ // (Properties stands on the bar by default; Exit is turned off; the others are put on the bar)
+ for k in ["selectall", "invertsel", "settings"] {
+ s.toolbar_extra.push(k.into());
+ }
+ s.toolbar_hidden.push(MORE_EXIT.into());
+ assert!(super::more_all_disabled(&s, false, false, false), "nothing to undo or redo, nothing selected");
+ assert!(!super::more_all_disabled(&s, true, false, false), "something to undo");
+ assert!(!super::more_all_disabled(&s, false, false, true), "something to deselect");
+ }
+
#[test]
fn the_more_menu_is_empty_only_when_everything_is_elsewhere() {
let mut s = crate::settings::Settings::default();
diff --git a/crates/rf-app/src/workspace.rs b/crates/rf-app/src/workspace.rs
index b715669e..94f9e8e8 100644
--- a/crates/rf-app/src/workspace.rs
+++ b/crates/rf-app/src/workspace.rs
@@ -4212,7 +4212,11 @@ impl Workspace {
// (off unless asked for: discussion 677) the archive submenus of the right-click menu, for the selection
"compress" => extra("compress").then(|| drop("cb-compress", L::Archive, None, "Sıkıştır", has_sel && in_folder, look("compress"), cx, |_, _| crate::ctx_menu::BarMenu::Compress).into_any_element()),
"extract" => extra("extract").then(|| drop("cb-extract", L::FolderOutput, None, "Çıkar", archives_sel, look("extract"), cx, |_, _| crate::ctx_menu::BarMenu::Extract).into_any_element()),
- "more" => (on("more") && !crate::ctx_menu::more_is_empty(cx.global::<crate::settings::Settings>())).then(|| drop("cb-more", L::Ellipsis, None, "Diğer", in_folder, look("more"), cx, |_, _| crate::ctx_menu::BarMenu::More).into_any_element()),
+ "more" => (on("more") && {
+ let (undo, redo) = crate::undo::next_labels();
+ !crate::ctx_menu::more_all_disabled(cx.global::<crate::settings::Settings>(), undo.is_some(), redo.is_some(), has_sel)
+ })
+ .then(|| drop("cb-more", L::Ellipsis, None, "Diğer", in_folder, look("more"), cx, |_, _| crate::ctx_menu::BarMenu::More).into_any_element()),
// (in the Explorer look only: in the other one they stand in the right group)
"sort" => on("sort").then(|| drop("cb-sort", L::ArrowUpDown, sort_label, "Sırala ve gruplandır", in_folder, look("sort"), cx, |_, _| crate::ctx_menu::BarMenu::Sort).into_any_element()),
"view" => on("view").then(|| {