Skip to content

Commit

Permalink
Add config option to show additional context menu actions
Browse files Browse the repository at this point in the history
  • Loading branch information
dengelt committed Aug 12, 2024
1 parent e7862be commit 41247fb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
3 changes: 3 additions & 0 deletions i18n/de/cosmic_files.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ properties = Eigenschaften
## Settings
settings = Einstellungen
settings-tab = Tab
settings-optional-context-menu-actions = Optionale Aktionen im Kontextmenü
settings-optional-context-menu-actions-description = Weitere Aktionen im Menü anzeigen. Tastenkürzel können auch für ausgeblendete Aktionen verwendet werden.
settings-show-hidden = Versteckte Dateien anzeigen
settings-show-delete-permanently = Dauerhaft löschen
icon-size-list = Symbolgröße (Liste)
icon-size-grid = Symbolgröße (Raster)
sorting-name = Sortieren nach
Expand Down
3 changes: 3 additions & 0 deletions i18n/en/cosmic_files.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ show-details = Show details
## Settings
settings = Settings
settings-tab = Tab
settings-optional-context-menu-actions = Optional Context Menu Actions
settings-optional-context-menu-actions-description = Show more actions in the menus. Keyboard shortcuts can be used even if the actions are not shown.
settings-show-hidden = Show hidden files
settings-show-delete-permanently = Permanently delete
default-view = Default view
icon-size-list = Icon size (list)
icon-size-grid = Icon size (grid)
Expand Down
18 changes: 18 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,24 @@ impl App {
)
})
.into(),
widget::settings::view_section(fl!("settings-optional-context-menu-actions"))
.add(widget::text(fl!(
"settings-optional-context-menu-actions-description"
)))
.add({
let tab_config = self.config.tab.clone();
widget::settings::item::builder(fl!("settings-show-delete-permanently"))
.toggler(
tab_config.show_delete_permanently,
move |show_delete_permanently| {
Message::TabConfig(TabConfig {
show_delete_permanently,
..tab_config
})
},
)
})
.into(),
])
.into()
}
Expand Down
3 changes: 3 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ pub struct TabConfig {
pub sort_direction: bool,
/// Icon zoom
pub icon_sizes: IconSizes,
/// Show delete permanently context menu item
pub show_delete_permanently: bool,
}

impl Default for TabConfig {
Expand All @@ -142,6 +144,7 @@ impl Default for TabConfig {
sort_name: HeadingOptions::Name,
sort_direction: true,
icon_sizes: IconSizes::default(),
show_delete_permanently: false,
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn context_menu<'a>(
let TabConfig {
sort_name,
sort_direction,
show_delete_permanently,
..
} = tab.config;
let sort_item = |label, variant| {
Expand Down Expand Up @@ -121,8 +122,11 @@ pub fn context_menu<'a>(
children.push(menu_item(fl!("add-to-sidebar"), Action::AddToSidebar).into());
children.push(container(horizontal_rule(1)).padding([0, 8]).into());
children.push(menu_item(fl!("move-to-trash"), Action::MoveToTrash).into());
children
.push(menu_item(fl!("permanently-delete"), Action::PermanentlyDelete).into());
if show_delete_permanently {
children.push(
menu_item(fl!("permanently-delete"), Action::PermanentlyDelete).into(),
);
}
} else {
//TODO: need better designs for menu with no selection
//TODO: have things like properties but they apply to the folder?
Expand Down

0 comments on commit 41247fb

Please sign in to comment.