mirror of
https://git.srhtnin.garden/sarah/SaraFem.git
synced 2026-10-15 02:23:17 +02:00
Fix tags crash with preview hidden; Ctrl+B toggles the sidebar
This commit is contained in:
1 parent
4c8d272719
commit
3cb1f416fb
5 files changed
+45
-7
No files matched your search
+15
-3
@@ -53,6 +53,7 @@ class Browser(ft.Row):
|
||||
OnPathChanged: Optional[Callable[[Path], None]] = None,
|
||||
OnBookmarksChanged: Optional[Callable[[], None]] = None,
|
||||
OnSidebarSettingsChanged: Optional[Callable[[], None]] = None,
|
||||
OnToggleSidebar: Optional[Callable[[], None]] = None,
|
||||
EntryFilter: Optional[Callable[[Path], bool]] = None,
|
||||
OnActivateFile: Optional[Callable[[Path], None]] = None,
|
||||
OnSelectionChanged: Optional[Callable[[], None]] = None,
|
||||
@@ -64,6 +65,7 @@ class Browser(ft.Row):
|
||||
self.OnPathChanged = OnPathChanged
|
||||
self.OnBookmarksChanged = OnBookmarksChanged
|
||||
self.OnSidebarSettingsChanged = OnSidebarSettingsChanged
|
||||
self.OnToggleSidebar = OnToggleSidebar # Ctrl+B; the sidebar lives in Main.py, not here
|
||||
# Hooks for picker mode (Picker.py), all unused in the normal window:
|
||||
# which entries to list, what double-click/Enter on a file does
|
||||
# (instead of xdg-open), and what Escape does.
|
||||
@@ -360,7 +362,7 @@ class Browser(ft.Row):
|
||||
self._Refresh()
|
||||
if self.Config.ShowPreview:
|
||||
self.PreviewPane.ShowPath(None)
|
||||
if self.Config.ShowTags:
|
||||
if self._TagsShown():
|
||||
self.TagPanel.ShowPath(None)
|
||||
if self.OnPathChanged:
|
||||
self.OnPathChanged(TargetPath)
|
||||
@@ -468,9 +470,16 @@ class Browser(ft.Row):
|
||||
ShowPath = self.SelectedPath if len(self.SelectedPaths) <= 1 else None
|
||||
if self.Config.ShowPreview:
|
||||
self.PreviewPane.ShowPath(ShowPath)
|
||||
if self.Config.ShowTags:
|
||||
if self._TagsShown():
|
||||
self.TagPanel.ShowPath(ShowPath)
|
||||
|
||||
def _TagsShown(self) -> bool:
|
||||
"""Whether the tags panel is actually in the window. Tags placed
|
||||
"under_preview" live in the preview column, so hiding the preview
|
||||
(Ctrl+P) hides them too even with ShowTags on; updating the panel then
|
||||
crashed with "TagPanel must be added to the page first"."""
|
||||
return self.Config.ShowTags and (self.Config.TagsPosition != "under_preview" or self.Config.ShowPreview)
|
||||
|
||||
def _TargetSelection(self, Entry: Path) -> list[Path]:
|
||||
"""What a right-click/menu action on Entry should operate on: the
|
||||
whole live selection if Entry is part of a multi-selection, otherwise
|
||||
@@ -747,8 +756,11 @@ class Browser(ft.Row):
|
||||
self.GoForward()
|
||||
elif Event.key == "A" and Event.ctrl:
|
||||
self._SelectAll()
|
||||
elif Event.key == "B" and Event.ctrl:
|
||||
elif Event.key == "B" and Event.ctrl and Event.shift:
|
||||
self._ToggleBreadcrumbs()
|
||||
elif Event.key == "B" and Event.ctrl:
|
||||
if self.OnToggleSidebar:
|
||||
self.OnToggleSidebar()
|
||||
elif Event.key == "P" and Event.ctrl:
|
||||
self._TogglePreview()
|
||||
elif Event.key == "H" and Event.ctrl:
|
||||
|
||||
Reference in new issue
Block a user