Moving probably works
This commit is contained in:
parent
69dea58516
commit
e89f6e10b4
|
@ -1,7 +1,7 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
use crate::{CurrentTab, ExcludedDirectoriesModel, GuiState, IncludedDirectoriesModel, MainListModel, MainWindow};
|
||||
use slint::{ComponentHandle, ModelRc, SharedString, VecModel};
|
||||
use crate::{CurrentTab, ExcludedDirectoriesModel, IncludedDirectoriesModel, MainListModel, MainWindow};
|
||||
use slint::{ModelRc, SharedString, VecModel};
|
||||
|
||||
// Remember to match updated this according to ui/main_lists.slint and connect_scan.rs files
|
||||
pub fn get_str_path_idx(active_tab: CurrentTab) -> usize {
|
||||
|
|
|
@ -4,23 +4,32 @@ use crate::{Callabler, CurrentTab, GuiState, MainListModel, MainWindow};
|
|||
|
||||
use czkawka_core::common_messages::Messages;
|
||||
use rayon::prelude::*;
|
||||
use rfd::FileDialog;
|
||||
use slint::{ComponentHandle, ModelRc, VecModel};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{fs, path};
|
||||
|
||||
pub fn connect_move(app: &MainWindow) {
|
||||
let a = app.as_weak();
|
||||
app.global::<Callabler>().on_move_items(move |select_mode, preserve_structure, copy_mode| {
|
||||
app.on_folders_move_choose_requested(move || {
|
||||
let app = a.upgrade().unwrap();
|
||||
|
||||
let file_dialog = FileDialog::new();
|
||||
let Some(folder) = file_dialog.pick_folder() else {
|
||||
return;
|
||||
};
|
||||
let folder_str = folder.to_string_lossy().to_string();
|
||||
|
||||
app.invoke_show_move_folders_dialog(folder_str.into());
|
||||
});
|
||||
|
||||
let a = app.as_weak();
|
||||
app.global::<Callabler>().on_move_items(move |preserve_structure, copy_mode, output_folder| {
|
||||
let app = a.upgrade().unwrap();
|
||||
let active_tab = app.global::<GuiState>().get_active_tab();
|
||||
let current_model = get_tool_model(&app, active_tab);
|
||||
|
||||
// If tree structure will be
|
||||
let preserve_structure = false;
|
||||
let copy_mode = true;
|
||||
let output_folder = "/home/rafal/Downloads/AAAAAAAA";
|
||||
|
||||
let (errors, new_model) = move_operation(¤t_model, preserve_structure, copy_mode, output_folder, active_tab);
|
||||
let (errors, new_model) = move_operation(¤t_model, preserve_structure, copy_mode, &output_folder, active_tab);
|
||||
if let Some(new_model) = new_model {
|
||||
set_tool_model(&app, active_tab, new_model);
|
||||
}
|
||||
|
@ -104,10 +113,7 @@ fn collect_path_and_create_folders(input_path: &str, input_file: &str, output_pa
|
|||
|
||||
let mut output_full_path = PathBuf::from(output_path);
|
||||
if preserve_structure {
|
||||
output_full_path.extend(Path::new(input_path).components().filter(|c| match c {
|
||||
path::Component::Normal(_) => true,
|
||||
_ => false,
|
||||
}));
|
||||
output_full_path.extend(Path::new(input_path).components().filter(|c| matches!(c, path::Component::Normal(_))));
|
||||
};
|
||||
let _ = fs::create_dir_all(&output_full_path);
|
||||
output_full_path.push(input_file);
|
||||
|
|
|
@ -8,6 +8,8 @@ pub fn deselect_all_items(items: &mut [MainListModel]) {
|
|||
item.selected_row = false;
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn select_all_items(items: &mut [MainListModel]) {
|
||||
for item in items {
|
||||
item.selected_row = true;
|
||||
|
|
|
@ -22,6 +22,7 @@ export component ActionButtons inherits HorizontalLayout {
|
|||
callback scan_starting(CurrentTab);
|
||||
callback show_select_popup(length, length);
|
||||
callback show_remove_popup();
|
||||
callback request_folder_to_move();
|
||||
in-out property <BottomPanelVisibility> bottom_panel_visibility: BottomPanelVisibility.Directories;
|
||||
in-out property <bool> stop_requested: false;
|
||||
in-out property <bool> scanning;
|
||||
|
@ -63,7 +64,7 @@ export component ActionButtons inherits HorizontalLayout {
|
|||
enabled: !scanning && lists_enabled;
|
||||
text: "Move";
|
||||
clicked => {
|
||||
// show_move_popup(self.x + self.width / 2, self.y + parent.y);
|
||||
request_folder_to_move();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ export global Callabler {
|
|||
|
||||
callback tab_changed();
|
||||
|
||||
callback move_items(bool, bool, string);
|
||||
|
||||
// Translations
|
||||
pure callback translate(string, [{key: string, value: string}]) -> string;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import {GuiState} from "gui_state.slint";
|
|||
import { Preview } from "preview.slint";
|
||||
import {PopupNewDirectories} from "popup_new_directories.slint";
|
||||
import {PopupDelete} from "popup_delete.slint";
|
||||
import {PopupMoveFolders} from "popup_move_folders.slint";
|
||||
import { PopupSelectResults } from "popup_select_results.slint";
|
||||
import { ToolSettings } from "tool_settings.slint";
|
||||
|
||||
|
@ -24,6 +25,8 @@ export component MainWindow inherits Window {
|
|||
callback scan_starting(CurrentTab);
|
||||
callback folder_choose_requested(bool);
|
||||
callback scan_ended(string);
|
||||
callback show_move_folders_dialog(string);
|
||||
callback folders_move_choose_requested();
|
||||
|
||||
min-width: 300px;
|
||||
preferred-width: 800px;
|
||||
|
@ -51,7 +54,7 @@ export component MainWindow inherits Window {
|
|||
{checked: true, selected_row: false, header_row: false, val_str: ["lokkaler", "/Xd1/Vide2", "01.23.1911"], val_int: []}
|
||||
];
|
||||
in-out property <[MainListModel]> similar_images_model: [];
|
||||
|
||||
|
||||
VerticalBox {
|
||||
HorizontalBox {
|
||||
vertical-stretch: 1.0;
|
||||
|
@ -123,6 +126,9 @@ export component MainWindow inherits Window {
|
|||
select_popup_window.y_offset = y_offset;
|
||||
select_popup_window.show_popup();
|
||||
}
|
||||
request_folder_to_move => {
|
||||
folders_move_choose_requested();
|
||||
}
|
||||
show_remove_popup => {
|
||||
delete_popup_window.show_popup();
|
||||
}
|
||||
|
@ -170,6 +176,19 @@ export component MainWindow inherits Window {
|
|||
y: parent.y + (parent.height - self.popup_height) / 2.0;
|
||||
}
|
||||
|
||||
move_popup_window := PopupMoveFolders {
|
||||
height: root.height;
|
||||
width: root.width;
|
||||
|
||||
x: parent.x + (root.width - self.popup_width) / 2.0;
|
||||
y: parent.y + (parent.height - self.popup_height) / 2.0;
|
||||
}
|
||||
|
||||
show_move_folders_dialog(folder_name) => {
|
||||
move_popup_window.folder_name = folder_name;
|
||||
move_popup_window.show_popup();
|
||||
}
|
||||
|
||||
scan_ended(scan_text) => {
|
||||
text_summary_text = scan_text;
|
||||
root.scanning = false;
|
||||
|
|
Loading…
Reference in a new issue