Align Settings sections into compact rows

Add a Settings-specific row layout with a narrower label column so Storage and About no longer waste half the width on captions.

Format the Application section with the same row layout and reserve a third column for the autostart status. The checkbox column is sized to fit the longest Application checkbox so the section reads like a table.
This commit is contained in:
mixeme
2026-06-16 07:57:32 +03:00
parent 7252d3683c
commit e8e0060063
+28 -12
View File
@@ -27,6 +27,9 @@ const appID = "io.github.pysentry.desktop"
const allFolders = "All" const allFolders = "All"
const noFolder = "No folder" const noFolder = "No folder"
const minJobsSidebarWidth float32 = 480 const minJobsSidebarWidth float32 = 480
const settingsLabelWidth float32 = 140
const settingsControlWidth float32 = 330
const settingsStatusWidth float32 = 280
const projectRepositoryURL = "https://gitea.mixdep.ru/mix/gosentry" const projectRepositoryURL = "https://gitea.mixdep.ru/mix/gosentry"
// The GUI package aliases core types to keep widget callbacks short. The actual // The GUI package aliases core types to keep widget callbacks short. The actual
@@ -512,6 +515,19 @@ func detailRow(label string, value fyne.CanvasObject) fyne.CanvasObject {
return container.NewGridWithColumns(2, caption, value) return container.NewGridWithColumns(2, caption, value)
} }
func settingsRow(label string, value fyne.CanvasObject) fyne.CanvasObject {
caption := widget.NewLabelWithStyle(label, fyne.TextAlignLeading, fyne.TextStyle{Bold: true})
caption.Wrapping = fyne.TextTruncate
captionBox := container.New(minWidthLayout{width: settingsLabelWidth}, caption)
return container.NewBorder(nil, nil, captionBox, nil, value)
}
func settingsRowWithStatus(label string, value fyne.CanvasObject, status fyne.CanvasObject) fyne.CanvasObject {
valueBox := container.New(minWidthLayout{width: settingsControlWidth}, value)
statusBox := container.New(minWidthLayout{width: settingsStatusWidth}, status)
return settingsRow(label, container.NewBorder(nil, nil, valueBox, nil, statusBox))
}
func filteredJobIndexes(jobs []job, folder string) []int { func filteredJobIndexes(jobs []job, folder string) []int {
indexes := make([]int, 0, len(jobs)) indexes := make([]int, 0, len(jobs))
for index, current := range jobs { for index, current := range jobs {
@@ -826,24 +842,24 @@ func settingsView(w fyne.Window, store *core.Store, jobs *[]job) fyne.CanvasObje
return container.NewPadded(container.NewVBox( return container.NewPadded(container.NewVBox(
widget.NewLabelWithStyle("Application", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Application", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
container.NewBorder(nil, nil, nil, autostartStatus, startOnLogin), settingsRowWithStatus("Autostart", startOnLogin, autostartStatus),
minimizeToTray, settingsRow("Tray", container.New(minWidthLayout{width: settingsControlWidth}, minimizeToTray)),
notifications, settingsRow("Notifications", container.New(minWidthLayout{width: settingsControlWidth}, notifications)),
widget.NewSeparator(), widget.NewSeparator(),
widget.NewLabelWithStyle("Storage", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("Storage", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
detailRow("Config YAML", widget.NewLabel(store.Paths.ConfigPath)), settingsRow("Config YAML", widget.NewLabel(store.Paths.ConfigPath)),
detailRow("Jobs directory", container.NewBorder(nil, nil, nil, jobsDirBrowse, jobsDir)), settingsRow("Jobs directory", container.NewBorder(nil, nil, nil, jobsDirBrowse, jobsDir)),
detailRow("Logs directory", container.NewBorder(nil, nil, nil, logsDirBrowse, logsDir)), settingsRow("Logs directory", container.NewBorder(nil, nil, nil, logsDirBrowse, logsDir)),
detailRow("Max log files", maxLogFiles), settingsRow("Max log files", maxLogFiles),
detailRow("Max log age days", maxLogAgeDays), settingsRow("Max log age days", maxLogAgeDays),
saveSettings, saveSettings,
settingsStatus, settingsStatus,
widget.NewSeparator(), widget.NewSeparator(),
widget.NewLabelWithStyle("About", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}), widget.NewLabelWithStyle("About", fyne.TextAlignLeading, fyne.TextStyle{Bold: true}),
detailRow("GoSentry", widget.NewLabel(core.Version)), settingsRow("GoSentry", widget.NewLabel(core.Version)),
detailRow("Go", widget.NewLabel(runtime.Version())), settingsRow("Go", widget.NewLabel(runtime.Version())),
detailRow("Fyne", widget.NewLabel(fyneVersion())), settingsRow("Fyne", widget.NewLabel(fyneVersion())),
detailRow("Repository", widget.NewHyperlink(projectRepositoryURL, mustParseURL(projectRepositoryURL))), settingsRow("Repository", widget.NewHyperlink(projectRepositoryURL, mustParseURL(projectRepositoryURL))),
)) ))
} }