mirror of
https://git.srhtnin.garden/sarah/SaraSort.git
synced 2026-10-14 10:48:11 +02:00
Look like SaraFem and SaraSuite: no custom title bar
The window keeps its own title bar (or none, per HideWindowTitleBar), with SaraSuite's header (name, Add to app menu for AppImages, gear). Settings is now a dialog laid out like SaraFem's, with export/import on the SaraSuite tab, and notifications use SaraFem's tinted toast style. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
f7ed23edf9
commit
e90f59bc16
6 files changed
+338
-219
No files matched your search
@@ -1,15 +1,19 @@
|
||||
"""SaraSort: a GUI for configuring SaraSortd. It doesn't sort anything itself;
|
||||
it reads and edits SaraSortd's configs and controls its systemd service."""
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import flet as ft
|
||||
|
||||
from ConfigPage import ConfigPage
|
||||
from Core import (
|
||||
AppName, ApplyAppearance, AssetsDir, BuildTheme, BundledFontFamily, EffectiveSettings, LoadConfig, Palette,
|
||||
AppName, ApplyAppearance, AssetsDir, BuildTheme, BundledFontFamily, ChipButtonStyle, DataHome, EffectiveSettings,
|
||||
LoadConfig, Palette,
|
||||
)
|
||||
from FlowPage import FlowPage
|
||||
from ServicePage import ServicePage
|
||||
from SettingsPage import SettingsPage
|
||||
from Settings import ShowSettingsDialog
|
||||
from TemplatesPage import TemplatesPage
|
||||
from ToolsPage import ToolsPage
|
||||
from Widgets import App
|
||||
@@ -20,10 +24,31 @@ Destinations = [
|
||||
("Configs", ft.Icons.TUNE_OUTLINED, ft.Icons.TUNE),
|
||||
("Templates", ft.Icons.DASHBOARD_CUSTOMIZE_OUTLINED, ft.Icons.DASHBOARD_CUSTOMIZE),
|
||||
("Tools", ft.Icons.BUILD_OUTLINED, ft.Icons.BUILD),
|
||||
("Settings", ft.Icons.SETTINGS_OUTLINED, ft.Icons.SETTINGS),
|
||||
|
||||
]
|
||||
Names = [Name for Name, _, _ in Destinations]
|
||||
|
||||
# When running as an AppImage, SaraSort can put itself in the app menu (like SaraSuite).
|
||||
_AppImage = os.environ.get("APPIMAGE", "")
|
||||
_MenuEntry = DataHome / "applications" / "SaraSort.desktop"
|
||||
_MenuIcon = DataHome / "SaraSort" / "SaraSort.png"
|
||||
|
||||
|
||||
def _SetMenuEntry(Enabled: bool) -> None:
|
||||
if not Enabled:
|
||||
_MenuEntry.unlink(missing_ok=True)
|
||||
_MenuIcon.unlink(missing_ok=True)
|
||||
return
|
||||
_MenuIcon.parent.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy(AssetsDir / "Icon.png", _MenuIcon)
|
||||
_MenuEntry.parent.mkdir(parents=True, exist_ok=True)
|
||||
_MenuEntry.write_text(
|
||||
"[Desktop Entry]\nType=Application\nName=SaraSort\n"
|
||||
"Comment=Configure SaraSortd, the file sorting daemon\n"
|
||||
f"Exec={_AppImage}\nIcon={_MenuIcon}\nTerminal=false\n"
|
||||
"Categories=Utility;\nStartupNotify=true\n"
|
||||
)
|
||||
|
||||
|
||||
def Main(Page: ft.Page) -> None:
|
||||
Config = LoadConfig()
|
||||
@@ -70,7 +95,6 @@ def Main(Page: ft.Page) -> None:
|
||||
"Configs": ConfigPage(TheApp),
|
||||
"Templates": TemplatesPage(TheApp),
|
||||
"Tools": ToolsPage(TheApp),
|
||||
"Settings": SettingsPage(TheApp, OnSaved=lambda: None),
|
||||
})
|
||||
|
||||
Rail = ft.NavigationRail(
|
||||
@@ -84,23 +108,37 @@ def Main(Page: ft.Page) -> None:
|
||||
on_change=lambda e: Navigate(Names[e.control.selected_index]),
|
||||
)
|
||||
|
||||
async def CloseWindow(e) -> None:
|
||||
await Page.window.close()
|
||||
def ToggleMenuEntry(e) -> None:
|
||||
_SetMenuEntry(not _MenuEntry.exists())
|
||||
MenuButton.content = "Remove from app menu" if _MenuEntry.exists() else "Add to app menu"
|
||||
MenuButton.update()
|
||||
|
||||
TitleRow = [ft.WindowDragArea(
|
||||
ft.Container(ft.Text(AppName, size=18, color=Palette.Mauve), padding=ft.Padding.only(left=16, top=6, bottom=6)),
|
||||
expand=True,
|
||||
)]
|
||||
if Appearance.HideWindowTitleBar:
|
||||
TitleRow += [
|
||||
ft.IconButton(ft.Icons.MINIMIZE, icon_size=16, tooltip="Minimize",
|
||||
on_click=lambda e: (setattr(Page.window, "minimized", True), Page.update())),
|
||||
ft.IconButton(ft.Icons.CLOSE, icon_size=16, tooltip="Close", on_click=CloseWindow),
|
||||
]
|
||||
MenuButton = ft.OutlinedButton(
|
||||
content="Remove from app menu" if _MenuEntry.exists() else "Add to app menu",
|
||||
style=ChipButtonStyle(),
|
||||
visible=bool(_AppImage),
|
||||
on_click=ToggleMenuEntry,
|
||||
)
|
||||
SettingsButton = ft.IconButton(
|
||||
icon=ft.Icons.SETTINGS_OUTLINED,
|
||||
icon_color=Palette.Mauve,
|
||||
tooltip="Settings",
|
||||
# SaraSortd's paths may have changed, so reload the page afterwards.
|
||||
on_click=lambda e: ShowSettingsDialog(TheApp, lambda: Navigate(State["Current"])),
|
||||
)
|
||||
|
||||
Page.add(ft.Column([
|
||||
ft.Container(ft.Row(TitleRow, spacing=0), bgcolor=Palette.Mantle,
|
||||
border=ft.Border.only(bottom=ft.BorderSide(1, Palette.Surface1))),
|
||||
ft.Container(
|
||||
content=ft.Row([
|
||||
ft.Text(AppName, size=24, color=Palette.Mauve),
|
||||
ft.Container(expand=True),
|
||||
MenuButton,
|
||||
SettingsButton,
|
||||
]),
|
||||
padding=ft.Padding.symmetric(horizontal=16, vertical=8),
|
||||
bgcolor=Palette.Mantle,
|
||||
border=ft.Border.only(bottom=ft.BorderSide(1, Palette.Surface1)),
|
||||
),
|
||||
ft.Row([Rail, ft.VerticalDivider(width=1, color=Palette.Surface1), Body], expand=True, spacing=0,
|
||||
vertical_alignment=ft.CrossAxisAlignment.STRETCH),
|
||||
], expand=True, spacing=0))
|
||||
|
||||
Reference in new issue
Block a user