From 84a2d5197b2829b37087fd4c511607cf9ebcb68f Mon Sep 17 00:00:00 2001 From: Ricky Dane Perlick Date: Thu, 15 Aug 2024 22:42:55 +0200 Subject: [PATCH 1/2] drag files and folders onto path items --- ui/main_logic.js | 23 ++++++++++++++++------- ui/utils.js | 4 +++- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/ui/main_logic.js b/ui/main_logic.js index 890f7b5..b890327 100644 --- a/ui/main_logic.js +++ b/ui/main_logic.js @@ -221,6 +221,7 @@ function closeAllPopups() { if (ArrCopyItems.length == 0) { IsCopyToCut = false; } + $(".path-item")?.css("opacity", "1"); } // Close context menu or new folder input dialog when click elsewhere document.addEventListener("mousedown", (e) => { @@ -642,7 +643,7 @@ document.onkeydown = async (e) => { e.stopPropagation(); } // check if backspace is pressed - if (e.keyCode == 8 && IsPopUpOpen === false && IsInputFocused === false) { + if (e.keyCode == 8 && IsPopUpOpen === false && IsInputFocused === false && ArrSelectedItems.length == 0) { goBack(); e.preventDefault(); e.stopPropagation(); @@ -1050,17 +1051,14 @@ async function showItems(items, dualPaneSide = "", millerCol = 1) { Platform != "darwin" && (Platform.includes("win") || Platform.includes("linux")) ) { - IsFileOpIntern = true; await startDrag({ item: arr, icon: icon }); unSelectAllItems(); refreshView(); } else { - IsFileOpIntern = true; await startDrag({ item: arr, icon: icon }); unSelectAllItems(); refreshView(); } - IsFileOpIntern = false; }; // Accept file drop into folders item.addEventListener("dragover", (e) => { @@ -1621,11 +1619,9 @@ async function addSingleItem(item, dualPaneSide = "", millerCol = 1) { ) { await startDrag({ item: arr, icon: "" }); unSelectAllItems(); - IsFileOpIntern = true; } else { await startDrag({ item: arr, icon: icon }); unSelectAllItems(); - IsFileOpIntern = true; } }; // Accept file drop into folders @@ -1910,6 +1906,16 @@ async function setCurrentDir(currentDir = "", dualPaneSide = "") { "onClick", "openItem(this, '" + dualPaneSide + "', '')", ); + pathItem.ondragover = (e) => { + MousePos = [e.clientX, e.clientY-60]; + e.preventDefault(); + pathItem.style.opacity = 0.5; + DraggedOverElement = pathItem; + } + pathItem.ondragleave = (e) => { + e.preventDefault(); + pathItem.style.opacity = 1; + } let divider = document.createElement("i"); divider.className = "fa fa-chevron-right"; divider.style.color = "var(--textColor)"; @@ -2526,7 +2532,7 @@ async function checkAppConfig() { } checkColorMode(appConfig); }); - + await unSelectAllItems(); IsFirstRun = false; } @@ -2815,6 +2821,8 @@ async function openItem(element, dualPaneSide, shortcutDirPath = null) { SelectedItemPaneSide = dualPaneSide; await listDirectories(); } + await setCurrentDir(path); + await unSelectAllItems(); } else { alert("Could not open directory"); return; @@ -4521,6 +4529,7 @@ async function openDirAndSwitch(path) { await invoke("open_dir", { path }); await setCurrentDir(path); await listDirectories(); + await unSelectAllItems(); } async function openConfigLocation() { diff --git a/ui/utils.js b/ui/utils.js index 12b559c..ce7dc54 100644 --- a/ui/utils.js +++ b/ui/utils.js @@ -41,10 +41,12 @@ listen("tauri://file-drop", async (event) => { DraggedOverElement = null; } } catch (error) { - await invoke("log", { log: error }); + await invoke("log", { log: JSON.stringify(error) }); + IsFileOpIntern = false; alert(error); } resetProgressBar(); + IsFileOpIntern = false; document.querySelectorAll(".site-nav-bar-button").forEach((item) => { item.style.opacity = "1"; }); From 8a349736b10cc77e67631d20990776cbfaf69be8 Mon Sep 17 00:00:00 2001 From: Ricky Dane Perlick Date: Thu, 15 Aug 2024 22:43:24 +0200 Subject: [PATCH 2/2] changed version number --- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 59914a4..48ca980 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -4,7 +4,7 @@ version = 3 [[package]] name = "CoDriver" -version = "0.4.81" +version = "0.4.82" dependencies = [ "archiver-rs", "chrono", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index fe3f109..5d74221 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,7 +1,7 @@ # cargo-features = ["profile-rustflags"] [package] name = "CoDriver" -version = "0.4.81" +version = "0.4.82" description = "A simple file explorer" authors = ["Ricky Dane Perlick"] license = "none" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dd4e6fa..4e1ec63 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "CoDriver", - "version": "0.4.81" + "version": "0.4.82" }, "tauri": { "bundle": {