From 69088149b2ae43893b7326998985bce61371b40d Mon Sep 17 00:00:00 2001 From: ErikKalkoken Date: Thu, 18 Jul 2024 16:56:11 +0200 Subject: [PATCH] Allow hiding value frame --- internal/ui/menu.go | 18 ++++++++++++++++++ internal/ui/ui.go | 7 +++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/internal/ui/menu.go b/internal/ui/menu.go index 6867a5a..5b13a2c 100644 --- a/internal/ui/menu.go +++ b/internal/ui/menu.go @@ -26,6 +26,7 @@ const ( settingRecentFileCountDefault = 5 settingLastWindowHeight = "last-window-height" settingLastWindowWidth = "last-window-width" + settingLastValueFrameHidden = "last-show-value-detail" ) func (u *UI) makeMenu() *fyne.MainMenu { @@ -105,6 +106,10 @@ func (u *UI) makeMenu() *fyne.MainMenu { u.showSettingsDialog() }), ) + toogleValueDetail := fyne.NewMenuItem("Show value detail", func() { + u.toogleViewDetail() + }) + toogleValueDetail.Checked = !u.detail.Hidden u.viewMenu = fyne.NewMenu("View", fyne.NewMenuItem("Scroll to top", func() { u.treeWidget.ScrollToTop() @@ -122,6 +127,8 @@ func (u *UI) makeMenu() *fyne.MainMenu { fyne.NewMenuItem("Collapse All", func() { u.treeWidget.CloseAllBranches() }), + fyne.NewMenuItemSeparator(), + toogleValueDetail, ) helpMenu := fyne.NewMenu("Help", fyne.NewMenuItem("Report a bug", func() { @@ -199,3 +206,14 @@ func (u *UI) updateRecentFilesMenu() { u.fileMenu.Items[3].ChildMenu.Items = items u.fileMenu.Refresh() } + +func (u *UI) toogleViewDetail() { + if u.detail.Hidden { + u.detail.Show() + } else { + u.detail.Hide() + } + toogleValueDetail := u.viewMenu.Items[7] + toogleValueDetail.Checked = !u.detail.Hidden + u.viewMenu.Refresh() +} diff --git a/internal/ui/ui.go b/internal/ui/ui.go index ea31bc6..ccecb79 100644 --- a/internal/ui/ui.go +++ b/internal/ui/ui.go @@ -71,6 +71,7 @@ type UI struct { jumpToSelection *widget.Button copyKeyClipboard *widget.Button + detail *fyne.Container copyValueClipboard *widget.Button valueDisplay *widget.RichText valueRaw string @@ -167,13 +168,14 @@ func NewUI(app fyne.App) (*UI, error) { u.window.Clipboard().SetContent(u.valueRaw) }) u.copyValueClipboard.Disable() - detail := container.NewBorder( + u.detail = container.NewBorder( nil, nil, nil, u.copyValueClipboard, container.NewScroll(u.valueDisplay), ) + u.detail.Hidden = app.Preferences().BoolWithFallback(settingLastValueFrameHidden, false) // status bar frame statusBar := container.NewHBox(u.statusTreeSize) @@ -196,7 +198,7 @@ func NewUI(app fyne.App) (*UI, error) { } c := container.NewBorder( - container.NewVBox(searchBar, selection, detail, widget.NewSeparator()), + container.NewVBox(searchBar, selection, u.detail, widget.NewSeparator()), container.NewVBox(widget.NewSeparator(), statusBar), nil, nil, @@ -228,6 +230,7 @@ func NewUI(app fyne.App) (*UI, error) { u.window.SetOnClosed(func() { app.Preferences().SetFloat(settingLastWindowWidth, float64(u.window.Canvas().Size().Width)) app.Preferences().SetFloat(settingLastWindowHeight, float64(u.window.Canvas().Size().Height)) + app.Preferences().SetBool(settingLastValueFrameHidden, u.detail.Hidden) }) return u, nil }