mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Fixed download sizes and directory highlighting
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
843ad1986e
commit
d4c018a402
8 files changed
+113
-37
No files matched your search
@@ -26,6 +26,12 @@ def _SetHighlight(Label: ft.Text, Holder: ft.Container, IsSelected: bool) -> Non
|
||||
Holder.update()
|
||||
|
||||
|
||||
def _SetOnPath(Holder: ft.Container, IsOnPath: bool) -> None:
|
||||
"""The bar beside every directory you're in (the web view's TreeRowCurrentDirectory)."""
|
||||
Holder.border = ft.Border.only(left=ft.BorderSide(2, Palette.Mauve)) if IsOnPath else None
|
||||
Holder.update()
|
||||
|
||||
|
||||
class _FileLeaf:
|
||||
"""A file in the tree: a plain row (no expand arrow) indented like a
|
||||
child tile, so names line up with the directories beside it."""
|
||||
@@ -104,6 +110,9 @@ class _FiletreeNode:
|
||||
def SetSelected(self, IsSelected: bool) -> None:
|
||||
_SetHighlight(self.NameLabel, self.NameContainer, IsSelected)
|
||||
|
||||
def SetOnPath(self, IsOnPath: bool) -> None:
|
||||
_SetOnPath(self.NameContainer, IsOnPath)
|
||||
|
||||
|
||||
class Filetree(ft.Container):
|
||||
def __init__(self, TheApp: App, OnNavigate: Callable[[str, str], None], OnOpenFile: Callable[[str, str], None]):
|
||||
@@ -112,6 +121,7 @@ class Filetree(ft.Container):
|
||||
self.OnOpenFile = OnOpenFile
|
||||
self.RootNodes: dict[str, _FiletreeNode] = {}
|
||||
self.SelectedNode: Optional[Union[_FiletreeNode, _FileLeaf]] = None
|
||||
self.PathNodes: list[_FiletreeNode] = [] # the directories you're in, marked
|
||||
self.TreeList = ft.ListView(expand=True)
|
||||
self.SourceLabel = ft.Text("", size=12, color=Palette.Overlay0, overflow=ft.TextOverflow.ELLIPSIS, max_lines=1)
|
||||
super().__init__(
|
||||
@@ -129,6 +139,7 @@ class Filetree(ft.Container):
|
||||
Source = self.TheApp.Source
|
||||
self.SourceLabel.value = "Not connected" if self.TheApp.ConnectError else Source.Describe()
|
||||
self.SelectedNode = None
|
||||
self.PathNodes = []
|
||||
Roots: list[str] = []
|
||||
if not self.TheApp.ConnectError:
|
||||
try:
|
||||
@@ -151,6 +162,9 @@ class Filetree(ft.Container):
|
||||
if self.SelectedNode:
|
||||
self.SelectedNode.SetSelected(False)
|
||||
self.SelectedNode = None
|
||||
for Marked in self.PathNodes:
|
||||
Marked.SetOnPath(False)
|
||||
self.PathNodes = []
|
||||
Node = self.RootNodes.get(Root or "")
|
||||
if Node is None:
|
||||
return
|
||||
@@ -169,5 +183,15 @@ class Filetree(ft.Container):
|
||||
Target = Leaf
|
||||
break
|
||||
Node = Target = NextNode
|
||||
# Every directory down to (and including) the one you're in, like the web view.
|
||||
Walk = self.RootNodes.get(Root or "")
|
||||
self.PathNodes = [Walk] if Walk else []
|
||||
for Part in Parts:
|
||||
Walk = Walk.ChildNodes.get(Part) if Walk else None
|
||||
if Walk is None:
|
||||
break
|
||||
self.PathNodes.append(Walk)
|
||||
for Marked in self.PathNodes:
|
||||
Marked.SetOnPath(True)
|
||||
Target.SetSelected(True)
|
||||
self.SelectedNode = Target
|
||||
Reference in new issue
Block a user