2016-09-27 16:37:18 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 13:23:14 +03:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-09-27 16:37:18 +03:00
|
|
|
|
2018-01-03 13:23:14 +03:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-09-27 16:37:18 +03:00
|
|
|
*/
|
|
|
|
#include "history/history_location_manager.h"
|
|
|
|
|
|
|
|
#include "mainwidget.h"
|
2017-04-13 11:27:10 +03:00
|
|
|
#include "lang/lang_keys.h"
|
2018-10-23 13:44:42 +04:00
|
|
|
#include "ui/image/image.h"
|
2019-01-04 15:09:48 +04:00
|
|
|
#include "data/data_file_origin.h"
|
2017-03-04 13:23:56 +03:00
|
|
|
#include "platform/platform_specific.h"
|
2016-09-27 16:37:18 +03:00
|
|
|
|
2017-02-03 13:17:40 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
constexpr auto kCoordPrecision = 8;
|
2017-03-06 11:08:59 +03:00
|
|
|
constexpr auto kMaxHttpRedirects = 5;
|
2017-02-03 13:17:40 +03:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2018-01-25 13:10:52 +03:00
|
|
|
QString LocationClickHandler::copyToClipboardText() const {
|
|
|
|
return _text;
|
|
|
|
}
|
|
|
|
|
2016-09-27 16:37:18 +03:00
|
|
|
QString LocationClickHandler::copyToClipboardContextItemText() const {
|
2019-06-19 17:09:03 +02:00
|
|
|
return tr::lng_context_copy_link(tr::now);
|
2016-09-27 16:37:18 +03:00
|
|
|
}
|
|
|
|
|
2018-07-09 21:13:48 +03:00
|
|
|
void LocationClickHandler::onClick(ClickContext context) const {
|
2019-06-21 14:27:46 +02:00
|
|
|
if (!psLaunchMaps(_point)) {
|
2016-09-27 16:37:18 +03:00
|
|
|
QDesktopServices::openUrl(_text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocationClickHandler::setup() {
|
2019-06-21 14:27:46 +02:00
|
|
|
_text = Url(_point);
|
2019-06-14 18:04:45 +02:00
|
|
|
}
|
|
|
|
|
2019-06-21 14:27:46 +02:00
|
|
|
QString LocationClickHandler::Url(const Data::LocationPoint &point) {
|
|
|
|
const auto latlon = point.latAsString() + ',' + point.lonAsString();
|
2019-06-14 18:04:45 +02:00
|
|
|
return qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16");
|
2016-09-27 16:37:18 +03:00
|
|
|
}
|