feat: added flag emoji instead of country code in the popup view, and countryCode and flag options to the Text widget (#2916)

This commit is contained in:
Serhiy Mytrovtsiy
2026-02-23 19:26:00 +01:00
parent 3812657460
commit dec8f08749
5 changed files with 24 additions and 3 deletions

View File

@@ -275,6 +275,8 @@ public class Network: Module {
case "private": replacement = value.laddr.v4 ?? value.laddr.v6 ?? "-"
case "privateV4": replacement = value.laddr.v4 ?? "-"
case "privateV6": replacement = value.laddr.v6 ?? "-"
case "countryCode": replacement = value.raddr.countryCode ?? "-"
case "flag": replacement = value.raddr.countryCode != nil ? countryFlag(value.raddr.countryCode!) : "-"
default: return
}
case "$interface":

View File

@@ -525,7 +525,12 @@ internal class Popup: PopupWrapper {
}
var ip = addr
if let cc = value.raddr.countryCode, !cc.isEmpty {
ip += " (\(cc))"
if let flag = countryFlag(cc) {
ip += " \(flag)"
} else {
ip += " (\(cc))"
}
self.publicIPv4Field?.toolTip = cc
}
if self.publicIPv4Field?.stringValue != ip {
self.publicIPv4Field?.stringValue = ip
@@ -545,7 +550,12 @@ internal class Popup: PopupWrapper {
}
var ip = addr
if let cc = value.raddr.countryCode {
ip += " (\(cc))"
if let flag = countryFlag(cc) {
ip += " \(flag)"
} else {
ip += " (\(cc))"
}
self.publicIPv6Field?.toolTip = cc
}
if self.publicIPv6Field?.stringValue != ip {
self.publicIPv6Field?.stringValue = ip

View File

@@ -29,6 +29,8 @@ You can use a combination of any of the variables. There is only one limitation:
<li><b>$addr.private</b>: <small>Private/local IP address.</small></li>
<li><b>$addr.privateV4</b>: <small>Private/local IPv4 address.</small></li>
<li><b>$addr.privateV6</b>: <small>Private/local IPv6 address.</small></li>
<li><b>$addr.countryCode</b>: <small>Country code based on the public IP address.</small></li>
<li><b>$addr.flag</b>: <small>Emoji flag based on the country code.</small></li>
<li><b>$interface.displayName</b>: <small>Network interface name.</small></li>
<li><b>$interface.BSDName</b>: <small>BSD name of the network interface.</small></li>
<li><b>$interface.address</b>: <small>MAC address of the network interface.</small></li>