From 728af0d9d3543b2319543156100e61c63ee4b2df Mon Sep 17 00:00:00 2001 From: Marcel Otte Date: Wed, 8 Jun 2022 10:04:28 +0200 Subject: [PATCH] struct for saving and message level handling ... --- ui/ui_main.go | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/ui/ui_main.go b/ui/ui_main.go index 1c7f45e..8168c3c 100644 --- a/ui/ui_main.go +++ b/ui/ui_main.go @@ -13,6 +13,11 @@ import ( "github.com/qwc/backive" ) +type UISettings struct { + hideUntil time.Time + globalLevel int +} + var ( app fyne.App window fyne.Window @@ -20,6 +25,8 @@ var ( db backive.Database doNotShowUntil time.Time = time.Unix(0, 0) c net.Conn + uisettings UISettings + messageLevel int ) func Init(a fyne.App, w fyne.Window, conf backive.Configuration, d backive.Database) { @@ -85,16 +92,34 @@ func ShallShow(data map[string]string) bool { if level <= 10 { return true } - - return true + if int(level) <= uisettings.globalLevel && messageLevel > 0 { + return false + } + if int(level) <= uisettings.globalLevel { + return true + } + return false } func SetHideUntil(until time.Time) { - + uisettings.hideUntil = until } func SetMessageLevel(level int) { + if level <= 10 { + messageLevel = level + } else { + uisettings.globalLevel = level + messageLevel = 0 + } +} +func SaveSettings() { + // save internal settings to file in homedir +} + +func LoadSettings() { + // load settings } func makeTray(app fyne.App) {