From c13f9255e20f7ab7e3d42fe70b9ba4add70edde9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= <41945903+qarmin@users.noreply.github.com> Date: Sun, 3 Apr 2022 12:57:47 +0200 Subject: [PATCH] Add button to disable by default size of letters when selecting things (#657) * Add button to disable by default size of letters when selecting things * Change wording --- czkawka_gui/i18n/en/czkawka_gui.ftl | 8 ++++- .../src/connect_things/connect_popovers.rs | 33 ++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/czkawka_gui/i18n/en/czkawka_gui.ftl b/czkawka_gui/i18n/en/czkawka_gui.ftl index 5942841..a259f08 100644 --- a/czkawka_gui/i18n/en/czkawka_gui.ftl +++ b/czkawka_gui/i18n/en/czkawka_gui.ftl @@ -182,6 +182,11 @@ popover_custom_regex_check_button_entry_tooltip = This uses the default Rust regex implementation. You can read more about it here: https://docs.rs/regex. +popover_custom_case_sensitive_check_button_tooltip = + Enables case-sensitive detection. + + When disabled /home/* finds both /HoMe/roman and /home/roman. + popover_custom_not_all_check_button_tooltip = Prevents selecting all records in group. @@ -192,6 +197,7 @@ popover_custom_not_all_check_button_tooltip = popover_custom_regex_path_label = Path popover_custom_regex_name_label = Name popover_custom_regex_regex_label = Regex Path + Name +popover_custom_case_sensitive_check_button = Case sensitive popover_custom_all_in_group_label = Don't select all records in group popover_custom_mode_unselect = Unselect Custom @@ -237,7 +243,7 @@ progress_stop_button = Stop about_repository_button_tooltip = Link to repository page with source code. about_donation_button_tooltip = Link to donation page. about_instruction_button_tooltip = Link to instruction page. -about_translation_button_tooltip = Link to Crowdin page with app translations. Officially Polish and English are supported, but any help with other language will be appreciated. +about_translation_button_tooltip = Link to Crowdin page with app translations. Officially Polish and English are supported. about_repository_button = Repository about_donation_button = Donation diff --git a/czkawka_gui/src/connect_things/connect_popovers.rs b/czkawka_gui/src/connect_things/connect_popovers.rs index 3cfc728..7053919 100644 --- a/czkawka_gui/src/connect_things/connect_popovers.rs +++ b/czkawka_gui/src/connect_things/connect_popovers.rs @@ -258,6 +258,9 @@ fn popover_custom_select_unselect( let check_button_name = gtk::CheckButton::builder().label(&flg!("popover_custom_regex_name_label")).build(); let check_button_rust_regex = gtk::CheckButton::builder().label(&flg!("popover_custom_regex_regex_label")).build(); + let check_button_case_sensitive = gtk::CheckButton::builder().label(&flg!("popover_custom_case_sensitive_check_button")).build(); + check_button_case_sensitive.set_active(false); + let check_button_select_not_all_results = gtk::CheckButton::builder().label(&flg!("popover_custom_all_in_group_label")).build(); check_button_select_not_all_results.set_active(true); @@ -279,6 +282,7 @@ fn popover_custom_select_unselect( check_button_rust_regex.set_tooltip_text(Some(&flg!("popover_custom_regex_check_button_entry_tooltip"))); entry_rust_regex.set_tooltip_text(Some(&flg!("popover_custom_regex_check_button_entry_tooltip"))); + check_button_case_sensitive.set_tooltip_text(Some(&flg!("popover_custom_case_sensitive_check_button_tooltip"))); check_button_select_not_all_results.set_tooltip_text(Some(&flg!("popover_custom_not_all_check_button_tooltip"))); } { @@ -347,8 +351,10 @@ fn popover_custom_select_unselect( grid.attach(&label_regex_valid, 0, 4, 2, 1); + grid.attach(&check_button_case_sensitive, 0, 5, 2, 1); + if select_things { - grid.attach(&check_button_select_not_all_results, 0, 5, 2, 1); + grid.attach(&check_button_select_not_all_results, 0, 6, 2, 1); } let box_widget = get_dialog_box_child(&dialog); @@ -372,6 +378,7 @@ fn popover_custom_select_unselect( let check_path = check_button_path.is_active(); let check_name = check_button_name.is_active(); let check_regex = check_button_rust_regex.is_active(); + let case_sensitive = check_button_case_sensitive.is_active(); let check_all_selected = check_button_select_not_all_results.is_active(); @@ -441,11 +448,27 @@ fn popover_custom_select_unselect( if check_regex && compiled_regex.find(&path_and_name).is_some() { need_to_change_thing = true; } else { - if check_name && Common::regex_check(&name_wildcard, &name) { - need_to_change_thing = true; + if check_name { + if case_sensitive { + if Common::regex_check(&name_wildcard, &name) { + need_to_change_thing = true; + } + } else { + if Common::regex_check(&name_wildcard.to_lowercase(), &name.to_lowercase()) { + need_to_change_thing = true; + } + } } - if check_path && Common::regex_check(&path_wildcard, &path) { - need_to_change_thing = true; + if check_path { + if case_sensitive { + if Common::regex_check(&path_wildcard, &path) { + need_to_change_thing = true; + } + } else { + if Common::regex_check(&path_wildcard.to_lowercase(), &path.to_lowercase()) { + need_to_change_thing = true; + } + } } }