1
0
Fork 0
mirror of synced 2024-06-20 19:30:47 +12:00
This commit is contained in:
Rafał Mikrut 2023-11-24 22:08:26 +01:00
parent 85da7f3feb
commit cc8bb6ef46
5 changed files with 46 additions and 18 deletions

View file

@ -2,6 +2,11 @@ use std::path::Path;
use crate::common::Common;
#[cfg(target_family = "unix")]
pub const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["/proc", "/dev", "/sys", "/run", "/snap"];
#[cfg(not(target_family = "unix"))]
pub const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["C:\\Windows"];
#[cfg(target_family = "unix")]
pub const DEFAULT_EXCLUDED_ITEMS: &str = "*/.git/*,*/node_modules/*,*/lost+found/*,*/Trash/*,*/.Trash-*/*,*/snap/*,/home/*/.cache/*";
#[cfg(not(target_family = "unix"))]

View file

@ -4,22 +4,13 @@ use std::path::PathBuf;
use crate::common::create_string_standard_list_view_from_pathbuf;
use crate::{GuiState, Settings};
use czkawka_core::common_items::{DEFAULT_EXCLUDED_DIRECTORIES, DEFAULT_EXCLUDED_ITEMS};
use directories_next::ProjectDirs;
use home::home_dir;
use log::error;
use serde::{Deserialize, Serialize};
use slint::{ComponentHandle, Model};
#[cfg(target_family = "unix")]
const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["/proc", "/dev", "/sys", "/run", "/snap"];
#[cfg(not(target_family = "unix"))]
const DEFAULT_EXCLUDED_DIRECTORIES: &[&str] = &["C:\\Windows"];
#[cfg(target_family = "unix")]
pub const DEFAULT_EXCLUDED_ITEMS: &str = "*/.git/*,*/node_modules/*,*/lost+found/*,*/Trash/*,*/.Trash-*/*,*/snap/*,/home/*/.cache/*";
#[cfg(not(target_family = "unix"))]
pub const DEFAULT_EXCLUDED_ITEMS: &str = "*\\.git\\*,*\\node_modules\\*,*\\lost+found\\*,*:\\windows\\*,*:\\$RECYCLE.BIN\\*,*:\\$SysReset\\*,*:\\System Volume Information\\*,*:\\OneDriveTemp\\*,*:\\hiberfil.sys,*:\\pagefile.sys,*:\\swapfile.sys";
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SettingsCustom {
#[serde(default = "default_included_directories")]
@ -34,12 +25,7 @@ pub struct SettingsCustom {
impl Default for SettingsCustom {
fn default() -> Self {
Self {
included_directories: default_included_directories(),
excluded_directories: default_excluded_directories(),
excluded_items: default_excluded_items(),
allowed_extensions: String::new(),
}
serde_json::from_str("{}").unwrap()
}
}

View file

@ -10,4 +10,7 @@ export global Callabler {
// Preview
callback load_image_preview(string);
// Settings
callback changed_settings_preset(string, int);
}

View file

@ -1,4 +1,7 @@
export global Settings {
in-out property <int> settings_preset_idx: 0;
in-out property <[string]> settings_presets: ["Preset 1", "Preset 2"];
in-out property <[StandardListViewItem]> included_directories: [{text: "ABCD"}, {text: "BCDA"}];
in-out property <[StandardListViewItem]> excluded_directories: [{text: "ABCD"}, {text: "BCDA"}, {text: "CDFFF"}];

View file

@ -1,5 +1,6 @@
import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox, ScrollView, LineEdit, SpinBox} from "std-widgets.slint";
import { Button, VerticalBox , HorizontalBox, TabWidget, ListView, StandardListView, StandardTableView, CheckBox, ScrollView, LineEdit, SpinBox, ComboBox, TextEdit} from "std-widgets.slint";
import { Settings } from "settings.slint";
import { Callabler } from "callabler.slint";
global SettingsSize {
out property <length> item_height: 30px;
@ -25,7 +26,7 @@ component MinMaxSizeComponent inherits HorizontalLayout {
spacing: 20px;
Text {
horizontal-stretch: 0.0;
text:"Size";
text:"Items Size";
vertical-alignment: TextVerticalAlignment.center;
}
HorizontalLayout {
@ -50,6 +51,32 @@ component MinMaxSizeComponent inherits HorizontalLayout {
}
}
component Presets inherits HorizontalLayout {
spacing: 5px;
Text {
text : "Current:";
vertical-alignment: TextVerticalAlignment.center;
}
combo_box := ComboBox {
current-index <=> Settings.settings_preset_idx;
model: Settings.settings_presets;
selected(item) => {
Callabler.changed_settings_preset(item, self.current_index);
current_name.text = item;
}
}
current_name := LineEdit {
text: Settings.settings_presets[0];
}
Button {
text: "Save";
clicked => {
Settings.settings_presets[combo_box.current_index] = current_name.text;
combo_box.current_value = current_name.text;
}
}
}
export component SettingsList inherits VerticalLayout {
preferred-height: 300px;
preferred-width: 400px;
@ -63,10 +90,14 @@ export component SettingsList inherits VerticalLayout {
ScrollView {
VerticalLayout {
spacing: 5px;
Presets{
height: SettingsSize.item_height;
}
Text {
text: "General settings";
height: SettingsSize.item_height;
horizontal-alignment: TextHorizontalAlignment.center;
vertical-alignment: TextVerticalAlignment.center;
}
TextComponent {
name: "Excluded item:";