2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-23 10:47:11 +00:00
tdesktop/Telegram/SourceFiles/core/current_geo_location.h

61 lines
1.3 KiB
C
Raw Permalink Normal View History

2024-07-04 12:18:30 +04:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#pragma once
namespace Core {
enum class GeoLocationAccuracy : uchar {
Exact,
Country,
Failed,
};
struct GeoLocation {
QPointF point;
QRectF bounds;
GeoLocationAccuracy accuracy = GeoLocationAccuracy::Failed;
[[nodiscard]] bool exact() const {
return accuracy == GeoLocationAccuracy::Exact;
}
[[nodiscard]] bool country() const {
return accuracy == GeoLocationAccuracy::Country;
}
[[nodiscard]] bool failed() const {
return accuracy == GeoLocationAccuracy::Failed;
}
explicit operator bool() const {
return !failed();
}
2024-07-07 21:01:26 +04:00
};
2024-07-11 18:15:17 +02:00
[[nodiscard]] bool AreTheSame(const GeoLocation &a, const GeoLocation &b);
2024-07-07 21:01:26 +04:00
struct GeoAddress {
QString name;
[[nodiscard]] bool empty() const {
return name.isEmpty();
}
explicit operator bool() const {
return !empty();
}
2024-07-04 12:18:30 +04:00
};
[[nodiscard]] GeoLocation ResolveCurrentCountryLocation();
void ResolveCurrentGeoLocation(Fn<void(GeoLocation)> callback);
2024-07-07 21:01:26 +04:00
void ResolveLocationAddress(
const GeoLocation &location,
2024-07-11 16:31:33 +02:00
const QString &language,
2024-07-07 21:01:26 +04:00
const QString &token,
Fn<void(GeoAddress)> callback);
2024-07-04 12:18:30 +04:00
} // namespace Core