tdesktop/Telegram/SourceFiles/history/history_location_manager.cpp

47 lines
1.2 KiB
C++
Raw Normal View History

/*
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
*/
#include "history/history_location_manager.h"
#include "mainwidget.h"
2017-04-13 08:27:10 +00:00
#include "lang/lang_keys.h"
#include "ui/image/image.h"
#include "data/data_file_origin.h"
2017-03-04 10:23:56 +00:00
#include "platform/platform_specific.h"
2019-09-04 07:19:15 +00:00
#include <QtGui/QDesktopServices>
namespace {
constexpr auto kCoordPrecision = 8;
constexpr auto kMaxHttpRedirects = 5;
} // namespace
QString LocationClickHandler::copyToClipboardText() const {
return _text;
}
QString LocationClickHandler::copyToClipboardContextItemText() const {
2019-06-19 15:09:03 +00:00
return tr::lng_context_copy_link(tr::now);
}
void LocationClickHandler::onClick(ClickContext context) const {
2019-06-21 12:27:46 +00:00
if (!psLaunchMaps(_point)) {
QDesktopServices::openUrl(_text);
}
}
void LocationClickHandler::setup() {
2019-06-21 12:27:46 +00:00
_text = Url(_point);
2019-06-14 16:04:45 +00:00
}
2019-06-21 12:27:46 +00:00
QString LocationClickHandler::Url(const Data::LocationPoint &point) {
const auto latlon = point.latAsString() + ',' + point.lonAsString();
2019-06-14 16:04:45 +00:00
return qsl("https://maps.google.com/maps?q=") + latlon + qsl("&ll=") + latlon + qsl("&z=16");
}