Skip to content

feat(providers): Add QWeather weather provider, ip.sb location provider and QWeather GeoAPI city search - #151

Merged
romanlefler merged 2 commits into
romanlefler:developmentfrom
chenxv399:feat/CN-Support
Aug 17, 2026
Merged

feat(providers): Add QWeather weather provider, ip.sb location provider and QWeather GeoAPI city search#151
romanlefler merged 2 commits into
romanlefler:developmentfrom
chenxv399:feat/CN-Support

Conversation

@chenxv399

Copy link
Copy Markdown
Contributor

Implements the feature requested in #150. Adds providers that work better for users in China, with no refactoring of existing code and no new dependencies.

New weather provider: QWeather

  • New provider src/providers/qweather.ts (index 3), registered in createProvider.
  • Authentication via X-QW-Api-Key request header; since QWeather API hosts are per-user (*.qweatherapi.com), a new api-hosts setting (a{ss}, mirroring api-keys) stores the host.
  • Fetches current / daily(7) / hourly(28) weather in parallel; converts QWeather's metric values to the internal imperial units; maps QWeather weather codes to the existing icon set; handles night-time variants (codes 150–153) and sunrise/sunset countdowns like the other providers.
  • Non-2xx responses and business error codes (code != "200") are surfaced as errors.

New location provider: ip.sb

  • Added as MyLocationProvider.IpSb (enum 5) in myLocation.ts; free, no API key needed.
  • Fixed a pre-existing range guard in config.getMyLocationProvider() which silently reset Disable(3) and Ipapi(4) to ipinfo.

City search auto-switch

  • When QWeather is selected and its key/host are configured, location search uses QWeather GeoAPI city lookup; otherwise it falls back to Nominatim as before.

Preferences UI

  • New "API Host" entry row, shown/enabled only for providers that require a host.
  • ip.sb added to the My Location provider list (online providers listed first).
  • API key online validation now only runs for OpenWeatherMap, so saving a QWeather key no longer triggers a false OWM warning.

Supporting changes

  • LibSoup.fetchJson gained an optional headers parameter (backward compatible).
  • config.ts: getApiHosts() / onApiHostsChanged() mirroring the existing api-keys accessors.
  • gschema: weather-provider enum +qweather(3), my-loc-provider enum +ip.sb(5), new api-hosts key.

Notes

  • New UI strings are in English only; translations can follow the usual Crowdin workflow.
  • Tested with a nested GNOME Shell (./debug.sh); tsc clean, schema compiles with glib-compile-schemas --strict.

# Conflicts:
#	src/preferences/generalPage.ts
#	src/providers/provider.ts
@romanlefler

Copy link
Copy Markdown
Owner

I like the idea and the implementation. There are a couple of changes I am going to make before I directly merge this PR into development; mainly an attribution issue and the fact that the weather provider is directly tied to the location search provider. You should see it merged soon, thank you!

@romanlefler romanlefler self-assigned this Aug 17, 2026
@romanlefler

Copy link
Copy Markdown
Owner

Could you (on this repo):

  1. Pull to get updates
  2. Switch to the cn-services branch.
  3. Confirm with your QWeather account that both Weather and Search work. You will have to switch the search provider in locations now. Could you also check that the Open-Meteo search provider works in China?

If there's no issues I'll merge to development soon! Thank you!

@chenxv399

Copy link
Copy Markdown
Contributor Author

I've tested the cn-services branch with my QWeather account:

  • QWeather weather provider: works after configuring the API key and host ✓
  • QWeather city search (search provider set to QWeather in Locations): works ✓
  • Open-Meteo search provider: works from China ✓

No issues found on my end. Thanks for the quick turnaround!

@romanlefler
romanlefler merged commit b412d6a into romanlefler:development Aug 17, 2026
1 check passed
@romanlefler

Copy link
Copy Markdown
Owner

Thank you! It was a large feature commit so as you can tell I made a couple changes, and I really appreciate this PR and your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants