mirror of
https://git.srhtnin.garden/sarah/SaraFem.git
synced 2026-10-15 10:23:17 +02:00
Add SaraSortd integration: show incoming/outgoing sort rules for the browsed directory
This commit is contained in:
1 parent
31b6c554e6
commit
d588d445b4
4 files changed
+436
-9
No files matched your search
+67
@@ -5,6 +5,7 @@ look good... sidebar with areas, then a much bigger main box"), with the
|
||||
left/right/top/bottom-style choices as icon-button pickers instead of text
|
||||
dropdowns ("some way to choose layout in a more graphical... way")."""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
import flet as ft
|
||||
@@ -66,6 +67,8 @@ def BuildSettingsDialog(
|
||||
Config: AppConfig,
|
||||
OnSave: Callable[[], None],
|
||||
OnDismiss: Callable[[], None],
|
||||
OnExport: Callable[[str], None],
|
||||
OnImport: Callable[[str], None],
|
||||
) -> ft.AlertDialog:
|
||||
Themes = AvailableThemes()
|
||||
Fonts = InstalledFontFamilies()
|
||||
@@ -91,6 +94,14 @@ def BuildSettingsDialog(
|
||||
SharedFontDropdown = FontPicker(Shared.FontFamily)
|
||||
SharedTitleBarSwitch = ft.Switch(label="Hide window title bar", value=Shared.HideWindowTitleBar)
|
||||
|
||||
# Export/import as one portable file (Features/Major) — separate from
|
||||
# the shared settings above: that's the always-on, automatic sync every
|
||||
# SaraSuite program reads on startup, this is a one-off snapshot you
|
||||
# choose a path for, to back up or carry to another machine.
|
||||
SettingsFileField = ft.TextField(
|
||||
value=str(Path.home() / "SaraFem-Settings.toml"), label="Settings file path"
|
||||
)
|
||||
|
||||
# "Middle" tab: the main file-list pane itself, not the panels around it.
|
||||
ViewModePicker, GetViewMode = _OptionPicker(
|
||||
[("list", "List", "VIEW_LIST_OUTLINED"), ("grid", "Grid", "GRID_VIEW_OUTLINED")], Config.ViewMode
|
||||
@@ -111,6 +122,15 @@ def BuildSettingsDialog(
|
||||
[("below", "Below", "SOUTH"), ("above", "Above", "NORTH")],
|
||||
"below" if Config.GridNameBelowIcon else "above",
|
||||
)
|
||||
ListIconSizeField = ft.TextField(
|
||||
value=str(Config.ListIconSize), label="List icon size", keyboard_type=ft.KeyboardType.NUMBER
|
||||
)
|
||||
FontSizeField = ft.TextField(
|
||||
value=str(Config.FontSize), label="Name font size", keyboard_type=ft.KeyboardType.NUMBER
|
||||
)
|
||||
ToolbarHamburgerSwitch = ft.Switch(
|
||||
label="Collapse toolbar buttons into one menu", value=Config.ToolbarHamburger
|
||||
)
|
||||
|
||||
# SaraFem's own values ("General" tab), only used with shared settings off.
|
||||
ThemeDropdown = ThemePicker(Config.Theme)
|
||||
@@ -229,6 +249,13 @@ def BuildSettingsDialog(
|
||||
hint_text="/home/sarah/Applications/SaraTag/.saratag",
|
||||
)
|
||||
|
||||
SaraSortdSwitch = ft.Switch(label="Enable SaraSortd integration", value=Config.SaraSortd.Enabled)
|
||||
SaraSortdPathField = ft.TextField(
|
||||
value=Config.SaraSortd.GlobalConfPath,
|
||||
label="SaraSortd GlobalConf.toml path",
|
||||
hint_text="/home/sarah/Applications/SaraSortd/GlobalConf.toml",
|
||||
)
|
||||
|
||||
Categories: dict[str, ft.Control] = {
|
||||
"SaraSuite": ft.Column(
|
||||
[
|
||||
@@ -239,6 +266,22 @@ def BuildSettingsDialog(
|
||||
SharedThemeDropdown,
|
||||
SharedFontDropdown,
|
||||
SharedTitleBarSwitch,
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
_SectionLabel("Export/import settings as one file — this tab's shared "
|
||||
"settings plus everything else in Options"),
|
||||
SettingsFileField,
|
||||
ft.Row(
|
||||
[
|
||||
ft.OutlinedButton(
|
||||
content="Export", style=ChipButtonStyle(),
|
||||
on_click=lambda e: OnExport(SettingsFileField.value.strip()),
|
||||
),
|
||||
ft.OutlinedButton(
|
||||
content="Import", style=ChipButtonStyle(),
|
||||
on_click=lambda e: OnImport(SettingsFileField.value.strip()),
|
||||
),
|
||||
]
|
||||
),
|
||||
],
|
||||
spacing=12,
|
||||
),
|
||||
@@ -269,6 +312,10 @@ def BuildSettingsDialog(
|
||||
ListContentSwitch,
|
||||
ListAccessSwitch,
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
_SectionLabel("Font and icon sizes"),
|
||||
FontSizeField,
|
||||
ListIconSizeField,
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
_SectionLabel("Grid"),
|
||||
GridIconSizeField,
|
||||
_SectionLabel("Name position"),
|
||||
@@ -288,6 +335,8 @@ def BuildSettingsDialog(
|
||||
PasteButtonSwitch,
|
||||
ViewToggleButtonSwitch,
|
||||
OptionsButtonSwitch,
|
||||
ft.Divider(height=1, color=Palette.Surface1),
|
||||
ToolbarHamburgerSwitch,
|
||||
],
|
||||
spacing=12,
|
||||
),
|
||||
@@ -341,6 +390,18 @@ def BuildSettingsDialog(
|
||||
scroll=ft.ScrollMode.AUTO,
|
||||
),
|
||||
"SaraTag": ft.Column([SaraTagSwitch, SaraTagPathField], spacing=12),
|
||||
"SaraSortd": ft.Column(
|
||||
[
|
||||
SaraSortdSwitch,
|
||||
SaraSortdPathField,
|
||||
_SectionLabel(
|
||||
'Shows what SaraSortd does with the directory you\'re browsing, e.g. '
|
||||
'"*.png -> ~/Pictures" for a watched input directory, or '
|
||||
'"*.png <- ~/Downloads" for one of its output directories.'
|
||||
),
|
||||
],
|
||||
spacing=12,
|
||||
),
|
||||
}
|
||||
|
||||
DetailArea = ft.Container(Categories["General"], expand=True, padding=ft.Padding.only(left=12))
|
||||
@@ -378,6 +439,7 @@ def BuildSettingsDialog(
|
||||
Config.ListShowContent = ListContentSwitch.value
|
||||
Config.ListShowAccess = ListAccessSwitch.value
|
||||
Config.GridNameBelowIcon = GetGridNamePosition() == "below"
|
||||
Config.ToolbarHamburger = ToolbarHamburgerSwitch.value
|
||||
Config.UseSharedSettings = UseSharedSwitch.value
|
||||
Config.Theme = ThemeDropdown.value
|
||||
Config.FontFamily = FontDropdown.value or Config.FontFamily
|
||||
@@ -421,6 +483,9 @@ def BuildSettingsDialog(
|
||||
Config.SaraTag.Enabled = SaraTagSwitch.value
|
||||
Config.SaraTag.CoreModulePath = SaraTagPathField.value.strip()
|
||||
|
||||
Config.SaraSortd.Enabled = SaraSortdSwitch.value
|
||||
Config.SaraSortd.GlobalConfPath = SaraSortdPathField.value.strip()
|
||||
|
||||
for Field, TargetAttr in (
|
||||
(SidebarWidthField, "SidebarWidth"),
|
||||
(BookmarksMinHeightField, "BookmarksMinHeight"),
|
||||
@@ -437,6 +502,8 @@ def BuildSettingsDialog(
|
||||
(TagPanelMinHeightField, "TagPanelMinHeight"),
|
||||
(TagPanelMaxHeightField, "TagPanelMaxHeight"),
|
||||
(GridIconSizeField, "GridIconSize"),
|
||||
(ListIconSizeField, "ListIconSize"),
|
||||
(FontSizeField, "FontSize"),
|
||||
):
|
||||
try:
|
||||
setattr(Config, TargetAttr, int(Field.value))
|
||||
|
||||
Reference in new issue
Block a user