From 407b9543078ee8f1a99ca2761e8616f9a3bff069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Tue, 7 Jun 2022 07:44:19 +0200 Subject: [PATCH] Broken --- czkawka_core/src/broken_files.rs | 13 ++++++ czkawka_gui/i18n/en/czkawka_gui.ftl | 5 +++ .../src/gui_structs/gui_main_notebook.rs | 20 +++++++++ czkawka_gui/src/saving_loading.rs | 45 +++++++++++++++++++ czkawka_gui/ui/czkawka.cmb | 18 +++++++- czkawka_gui/ui/main_window.ui | 36 ++++++++++++++- 6 files changed, 135 insertions(+), 2 deletions(-) diff --git a/czkawka_core/src/broken_files.rs b/czkawka_core/src/broken_files.rs index 069300b68..87149d8f5 100644 --- a/czkawka_core/src/broken_files.rs +++ b/czkawka_core/src/broken_files.rs @@ -57,6 +57,19 @@ pub enum TypeOfFile { PDF, } +bitflags! { + pub struct CheckedFiles : u32 { + const NONE = 0; + + const TRACK_TITLE = 0b1; + const TRACK_ARTIST = 0b10; + const YEAR = 0b100; + const LENGTH = 0b1000; + const GENRE = 0b10000; + const BITRATE = 0b100000; + } +} + /// Info struck with helpful information's about results #[derive(Default)] pub struct Info { diff --git a/czkawka_gui/i18n/en/czkawka_gui.ftl b/czkawka_gui/i18n/en/czkawka_gui.ftl index e0450daee..2caeb317c 100644 --- a/czkawka_gui/i18n/en/czkawka_gui.ftl +++ b/czkawka_gui/i18n/en/czkawka_gui.ftl @@ -116,6 +116,11 @@ main_label_shown_files = Number of shown files main_label_resize_algorithm = Resize algorithm main_label_similarity = Similarity{" "} +main_check_box_broken_files_audio = Audio +main_check_box_broken_files_pdf = Pdf +main_check_box_broken_files_archive = Archive +main_check_box_broken_files_image = Image + check_button_general_same_size = Ignore same size check_button_general_same_size_tooltip = Ignore from results, files which have identical size - usually this are 1:1 duplicates diff --git a/czkawka_gui/src/gui_structs/gui_main_notebook.rs b/czkawka_gui/src/gui_structs/gui_main_notebook.rs index d01a5c4cf..301692bb1 100644 --- a/czkawka_gui/src/gui_structs/gui_main_notebook.rs +++ b/czkawka_gui/src/gui_structs/gui_main_notebook.rs @@ -109,6 +109,12 @@ pub struct GuiMainNotebook { pub scale_similarity_similar_videos: Scale, + // Broken Files + pub check_button_broken_files_audio: CheckButton, + pub check_button_broken_files_pdf: CheckButton, + pub check_button_broken_files_archive: CheckButton, + pub check_button_broken_files_image: CheckButton, + // Music pub check_button_music_title: CheckButton, pub check_button_music_artist: CheckButton, @@ -209,6 +215,11 @@ impl GuiMainNotebook { let check_button_music_length: CheckButton = builder.object("check_button_music_length").unwrap(); let check_button_music_approximate_comparison: CheckButton = builder.object("check_button_music_approximate_comparison").unwrap(); + let check_button_broken_files_audio: CheckButton = builder.object("check_button_broken_files_audio").unwrap(); + let check_button_broken_files_pdf: CheckButton = builder.object("check_button_broken_files_pdf").unwrap(); + let check_button_broken_files_archive: CheckButton = builder.object("check_button_broken_files_archive").unwrap(); + let check_button_broken_files_image: CheckButton = builder.object("check_button_broken_files_image").unwrap(); + let scale_similarity_similar_images: Scale = builder.object("scale_similarity_similar_images").unwrap(); let scale_similarity_similar_videos: Scale = builder.object("scale_similarity_similar_videos").unwrap(); @@ -284,6 +295,9 @@ impl GuiMainNotebook { check_button_music_approximate_comparison, scale_similarity_similar_images, scale_similarity_similar_videos, + check_button_broken_files_audio, + check_button_broken_files_pdf, + check_button_broken_files_archive, check_button_image_ignore_same_size, label_similar_images_minimal_similarity, label_duplicate_check_method, @@ -321,6 +335,7 @@ impl GuiMainNotebook { gc_tree_view_bad_extensions, combo_box_big_files_mode, label_big_files_mode, + check_button_broken_files_image, } } @@ -396,6 +411,11 @@ impl GuiMainNotebook { self.check_button_image_fast_compare .set_tooltip_text(Some(&flg!("main_notebook_image_fast_compare_tooltip"))); + self.check_button_broken_files_audio.set_label(Some(&flg!("main_check_box_broken_files_audio"))); + self.check_button_broken_files_archive.set_label(Some(&flg!("main_check_box_broken_files_archive"))); + self.check_button_broken_files_image.set_label(Some(&flg!("main_check_box_broken_files_image"))); + self.check_button_broken_files_pdf.set_label(Some(&flg!("main_check_box_broken_files_pdf"))); + { let hash_size_index = self.combo_box_image_hash_size.active().unwrap() as usize; let hash_size = IMAGES_HASH_SIZE_COMBO_BOX[hash_size_index]; diff --git a/czkawka_gui/src/saving_loading.rs b/czkawka_gui/src/saving_loading.rs index 8de7b4011..d47959aa5 100644 --- a/czkawka_gui/src/saving_loading.rs +++ b/czkawka_gui/src/saving_loading.rs @@ -42,6 +42,11 @@ const DEFAULT_IMAGE_REMOVE_AUTO_OUTDATED_CACHE: bool = true; const DEFAULT_DUPLICATE_REMOVE_AUTO_OUTDATED_CACHE: bool = true; const DEFAULT_DUPLICATE_CASE_SENSITIVE_NAME_CHECKING: bool = false; +const DEFAULT_BROKEN_FILES_PDF: bool = true; +const DEFAULT_BROKEN_FILES_AUDIO: bool = true; +const DEFAULT_BROKEN_FILES_ARCHIVE: bool = true; +const DEFAULT_BROKEN_FILES_IMAGE: bool = true; + const DEFAULT_NUMBER_OF_BIGGEST_FILES: &str = "50"; const DEFAULT_SIMILAR_IMAGES_SIMILARITY: i32 = 0; const DEFAULT_SIMILAR_IMAGES_IGNORE_SAME_SIZE: bool = false; @@ -427,6 +432,10 @@ enum LoadText { SimilarVideosIgnoreSameSize, MusicApproximateComparison, DuplicateNameCaseSensitive, + BrokenFilesPdf, + BrokenFilesAudio, + BrokenFilesImage, + BrokenFilesArchive, } fn create_hash_map() -> (HashMap, HashMap) { @@ -469,6 +478,10 @@ fn create_hash_map() -> (HashMap, HashMap) { (LoadText::MusicApproximateComparison, "music_approximate_comparison"), (LoadText::DuplicateNameCaseSensitive, "duplicate_name_case_sensitive"), (LoadText::ComboBoxBigFiles, "combo_box_big_files_mode"), + (LoadText::BrokenFilesPdf, "broken_files_pdf"), + (LoadText::BrokenFilesAudio, "broken_files_audio"), + (LoadText::BrokenFilesImage, "broken_files_image"), + (LoadText::BrokenFilesArchive, "broken_files_archive"), ]; let mut hashmap_ls: HashMap = Default::default(); let mut hashmap_sl: HashMap = Default::default(); @@ -583,6 +596,23 @@ pub fn save_configuration(manual_execution: bool, upper_notebook: &GuiUpperNoteb settings.check_button_settings_show_text_view.is_active(), ); + saving_struct.save_var( + hashmap_ls.get(&LoadText::BrokenFilesArchive).unwrap().to_string(), + main_notebook.check_button_broken_files_archive.is_active(), + ); + saving_struct.save_var( + hashmap_ls.get(&LoadText::BrokenFilesImage).unwrap().to_string(), + main_notebook.check_button_broken_files_image.is_active(), + ); + saving_struct.save_var( + hashmap_ls.get(&LoadText::BrokenFilesAudio).unwrap().to_string(), + main_notebook.check_button_broken_files_audio.is_active(), + ); + saving_struct.save_var( + hashmap_ls.get(&LoadText::BrokenFilesPdf).unwrap().to_string(), + main_notebook.check_button_broken_files_pdf.is_active(), + ); + // Others saving_struct.save_var( hashmap_ls.get(&LoadText::MinimalCacheSize).unwrap().to_string(), @@ -756,6 +786,11 @@ pub fn load_configuration( DEFAULT_DUPLICATE_CASE_SENSITIVE_NAME_CHECKING, ); + let check_button_broken_files_archive = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesArchive).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE); + let check_button_broken_files_pdf = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesPdf).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE); + let check_button_broken_files_image = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesImage).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE); + let check_button_broken_files_audio = loaded_entries.get_integer(hashmap_ls.get(&LoadText::BrokenFilesAudio).unwrap().clone(), DEFAULT_BROKEN_FILES_ARCHIVE); + // Setting data if manual_execution || loading_at_start { { @@ -880,6 +915,11 @@ pub fn load_configuration( main_notebook.check_button_video_ignore_same_size.set_active(similar_videos_ignore_same_size); main_notebook.scale_similarity_similar_videos.set_value(similar_videos_similarity as f64); + main_notebook.check_button_broken_files_audio.set_active(check_button_broken_files_audio); + main_notebook.check_button_broken_files_pdf.set_active(check_button_broken_files_pdf); + main_notebook.check_button_broken_files_image.set_active(check_button_broken_files_image); + main_notebook.check_button_broken_files_archive.set_active(check_button_broken_files_archive); + { let combo_chosen_index = main_notebook.combo_box_duplicate_check_method.active().unwrap(); @@ -1004,6 +1044,11 @@ pub fn reset_configuration(manual_clearing: bool, upper_notebook: &GuiUpperNoteb main_notebook.combo_box_image_hash_size.set_active(Some(0)); main_notebook.combo_box_big_files_mode.set_active(Some(0)); + main_notebook.check_button_broken_files_audio.set_active(DEFAULT_BROKEN_FILES_AUDIO); + main_notebook.check_button_broken_files_pdf.set_active(DEFAULT_BROKEN_FILES_PDF); + main_notebook.check_button_broken_files_archive.set_active(DEFAULT_BROKEN_FILES_ARCHIVE); + main_notebook.check_button_broken_files_image.set_active(DEFAULT_BROKEN_FILES_IMAGE); + main_notebook.scale_similarity_similar_images.set_range(0_f64, SIMILAR_VALUES[0][5] as f64); // DEFAULT FOR MAX of 8 main_notebook.scale_similarity_similar_images.set_fill_level(SIMILAR_VALUES[0][5] as f64); diff --git a/czkawka_gui/ui/czkawka.cmb b/czkawka_gui/ui/czkawka.cmb index 8e1547f41..5ce98c308 100755 --- a/czkawka_gui/ui/czkawka.cmb +++ b/czkawka_gui/ui/czkawka.cmb @@ -167,7 +167,7 @@ (5,129,"GtkScrolledWindow","scrolled_window_invalid_symlinks",128,None,None,None,None), (5,130,"GtkLabel",None,128,None,None,None,None), (5,131,"GtkNotebookPage",None,56,None,None,None,9), - (5,132,"GtkScrolledWindow","scrolled_window_broken_files",131,None,None,None,None), + (5,132,"GtkBox",None,131,None,None,None,None), (5,133,"GtkLabel",None,131,None,None,None,None), (5,134,"GtkNotebookPage",None,56,None,None,None,10), (5,135,"GtkScrolledWindow","scrolled_window_bad_extensions",134,None,None,None,None), @@ -225,6 +225,12 @@ (5,220,"GtkImage",None,219,None,None,None,None), (5,221,"GtkComboBoxText","combo_box_big_files_mode",74,None,None,None,1), (5,222,"GtkLabel","label_big_files_mode",74,None,None,None,None), + (5,223,"GtkScrolledWindow","scrolled_window_broken_files",132,None,None,None,1), + (5,224,"GtkBox",None,132,None,None,None,None), + (5,225,"GtkCheckButton","check_button_broken_files_audio",224,None,None,None,None), + (5,226,"GtkCheckButton","check_button_broken_files_pdf",224,None,None,None,1), + (5,227,"GtkCheckButton","check_button_broken_files_archive",224,None,None,None,2), + (5,228,"GtkCheckButton","check_button_broken_files_image",224,None,None,None,3), (6,1,"GtkPopover","popover_right_click",None,None,None,None,None), (6,2,"GtkBox",None,1,None,None,None,None), (6,3,"GtkButton","buttons_popover_right_click_open_file",2,None,None,None,None), @@ -627,6 +633,7 @@ (5,131,"GtkNotebookPage","child",None,None,None,None,None,132), (5,131,"GtkNotebookPage","position","9",None,None,None,None,None), (5,131,"GtkNotebookPage","tab",None,None,None,None,None,133), + (5,132,"GtkOrientable","orientation","vertical",None,None,None,None,None), (5,132,"GtkWidget","focusable","1",None,None,None,None,None), (5,133,"GtkLabel","label","Broken Files",1,None,None,None,None), (5,134,"GtkNotebookPage","child",None,None,None,None,None,135), @@ -727,6 +734,15 @@ (5,220,"GtkImage","icon-name","image-missing",None,None,None,None,None), (5,220,"GtkWidget","halign","center",None,None,None,None,None), (5,222,"GtkLabel","label","VVV",None,None,None,None,None), + (5,223,"GtkWidget","vexpand","True",None,None,None,None,None), + (5,225,"GtkCheckButton","active","True",None,None,None,None,None), + (5,225,"GtkCheckButton","label","Audio",None,None,None,None,None), + (5,226,"GtkCheckButton","active","True",None,None,None,None,None), + (5,226,"GtkCheckButton","label","PDF",None,None,None,None,None), + (5,227,"GtkCheckButton","active","True",None,None,None,None,None), + (5,227,"GtkCheckButton","label","Archive",None,None,None,None,None), + (5,228,"GtkCheckButton","active","True",None,None,None,None,None), + (5,228,"GtkCheckButton","label","Image",None,None,None,None,None), (6,1,"GtkPopover","child",None,None,None,None,None,2), (6,1,"GtkPopover","position","left",None,None,None,None,None), (6,2,"GtkOrientable","orientation","vertical",None,None,None,None,None), diff --git a/czkawka_gui/ui/main_window.ui b/czkawka_gui/ui/main_window.ui index 17fed1fc1..9097abcc1 100644 --- a/czkawka_gui/ui/main_window.ui +++ b/czkawka_gui/ui/main_window.ui @@ -778,8 +778,42 @@ - + 1 + vertical + + + + + True + Audio + + + + + True + PDF + + + + + True + Archive + + + + + True + Image + + + + + + + True + + 9