diff options
author | Alexander Neumann <alexander.neumann@picos-software.com> | 2019-05-14 18:18:06 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-15 20:11:19 +0200 |
commit | be01929f5d00456024e203bc56955105930e248c (patch) | |
tree | 89e4461bc9aba159e91396dde0b165fda74e886b /ui/tray.go | |
parent | ui: don't closehandle on a menu (diff) | |
download | wireguard-windows-be01929f5d00456024e203bc56955105930e248c.tar.xz wireguard-windows-be01929f5d00456024e203bc56955105930e248c.zip |
ui: fix dpi related code smells
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com>
Diffstat (limited to 'ui/tray.go')
-rw-r--r-- | ui/tray.go | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -55,7 +55,7 @@ func (tray *Tray) setup() error { tray.SetToolTip("WireGuard: Deactivated") tray.SetVisible(true) - if icon, err := loadLogoIcon(tray.mtw.DPI() / 6); err == nil { //TODO: calculate DPI dynamically + if icon, err := loadLogoIcon(16); err == nil { tray.SetIcon(icon) } @@ -219,7 +219,7 @@ func (tray *Tray) onTunnelChange(tunnel *service.Tunnel, state service.TunnelSta } func (tray *Tray) updateGlobalState(globalState service.TunnelState) { - if icon, err := iconWithOverlayForState(globalState, tray.mtw.DPI()/6); err == nil { //TODO: calculate DPI dynamically + if icon, err := iconWithOverlayForState(globalState, 16); err == nil { tray.SetIcon(icon) } @@ -287,14 +287,14 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta tunnelAction.SetEnabled(true) tunnelAction.SetChecked(true) if !wasChecked && showNotifications { - icon, _ := iconWithOverlayForState(state, tray.mtw.DPI()*4/3) //TODO: calculate dpi dynamically + icon, _ := iconWithOverlayForState(state, 128) tray.ShowCustom("WireGuard Activated", fmt.Sprintf("The %s tunnel has been activated.", tunnel.Name), icon) } case service.TunnelStopped: tunnelAction.SetChecked(false) if wasChecked && showNotifications { - icon, _ := loadSystemIcon("imageres", 26, tray.mtw.DPI()*4/3) //TODO: this icon isn't very good..., also calculate dpi dynamically + icon, _ := loadSystemIcon("imageres", 26, 128) //TODO: this icon isn't very good... tray.ShowCustom("WireGuard Deactivated", fmt.Sprintf("The %s tunnel has been deactivated.", tunnel.Name), icon) } } @@ -303,10 +303,8 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta func (tray *Tray) UpdateFound() { action := walk.NewAction() action.SetText("An Update is Available!") - iconSize := tray.mtw.DPI() / 6 //TODO: This should use dynamic DPI. - menuIcon, _ := loadSystemIcon("imageres", 1, iconSize) - bitmap, _ := walk.NewBitmapFromIcon(menuIcon, walk.Size{iconSize, iconSize}) - action.SetImage(bitmap) + menuIcon, _ := loadSystemIcon("imageres", 1, 16) + action.SetImage(menuIcon) action.SetDefault(true) showUpdateTab := func() { if !tray.mtw.Visible() { @@ -320,7 +318,7 @@ func (tray *Tray) UpdateFound() { tray.ContextMenu().Actions().Insert(tray.ContextMenu().Actions().Len()-2, action) showUpdateBalloon := func() { - icon, _ := loadSystemIcon("imageres", 1, tray.mtw.DPI()*4/3) //TODO: calculate DPI dynamically + icon, _ := loadSystemIcon("imageres", 1, 128) tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon) } |