1
0
Fork 0
mirror of synced 2024-05-09 15:02:24 +12:00
czkawka/krokiet/src/set_initial_gui_info.rs
Rafał Mikrut 378fa1fd6e
Excluded extensions and krokiet new features (#1184)
* AVC

* Import split

* Default thread size

* Hen

* Allowed extensions

* Perf

* Connect

* Excluded

* Zmiany

* Optimization

* 4.10

* At once

* Included

* Chang

* VD

* VD

* Hashes

* Wersja

* SD

* Up

* Up

* 2024

* Dup

* Slint files

* Added  select

* Selections

* Fix

* LTO

* Actions

* Added popup delete

* AB

* V4

* Release

* LTO

* Basic moving

* Commonsy

* Moving probably works

* Popup move
2024-02-14 17:45:25 +01:00

32 lines
1.4 KiB
Rust

use slint::{ComponentHandle, SharedString, VecModel};
use czkawka_core::common::get_all_available_threads;
use crate::settings::{ALLOWED_HASH_SIZE_VALUES, ALLOWED_HASH_TYPE_VALUES, ALLOWED_RESIZE_ALGORITHM_VALUES};
use crate::{GuiState, MainWindow, Settings};
// Some info needs to be send to gui at the start like available thread number in OS.
//
pub fn set_initial_gui_infos(app: &MainWindow) {
let threads = get_all_available_threads();
let settings = app.global::<Settings>();
app.global::<GuiState>().set_maximum_threads(threads as f32);
let available_hash_size: Vec<SharedString> = ALLOWED_HASH_SIZE_VALUES
.iter()
.map(|(hash_size, _max_similarity)| hash_size.to_string().into())
.collect::<Vec<_>>();
let available_resize_algorithm: Vec<SharedString> = ALLOWED_RESIZE_ALGORITHM_VALUES
.iter()
.map(|(_settings_key, gui_name, _filter_type)| (*gui_name).into())
.collect::<Vec<_>>();
let available_hash_type: Vec<SharedString> = ALLOWED_HASH_TYPE_VALUES
.iter()
.map(|(_settings_key, gui_name, _hash_type)| (*gui_name).into())
.collect::<Vec<_>>();
settings.set_similar_images_sub_available_hash_size(VecModel::from_slice(&available_hash_size));
settings.set_similar_images_sub_available_resize_algorithm(VecModel::from_slice(&available_resize_algorithm));
settings.set_similar_images_sub_available_hash_type(VecModel::from_slice(&available_hash_type));
}