mirror of
https://github.com/Mikescher/kpsync.git
synced 2025-10-24 21:55:08 +02:00
kinda works, upload, download etc
This commit is contained in:
59
app/tray.go
59
app/tray.go
@@ -7,20 +7,61 @@ import (
|
||||
|
||||
func (app *Application) initTray() {
|
||||
|
||||
sigBGStop := make(chan bool, 128)
|
||||
|
||||
trayOnReady := func() {
|
||||
|
||||
app.masterLock.Lock()
|
||||
defer app.masterLock.Unlock()
|
||||
|
||||
systray.SetIcon(assets.IconInit)
|
||||
systray.SetTitle("KeepassXC Sync")
|
||||
systray.SetTooltip("Initializing...")
|
||||
app.currSysTrayTooltop = "Initializing..."
|
||||
systray.SetTooltip(app.currSysTrayTooltop)
|
||||
|
||||
miSync := systray.AddMenuItem("Sync Now (checked)", "")
|
||||
miSyncForce := systray.AddMenuItem("Sync Now (forced)", "")
|
||||
miShowLog := systray.AddMenuItem("Show Log", "")
|
||||
systray.AddMenuItem("", "")
|
||||
app.trayItemChecksum = systray.AddMenuItem("Checksum: {...}", "")
|
||||
app.trayItemETag = systray.AddMenuItem("ETag: {...}", "")
|
||||
app.trayItemLastModified = systray.AddMenuItem("LastModified: {...}", "")
|
||||
systray.AddMenuItem("", "")
|
||||
miQuit := systray.AddMenuItem("Quit", "")
|
||||
|
||||
app.LogDebug("SysTray initialized")
|
||||
app.LogLine()
|
||||
|
||||
go func() {
|
||||
for {
|
||||
select {
|
||||
case <-miSync.ClickedCh:
|
||||
app.LogDebug("SysTray: [Sync Now (checked)] clicked")
|
||||
//TODO
|
||||
case <-miSyncForce.ClickedCh:
|
||||
app.LogDebug("SysTray: [Sync Now (forced)] clicked")
|
||||
//TODO
|
||||
case <-miShowLog.ClickedCh:
|
||||
app.LogDebug("SysTray: [Show Log] clicked")
|
||||
//TODO
|
||||
case <-miQuit.ClickedCh:
|
||||
app.LogDebug("SysTray: [Quit] clicked")
|
||||
app.sigManualStopChan <- true
|
||||
case <-sigBGStop:
|
||||
app.LogDebug("SysTray: Click-Listener goroutine stopped")
|
||||
return
|
||||
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
app.trayReady.Set(true)
|
||||
}
|
||||
|
||||
systray.Run(trayOnReady, nil)
|
||||
|
||||
sigBGStop <- true
|
||||
|
||||
app.LogDebug("SysTray stopped")
|
||||
app.LogLine()
|
||||
|
||||
@@ -53,7 +94,8 @@ func (app *Application) setTrayState(txt string, icon []byte) func() {
|
||||
}
|
||||
|
||||
systray.SetIcon(assets.IconDefault)
|
||||
systray.SetTooltip("Sleeping...")
|
||||
app.currSysTrayTooltop = "Sleeping..."
|
||||
systray.SetTooltip(app.currSysTrayTooltop)
|
||||
|
||||
finDone = true
|
||||
}
|
||||
@@ -72,3 +114,16 @@ func (app *Application) setTrayStateDirect(txt string, icon []byte) {
|
||||
systray.SetIcon(icon)
|
||||
systray.SetTooltip(txt)
|
||||
}
|
||||
|
||||
func (app *Application) setTrayTooltip(txt string) {
|
||||
if !app.trayReady.Get() {
|
||||
return
|
||||
}
|
||||
|
||||
app.masterLock.Lock()
|
||||
defer app.masterLock.Unlock()
|
||||
|
||||
systray.SetTooltip(txt)
|
||||
app.currSysTrayTooltop = txt
|
||||
systray.SetTooltip(app.currSysTrayTooltop)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user