Add country flags for external IP#23731
Add country flags for external IP#23731devIlluSioN wants to merge 3 commits intoqbittorrent:masterfrom
Conversation
|
I will update the code format error today |
|
Updated ! |
|
Can we rerun the workflow, or do I need to do other things ? @glassez 🤗 |
Display country flags next to external IPv4 and IPv6 addresses in the webui status bar, using the same method as peer flags. The flag is shown only when peer country resolution is enabled in preferences, consistent with peer flag display behavior.
|
Sorry @glassez about the workflow that didn’t pass. |
|
Hi Could you clarify the next steps for this PR? Specifically: Thanks in advance for the guidance! |
Requires relevant team review & approval.
qBittorrent 5.2.0 Beta 2/RC/General Release. |
stalkerok
left a comment
There was a problem hiding this comment.
The flag is displayed correctly with both ipv4 and ipv6.
|
Desktop app UI doesn't have such a feature, am I right? |
Yes |
The external IP can be shown in the desktop ui but you have to enable it. It isn't enabled by default. It would be nice if the flag could be added to the desktop ui too. |
|
Hello everyone, thanks for your reviews on my PR. I have two questions: First: for the changes requested by @glassez, should I amend my last commit or create a new refactor commit? Second: for the flag on desktop, would it be better if I open an additional PR? |
You can add new commits. Either way all they will be squashed into single one while merging the PR. |
As you wish. Personally, I don't even insist that you do it at all, if you suddenly don't want to. |
|
Everything is done |
|
Sorry, I forgot to run the linter. |
|
In the GUI, there is an unnecessary space before the flags and after the ipv4 address. |
|
@stalkerok like this is ok for you ? |
|
Updated ! |
|
When hovering over the flag in the GUI, N/A appears briefly and then disappears. |
|
I won’t have time to look at this today. |
|
No, not anytime soon, there are no deadlines. |
| countryCode = geoIP->lookup(hostAddr); | ||
| if (!countryCode.isEmpty()) | ||
| { | ||
| countryCode = countryCode.toLower(); |
There was a problem hiding this comment.
When hovering over the flag in the GUI, N/A appears briefly and then disappears.
The "N/A" part is because of this.
The duration of the tooltip appears to be affected by Refresh interval in advanced settings or when some item in the toolbar is updated e.g. DHT nodes.

Motivation
Currently, the WebUI and DesktopGUI displays the external IP address in the status bar, but unlike peer IPs, it doesn't show the associated country flag. This feature request adds visual consistency by displaying country flags for external IPs using the same method as peer IPs. Very cool when you use a VPN
What it does
This PR adds country flag display for external IP addresses (both IPv4 and IPv6) in the status bar. The flags are shown next to the IP addresses, matching the behavior already implemented for peer IPs in the peers table.
Changes
Backend (C++ - WebUI):
src/webui/api/synccontroller.cpp:QHostAddressincludegetTransferInfo()to resolve country codes usingGeoIPManagerwhen peer country resolution is enabledFrontend (JavaScript - WebUI):
src/webui/www/private/scripts/client.js:processServerState()to display flags for external IPs<span>elements withflagsclass and background images pointing to flag SVG filesCSS (WebUI):
src/webui/www/private/css/style.css:span.flagsstyle for status bar (matching the style used in dynamic tables)Desktop GUI:
src/gui/statusbar.h:QLabel *m_lastExternalIPsLblwithQWidget *m_externalIPsContainerto support a richer layoutsrc/gui/statusbar.cpp:QHostAddressandGeoIPManagerincludesQLabelwith aQWidgetcontainer usingQHBoxLayoutfor flexible contentupdateExternalAddressesLabel()now dynamically builds the IP display: clears existing widgets, adds a prefix label, then for each IP adds an optional flag icon (UIThemeManager::getFlagIcon()) with country name tooltip followed by the IP addressPreferences::resolvePeerCountries()(same as peers)Behavior
Testing
To test this feature:
Screenshots
WebUI :

(Ip Hidden)
Desktop GUI (Mac) :

(Ip Hidden)
Related
This feature uses the same GeoIP resolution system and flag display method as the existing peer country feature, ensuring consistency across the application.