Client: diagrams in local folders (setting)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
sarahandClaude Opus 5.5 committed 2026-10-13 13:12:28 +02:00
1 parent f99b227cc3
commit db81507b7c
4 files changed
+376 -9

No files matched your search

+25 -2
View File
@@ -9,10 +9,11 @@ from typing import Callable
import flet as ft
import tomlkit
import LocalDiagrams
from App import App
from Core import (
AppConfig, AssetsDir, AvailableThemes, ChipButton, DataHome, ExportSettings, Home, ImportSettings,
InstalledFontFamilies, LoadSharedSettings, Palette, SharedSettings,
AppConfig, AssetsDir, AvailableThemes, ChipButton, DataHome, ExportSettings, Home, HumanSize,
ImportSettings, InstalledFontFamilies, LoadSharedSettings, Palette, SharedSettings,
)
DialogWidth = 700
@@ -109,6 +110,16 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
)
FontSizeField = ft.TextField(label="Text size", value=str(Config.FontSize), keyboard_type=ft.KeyboardType.NUMBER, width=160)
LocalDiagramsSwitch = ft.Switch(label="Draw diagrams in local folders", value=Config.LocalDiagrams)
ToolsBytes = LocalDiagrams.ToolsSize()
LocalDiagramsNote = _Note(
"```mermaid blocks (flowcharts and the like) as pictures, drawn on this computer. The first one "
"downloads what that needs: ~150 MB with Chrome, Chromium, Brave or Edge installed, ~430 MB without. "
"Off: deletes those downloads"
+ (f" ({HumanSize(ToolsBytes)} now)." if ToolsBytes else ".")
+ " On a server, the server draws them either way."
)
def ToggleMenuEntry(e) -> None:
SetMenuEntry(not MenuEntryPath.exists())
MenuButton.content = "Remove from app menu" if MenuEntryPath.exists() else "Add to app menu"
@@ -217,6 +228,8 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
ft.Divider(height=1, color=Palette.Surface1),
ft.Text("Markdown editing"),
MarkdownEditingPicker,
LocalDiagramsSwitch,
LocalDiagramsNote,
ft.Divider(height=1, color=Palette.Surface1),
OwnAppearance,
], spacing=12, scroll=ft.ScrollMode.AUTO),
@@ -266,6 +279,8 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
Config.ShowSidebar = SidebarSwitch.value
Config.ShowFilesInTree = TreeFilesSwitch.value
Config.MarkdownEditing = MarkdownEditingPicker.value or Config.MarkdownEditing
RemoveDiagramTools = Config.LocalDiagrams and not LocalDiagramsSwitch.value
Config.LocalDiagrams = LocalDiagramsSwitch.value
Config.GraphShowDirectories = GraphDirectoriesSwitch.value
Config.GraphColourByDepth = ColourByDepthSwitch.value
Config.GraphShrinkByDepth = ShrinkByDepthSwitch.value
@@ -289,6 +304,14 @@ def ShowSettingsDialog(TheApp: App, OnSaved: Callable[[bool], None], StartCatego
TheApp.Close()
OnSaved(SourceAfter != SourceBefore)
TheApp.Notify("Settings saved.", "success")
if RemoveDiagramTools:
def RemoveTools() -> None:
Freed = LocalDiagrams.ToolsSize()
LocalDiagrams.Remove()
if Freed:
TheApp.Notify(f"Removed the diagram downloads ({HumanSize(Freed)}).", "success")
Page.run_thread(RemoveTools)
TheApp.DialogOpen = True
Page.show_dialog(ft.AlertDialog(