mirror of
https://git.srhtnin.garden/sarah/SaraView.git
synced 2026-10-15 02:43:17 +02:00
Client: your server settings, profile, account and admin in Settings
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
e2cb25e2e1
commit
c7a7596e99
3 files changed
+401
-2
No files matched your search
+26
-2
@@ -15,6 +15,8 @@ from Core import (
|
||||
AppConfig, AssetsDir, AvailableThemes, ChipButton, DataHome, ExportSettings, Home, HumanSize,
|
||||
ImportSettings, InstalledFontFamilies, LoadSharedSettings, Palette, SharedSettings,
|
||||
)
|
||||
from ServerSettings import ServerSections
|
||||
from Sources import SourceError
|
||||
|
||||
DialogWidth = 700
|
||||
DialogHeight = 520
|
||||
@@ -252,6 +254,23 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
|
||||
], spacing=12, scroll=ft.ScrollMode.AUTO),
|
||||
}
|
||||
|
||||
# Logged in to a server: your account and server settings too, like the
|
||||
# web view's Settings (ServerSettings.py).
|
||||
Server = TheApp.Server
|
||||
Extra = None
|
||||
if Server is not None and Server.User is not None and not TheApp.ConnectError:
|
||||
def LogOut() -> None:
|
||||
TheApp.Close()
|
||||
TheApp.Logout()
|
||||
|
||||
try:
|
||||
Extra = ServerSections(TheApp, LogOut)
|
||||
Categories.update(Extra.Categories)
|
||||
except SourceError as Error:
|
||||
TheApp.Notify(f"Couldn't load your server settings: {Error}", "error")
|
||||
if StartCategory not in Categories:
|
||||
StartCategory = "General"
|
||||
|
||||
DetailArea = ft.Container(Categories[StartCategory], expand=True, padding=ft.Padding.only(left=12))
|
||||
CategoryTiles: dict[str, ft.ListTile] = {}
|
||||
|
||||
@@ -264,12 +283,16 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
|
||||
|
||||
for Name in Categories:
|
||||
CategoryTiles[Name] = ft.ListTile(
|
||||
title=Name, selected=Name == StartCategory, selected_tile_color=Palette.Surface1,
|
||||
title=Name, selected=Name == StartCategory, dense=True, # room for the server sections too selected_tile_color=Palette.Surface1,
|
||||
selected_color=Palette.Mauve, on_click=lambda e, N=Name: SelectCategory(N),
|
||||
)
|
||||
CategoryList = ft.Column(list(CategoryTiles.values()), spacing=0, scroll=ft.ScrollMode.AUTO)
|
||||
|
||||
def Save(e) -> None:
|
||||
ServerFilesBefore = Extra and (Extra.Values.get("ShowHiddenFolders"), Extra.Values.get("ShowSvFiles"))
|
||||
if Extra is not None and not Extra.Save():
|
||||
return # stays open, so nothing's lost
|
||||
ServerFilesAfter = Extra and (Extra.Switches["ShowHiddenFolders"].value, Extra.Switches["ShowSvFiles"].value)
|
||||
SourceBefore = (Config.Mode, Config.LocalRoot, Config.ServerUrl, Config.ShowHiddenFolders,
|
||||
Config.ShowSvFiles, Config.HideInternalFiles)
|
||||
Config.UseSharedSettings = UseSharedSwitch.value
|
||||
@@ -305,7 +328,8 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
|
||||
SourceAfter = (Config.Mode, Config.LocalRoot, Config.ServerUrl, Config.ShowHiddenFolders,
|
||||
Config.ShowSvFiles, Config.HideInternalFiles)
|
||||
TheApp.Close()
|
||||
OnSaved(SourceAfter != SourceBefore)
|
||||
# A server's hidden-file settings change what it lists: reload like a new source.
|
||||
OnSaved(SourceAfter != SourceBefore or ServerFilesAfter != ServerFilesBefore)
|
||||
TheApp.Notify("Settings saved.", "success")
|
||||
if RemoveDiagramTools:
|
||||
def RemoveTools() -> None:
|
||||
|
||||
Reference in new issue
Block a user