diff --git a/czkawka_core/src/similar_images.rs b/czkawka_core/src/similar_images.rs index c6fec94..0ba12ac 100644 --- a/czkawka_core/src/similar_images.rs +++ b/czkawka_core/src/similar_images.rs @@ -22,7 +22,8 @@ use serde::{Deserialize, Serialize}; #[cfg(feature = "heif")] use crate::common::get_dynamic_image_from_heic; use crate::common::{ - create_crash_message, get_dynamic_image_from_raw_image, open_cache_folder, Common, HEIC_EXTENSIONS, IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS, LOOP_DURATION, RAW_IMAGE_EXTENSIONS, + create_crash_message, get_dynamic_image_from_raw_image, get_number_of_threads, open_cache_folder, Common, HEIC_EXTENSIONS, IMAGE_RS_SIMILAR_IMAGES_EXTENSIONS, LOOP_DURATION, + RAW_IMAGE_EXTENSIONS, }; use crate::common_directory::Directories; use crate::common_extensions::Extensions; @@ -736,7 +737,7 @@ impl SimilarImages { let mut files_from_referenced_folders = HashMap::new(); let mut normal_files = HashMap::new(); - let number_of_processors = num_cpus::get(); + let number_of_processors = get_number_of_threads(); let chunk_size; let mut chunks: Vec<&[&Vec]>; diff --git a/czkawka_gui/i18n/en/czkawka_gui.ftl b/czkawka_gui/i18n/en/czkawka_gui.ftl index 8b99ba1..1c3da14 100644 --- a/czkawka_gui/i18n/en/czkawka_gui.ftl +++ b/czkawka_gui/i18n/en/czkawka_gui.ftl @@ -292,6 +292,11 @@ header_about_button_tooltip = Opens dialog with info about app. # Settings ## General +settings_number_of_threads = Number of used threads +settings_number_of_threads_tooltip = Number of used threads, 0 means that all available threads will be used. + +settings_label_restart = You need to restart app to apply settings! + settings_ignore_other_filesystems = Ignore other filesystems (only Linux) settings_ignore_other_filesystems_tooltip = ignores files that are not in the same file system as searched directories. diff --git a/czkawka_gui/src/connect_things/connect_settings.rs b/czkawka_gui/src/connect_things/connect_settings.rs index a9f4636..977a586 100644 --- a/czkawka_gui/src/connect_things/connect_settings.rs +++ b/czkawka_gui/src/connect_things/connect_settings.rs @@ -17,6 +17,16 @@ use crate::help_functions::get_dialog_box_child; use crate::saving_loading::{load_configuration, reset_configuration, save_configuration}; pub fn connect_settings(gui_data: &GuiData) { + // Connect scale + { + gui_data.settings.label_restart_needed.hide(); + let label_restart_needed = gui_data.settings.label_restart_needed.clone(); + gui_data.settings.scale_settings_number_of_threads.connect_value_changed(move |_| { + if !label_restart_needed.is_visible() { + label_restart_needed.show(); + } + }); + } // Connect button settings { let button_settings = gui_data.header.button_settings.clone(); diff --git a/czkawka_gui/src/gui_structs/gui_settings.rs b/czkawka_gui/src/gui_structs/gui_settings.rs index 0e79484..972f71b 100644 --- a/czkawka_gui/src/gui_structs/gui_settings.rs +++ b/czkawka_gui/src/gui_structs/gui_settings.rs @@ -1,9 +1,8 @@ -use glib::signal::Inhibit; use gtk4::prelude::*; use gtk4::{Builder, Window}; use crate::flg; -use crate::help_functions::{get_all_direct_children, scale_step_function}; +use crate::help_functions::get_all_direct_children; #[derive(Clone)] pub struct GuiSettings { @@ -26,6 +25,7 @@ pub struct GuiSettings { pub check_button_settings_one_filesystem: gtk4::CheckButton, pub label_settings_number_of_threads: gtk4::Label, pub scale_settings_number_of_threads: gtk4::Scale, + pub label_restart_needed: gtk4::Label, // Duplicates pub check_button_settings_hide_hard_links: gtk4::CheckButton, @@ -83,6 +83,7 @@ impl GuiSettings { let combo_box_settings_language: gtk4::ComboBoxText = builder.object("combo_box_settings_language").unwrap(); let label_settings_number_of_threads: gtk4::Label = builder.object("label_settings_number_of_threads").unwrap(); let scale_settings_number_of_threads: gtk4::Scale = builder.object("scale_settings_number_of_threads").unwrap(); + let label_restart_needed: gtk4::Label = builder.object("label_restart_needed").unwrap(); // Duplicates let check_button_settings_hide_hard_links: gtk4::CheckButton = builder.object("check_button_settings_hide_hard_links").unwrap(); @@ -129,6 +130,7 @@ impl GuiSettings { check_button_settings_one_filesystem, label_settings_number_of_threads, scale_settings_number_of_threads, + label_restart_needed, check_button_settings_hide_hard_links, entry_settings_cache_file_minimal_size, entry_settings_prehash_cache_file_minimal_size, @@ -154,6 +156,7 @@ impl GuiSettings { pub fn update_language(&self) { self.window_settings.set_title(Some(&flg!("window_settings_title"))); + self.label_restart_needed.set_label(&flg!("settings_label_restart")); self.check_button_settings_save_at_exit.set_label(Some(&flg!("settings_save_at_exit_button"))); self.check_button_settings_load_at_start.set_label(Some(&flg!("settings_load_at_start_button"))); self.check_button_settings_confirm_deletion.set_label(Some(&flg!("settings_confirm_deletion_button"))); @@ -166,6 +169,7 @@ impl GuiSettings { self.check_button_settings_use_trash.set_label(Some(&flg!("settings_use_trash_button"))); self.label_settings_general_language.set_label(&flg!("settings_language_label")); self.check_button_settings_one_filesystem.set_label(Some(&flg!("settings_ignore_other_filesystems"))); + self.label_settings_number_of_threads.set_label(&flg!("settings_number_of_threads")); self.check_button_settings_save_at_exit .set_tooltip_text(Some(&flg!("settings_save_at_exit_button_tooltip"))); @@ -186,6 +190,7 @@ impl GuiSettings { self.label_settings_general_language.set_tooltip_text(Some(&flg!("settings_language_label_tooltip"))); self.check_button_settings_one_filesystem .set_tooltip_text(Some(&flg!("settings_ignore_other_filesystems_tooltip"))); + self.scale_settings_number_of_threads.set_tooltip_text(Some(&flg!("settings_number_of_threads_tooltip"))); self.check_button_settings_hide_hard_links .set_label(Some(&flg!("settings_duplicates_hide_hard_link_button"))); diff --git a/czkawka_gui/src/main.rs b/czkawka_gui/src/main.rs index 5a7888a..5288b42 100644 --- a/czkawka_gui/src/main.rs +++ b/czkawka_gui/src/main.rs @@ -136,7 +136,7 @@ fn build_ui(application: &Application, arguments: Vec) { &gui_data.scrolled_window_errors, arguments.clone(), ); - // set_number_of_threads(gui_data.settings.sc); + set_number_of_threads(gui_data.settings.scale_settings_number_of_threads.value() as usize); // Needs to run when entire GUI is initialized connect_change_language(&gui_data); diff --git a/czkawka_gui/src/saving_loading.rs b/czkawka_gui/src/saving_loading.rs index 27ae433..0909bf2 100644 --- a/czkawka_gui/src/saving_loading.rs +++ b/czkawka_gui/src/saving_loading.rs @@ -5,7 +5,7 @@ use std::io::{Read, Write}; use std::path::{Path, PathBuf}; use std::{env, fs}; -use czkawka_core::common::{get_default_number_of_threads, get_number_of_threads}; +use czkawka_core::common::get_default_number_of_threads; use directories_next::ProjectDirs; use gtk4::prelude::*; use gtk4::{ComboBoxText, ScrolledWindow, TextView}; @@ -101,7 +101,6 @@ impl LoadSaveStruct { println!("Default value {} can't be convert to integer value", default_value); panic!(); } - assert!(default_value.parse::().is_ok()); let mut returned_value = self.get_string(key, default_value.clone()); if returned_value.parse::().is_err() { returned_value = default_value; diff --git a/czkawka_gui/ui/czkawka.cmb b/czkawka_gui/ui/czkawka.cmb index a14fa31..17e6d7a 100755 --- a/czkawka_gui/ui/czkawka.cmb +++ b/czkawka_gui/ui/czkawka.cmb @@ -281,7 +281,7 @@ (9,19,"GtkCheckButton","check_button_settings_use_cache",9,None,None,None,7), (9,20,"GtkCheckButton","check_button_settings_save_also_json",9,None,None,None,8), (9,21,"GtkCheckButton","check_button_settings_use_trash",9,None,None,None,9), - (9,22,"GtkBox",None,8,None,None,None,1), + (9,22,"GtkBox",None,8,None,None,None,2), (9,23,"GtkButton","button_settings_open_cache_folder",22,None,None,None,None), (9,24,"GtkButton","button_settings_open_settings_folder",22,None,None,None,1), (9,25,"GtkLabel",None,7,None,None,None,None), @@ -317,7 +317,8 @@ (9,55,"GtkCheckButton","check_button_settings_one_filesystem",9,None,None,None,10), (9,56,"GtkBox",None,9,None,None,None,11), (9,57,"GtkLabel","label_settings_number_of_threads",56,None,None,None,None), - (9,58,"GtkScale","scale_settings_number_of_threads",56,None,None,None,1) + (9,58,"GtkScale","scale_settings_number_of_threads",56,None,None,None,1), + (9,59,"GtkLabel","label_restart_needed",8,None,None,None,1) (3,1,"GtkAboutDialog","comments","2020 - 2022 RafaƂ Mikrut(qarmin)\n\nThis program is free to use and will always be.\n",1,None,None,None,None), @@ -955,14 +956,21 @@ (9,55,"GtkCheckButton","active","1",None,None,None,None,None), (9,55,"GtkCheckButton","label","Exclude other filesystems(Linux)",None,None,None,None,None), (9,55,"GtkWidget","focusable","1",None,None,None,None,None), + (9,57,"GtkAccessible","accessible-role","presentation",None,None,None,None,None), (9,57,"GtkLabel","label","Number of used threads",None,None,None,None,None), + (9,57,"GtkLabel","wrap-mode","word-char",None,None,None,None,None), + (9,57,"GtkWidget","margin-start","5",None,None,None,None,None), (9,58,"GtkRange","fill-level","100",None,None,None,None,None), (9,58,"GtkRange","round-digits","1",None,None,None,None,None), (9,58,"GtkScale","digits","0",None,None,None,None,None), (9,58,"GtkScale","draw-value","True",None,None,None,None,None), (9,58,"GtkScale","value-pos","right",None,None,None,None,None), (9,58,"GtkWidget","focusable","1",None,None,None,None,None), - (9,58,"GtkWidget","hexpand","1",None,None,None,None,None) + (9,58,"GtkWidget","hexpand","1",None,None,None,None,None), + (9,59,"GtkAccessible","accessible-role","menu-item-checkbox",None,None,None,None,None), + (9,59,"GtkLabel","label","You need to restart app to apply settings!",None,None,None,None,None), + (9,59,"GtkWidget","margin-bottom","4",None,None,None,None,None), + (9,59,"GtkWidget","margin-top","5",None,None,None,None,None) (8,17,18,"GtkGridLayoutChild","column","0",None,None,None,None), diff --git a/czkawka_gui/ui/settings.ui b/czkawka_gui/ui/settings.ui index 9c40cbd..0a54f45 100644 --- a/czkawka_gui/ui/settings.ui +++ b/czkawka_gui/ui/settings.ui @@ -118,7 +118,10 @@ + presentation Number of used threads + 5 + word-char @@ -136,6 +139,14 @@ + + + menu-item-checkbox + You need to restart app to apply settings! + 4 + 5 + + center