Add status tooltip with profile name

This commit is contained in:
Davide De Rosa 2021-01-24 22:19:18 +01:00
parent e1d2370564
commit e833f64faf
2 changed files with 27 additions and 2 deletions

View File

@ -154,3 +154,21 @@ extension DNSProtocol: CustomStringConvertible {
}
}
}
extension VPNStatus: UIDescriptible {
public var uiDescription: String {
switch self {
case .connecting:
return L10n.Core.Vpn.connecting
case .connected:
return L10n.Core.Vpn.active
case .disconnecting:
return L10n.Core.Vpn.disconnecting
case .disconnected:
return L10n.Core.Vpn.inactive
}
}
}

View File

@ -215,10 +215,11 @@ class StatusMenu: NSObject {
itemToggleVPN = nil
itemReconnectVPN = nil
statusItem.button?.image = imageStatusInactive
statusItem.button?.toolTip = nil
return
}
itemProfileName?.title = service.screenTitle(ProfileKey(profile))
let profileTitle = service.screenTitle(ProfileKey(profile))
itemProfileName?.title = profileTitle
// itemProfileName?.image = profile.image
let needsCredentials = service.needsCredentials(for: profile)
@ -548,6 +549,12 @@ class StatusMenu: NSObject {
itemToggleVPN?.title = L10n.App.Service.Cells.Vpn.TurnOn.caption
itemToggleVPN?.action = #selector(enableVPN)
}
if let profile = service.activeProfile {
let profileTitle = service.screenTitle(ProfileKey(profile))
statusItem.button?.toolTip = "\(GroupConstants.App.name)\n\(profileTitle)\n\((vpn.status ?? .disconnected).uiDescription)"
} else {
statusItem.button?.toolTip = nil
}
switch vpn.status ?? .disconnected {
case .connected: