mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-13 18:28:14 +02:00
Client: switch local/server from the connection button
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
81ebcd66a1
commit
6750f7927f
2 files changed
+23
-3
No files matched your search
+21
-2
@@ -23,7 +23,7 @@ TypeLabels = {"markdown": "Markdown", "text": "Text", "config": "Config", "html"
|
||||
|
||||
class Browser(ft.Column):
|
||||
def __init__(self, TheApp: App, OnPathChanged: Callable[[Optional[str], str, bool], None],
|
||||
OnShowSettings: Callable[[], None], OnToggleSidebar: Callable[[], None]):
|
||||
OnShowSettings: Callable[..., None], OnToggleSidebar: Callable[[], None]):
|
||||
super().__init__(expand=True, spacing=0, horizontal_alignment=ft.CrossAxisAlignment.STRETCH)
|
||||
self.TheApp = TheApp
|
||||
self.Config = TheApp.Config
|
||||
@@ -158,8 +158,15 @@ class Browser(ft.Column):
|
||||
Items.append(ft.PopupMenuItem(content="Log in", icon=ft.Icons.LOGIN, on_click=lambda e: TheApp.ShowLoginDialog()))
|
||||
else:
|
||||
Items.append(ft.PopupMenuItem(content="Log out", icon=ft.Icons.LOGOUT, on_click=lambda e: TheApp.Logout()))
|
||||
# Switch between this computer and the server, without going through Settings.
|
||||
if Server is None:
|
||||
Items.append(ft.PopupMenuItem(content="Switch to server", icon=ft.Icons.CLOUD_OUTLINED,
|
||||
on_click=lambda e: self._SwitchMode("Server")))
|
||||
else:
|
||||
Items.append(ft.PopupMenuItem(content="Switch to local folder", icon=ft.Icons.COMPUTER,
|
||||
on_click=lambda e: self._SwitchMode("Local")))
|
||||
Items.append(ft.PopupMenuItem(content="Connection settings", icon=ft.Icons.SETTINGS_OUTLINED,
|
||||
on_click=lambda e: self.OnShowSettings()))
|
||||
on_click=lambda e: self.OnShowSettings("Connection")))
|
||||
self.ConnectionButton.items = Items
|
||||
self.ConnectionButton.tooltip = TheApp.Source.Describe()
|
||||
CanWrite = TheApp.Source.CanWrite and not TheApp.ConnectError
|
||||
@@ -167,6 +174,18 @@ class Browser(ft.Column):
|
||||
Button.disabled = not CanWrite
|
||||
Button.tooltip = None if CanWrite else "Log in to change files"
|
||||
|
||||
def _SwitchMode(self, Mode: str) -> None:
|
||||
"""Local folder <-> server, from the connection button. Without a
|
||||
server address yet, it opens the Connection settings instead."""
|
||||
Config = self.TheApp.Config
|
||||
if Mode == "Server" and not Config.ServerUrl.strip():
|
||||
self.OnShowSettings("Connection")
|
||||
self.TheApp.Notify("Set the server address first.", "info")
|
||||
return
|
||||
Config.Mode = Mode
|
||||
Config.Save()
|
||||
self.TheApp.Connect() # its listeners reload the tree and this browser
|
||||
|
||||
# --- Navigation -------------------------------------------------------
|
||||
|
||||
def NavigateTo(self, Root: Optional[str], RelativePath: str, RecordHistory: bool = True) -> None:
|
||||
|
||||
Reference in new issue
Block a user