2
0
Эх сурвалжийг харах

[filebrowser] Added button to seach in file paths in the gallery view

Clément Espeute 2 сар өмнө
parent
commit
de6916870c

+ 10 - 0
bin/res/icons/svg/search_folder.svg

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg width="100%" height="100%" viewBox="0 0 256 256" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
+    <g transform="matrix(0.225265,0,0,0.225265,8.2088,242.222)">
+        <path d="M880,-446.103L880,-240C880,-218 872.167,-199.167 856.5,-183.5C840.833,-167.833 822,-160 800,-160L160,-160C138,-160 119.167,-167.833 103.5,-183.5C87.833,-199.167 80,-218 80,-240L80,-720C80,-742 87.833,-760.833 103.5,-776.5C119.167,-792.167 138,-800 160,-800L400,-800L480,-720L604.912,-720C599.872,-701.08 597.349,-681.08 597.349,-660C597.349,-653.222 597.61,-646.555 598.132,-640L447,-640L367,-720L160,-720L160,-240L800,-240L800,-438.132C806.555,-437.61 813.222,-437.349 820,-437.349C841.089,-437.349 861.083,-440.305 880,-446.103Z" style="fill:white;"/>
+    </g>
+    <g transform="matrix(0.225265,0,0,0.225265,53.2617,251.233)">
+        <path d="M772,-604L900,-476L844,-420L716,-548C702,-540 687,-533.333 671,-528C655,-522.667 638,-520 620,-520C570,-520 527.5,-537.5 492.5,-572.5C457.5,-607.5 440,-650 440,-700C440,-750 457.5,-792.5 492.5,-827.5C527.5,-862.5 570,-880 620,-880C670,-880 712.5,-862.5 747.5,-827.5C782.5,-792.5 800,-750 800,-700C800,-682 797.333,-665 792,-649C786.667,-633 780,-618 772,-604ZM620,-600C648,-600 671.667,-609.667 691,-629C710.333,-648.333 720,-672 720,-700C720,-728 710.333,-751.667 691,-771C671.667,-790.333 648,-800 620,-800C592,-800 568.333,-790.333 549,-771C529.667,-751.667 520,-728 520,-700C520,-672 529.667,-648.333 549,-629C568.333,-609.667 592,-600 620,-600Z" style="fill:white;fill-rule:nonzero;"/>
+    </g>
+</svg>

+ 3 - 0
bin/style.css

@@ -4979,6 +4979,9 @@ fancy-icon {
 fancy-icon.small {
   height: 12px;
 }
+fancy-icon.med {
+  height: 18px;
+}
 fancy-icon.big {
   height: 22px;
 }

+ 3 - 0
bin/style.less

@@ -5954,6 +5954,9 @@ fancy-icon {
 		height: 12px;
 	}
 
+	&.med {
+		height: 18px;
+	}
 
 	&.big {
 		height: 22px;

+ 31 - 2
hide/view/FileBrowser.hx

@@ -124,6 +124,10 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 	var fancyTree: hide.comp.FancyTree<FileEntry>;
 	var collapseSubfolders : Bool;
 	var collapseSubfoldersButton : js.html.Element;
+
+	var gallerySearchFullPath : Bool = false;
+	var gallerySearchFullPathButton : js.html.Element;
+
 	var filterButton : js.html.Element;
 	var filterEnabled(default, set) : Bool;
 	var filters : Map<String, {exts: Array<String>, icon: String}> = [];
@@ -160,6 +164,12 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 		queueGalleryRefresh();
 	}
 
+	function syncGallerySearchFullPath() {
+		gallerySearchFullPathButton.classList.toggle("selected", gallerySearchFullPath);
+		saveDisplayState("gallerySearchFullPath", gallerySearchFullPath);
+		queueGalleryRefresh();
+	}
+
 	var galleryRefreshQueued = false;
 	function queueGalleryRefresh() {
 		if (!galleryRefreshQueued) {
@@ -201,6 +211,8 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 				}
 			}
 
+			var base = currentFolder.getRelPath();
+
 			function rec(files: Array<FileEntry>) {
 				for (file in files) {
 					if (file.kind == Dir && (collapseSubfolders || searchString.length > 0)) {
@@ -219,7 +231,13 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 						}
 
 						if (searchString.length > 0) {
-							var range = hide.comp.FancySearch.computeSearchRanges(file.name, searchString);
+							var name = if (gallerySearchFullPath) {
+								file.getRelPath().substr(base.length);
+							} else {
+								file.name;
+							}
+
+							var range = hide.comp.FancySearch.computeSearchRanges(name, searchString);
 							if (range == null) {
 								continue;
 							}
@@ -331,6 +349,9 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 						<fancy-separator></fancy-separator>
 
 						<fancy-search class="fb-search"></fancy-search>
+						<fancy-button class="btn-seach-full-path" title="Search in files path in addition of the files name">
+							<fancy-icon class="med" style="mask-image:url(\'res/icons/svg/search_folder.svg\')"></fancy-icon>
+						</fancy-button>
 					</fancy-toolbar>
 					<fancy-gallery></fancy-gallery>
 				</div>
@@ -343,7 +364,7 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 
 		var search = new hide.comp.FancySearch(null, browserLayout.find(".fb-search"));
 		search.onSearch = (string, _) -> {
-			searchString = string;
+			searchString = string.toLowerCase();
 			queueGalleryRefresh();
 		};
 
@@ -620,6 +641,14 @@ class FileBrowser extends hide.ui.View<FileBrowserState> {
 		}
 		syncCollapseSubfolders();
 
+		gallerySearchFullPath = getDisplayState("gallerySearchFullPath") ?? false;
+		gallerySearchFullPathButton = browserLayout.find(".btn-seach-full-path").get(0);
+		gallerySearchFullPathButton.onclick = (e: js.html.MouseEvent) -> {
+			gallerySearchFullPath = !gallerySearchFullPath;
+			syncGallerySearchFullPath();
+		}
+		syncGallerySearchFullPath();
+
 		FileManager.inst.onFileChangeHandlers.push(onFileChange);
 
 		layout = state.savedLayout ?? Horizontal;