2018-12-18 10:45:06 +00: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
|
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
#include "history/view/media/history_view_media.h"
|
2020-05-28 13:05:44 +00:00
|
|
|
#include "data/data_location.h"
|
2018-12-18 10:45:06 +00:00
|
|
|
|
2019-06-21 12:27:46 +00:00
|
|
|
namespace Data {
|
2020-05-28 13:05:44 +00:00
|
|
|
class CloudImage;
|
|
|
|
class CloudImageView;
|
2019-06-21 12:27:46 +00:00
|
|
|
} // namespace Data
|
2018-12-18 10:45:06 +00:00
|
|
|
|
2019-08-02 13:21:09 +00:00
|
|
|
namespace HistoryView {
|
|
|
|
|
|
|
|
class Location : public Media {
|
2018-12-18 10:45:06 +00:00
|
|
|
public:
|
2019-08-02 13:21:09 +00:00
|
|
|
Location(
|
2018-12-18 10:45:06 +00:00
|
|
|
not_null<Element*> parent,
|
2020-05-28 13:05:44 +00:00
|
|
|
not_null<Data::CloudImage*> data,
|
|
|
|
Data::LocationPoint point,
|
2018-12-18 10:45:06 +00:00
|
|
|
const QString &title = QString(),
|
|
|
|
const QString &description = QString());
|
2020-05-29 14:08:18 +00:00
|
|
|
~Location();
|
2018-12-18 10:45:06 +00:00
|
|
|
|
2019-02-19 06:57:53 +00:00
|
|
|
void draw(Painter &p, const QRect &r, TextSelection selection, crl::time ms) const override;
|
2018-12-18 10:45:06 +00:00
|
|
|
TextState textState(QPoint point, StateRequest request) const override;
|
|
|
|
|
|
|
|
[[nodiscard]] TextSelection adjustSelection(
|
|
|
|
TextSelection selection,
|
|
|
|
TextSelectType type) const override;
|
|
|
|
uint16 fullSelectionLength() const override {
|
|
|
|
return _title.length() + _description.length();
|
|
|
|
}
|
|
|
|
bool hasTextForCopy() const override {
|
|
|
|
return !_title.isEmpty() || !_description.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool toggleSelectionByHandlerClick(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _link;
|
|
|
|
}
|
|
|
|
bool dragItemByHandler(const ClickHandlerPtr &p) const override {
|
|
|
|
return p == _link;
|
|
|
|
}
|
|
|
|
|
2019-04-08 15:10:06 +00:00
|
|
|
TextForMimeData selectedText(TextSelection selection) const override;
|
2018-12-18 10:45:06 +00:00
|
|
|
|
|
|
|
bool needsBubble() const override;
|
|
|
|
bool customInfoLayout() const override {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool skipBubbleTail() const override {
|
2020-09-03 07:19:02 +00:00
|
|
|
return isRoundedInBubbleBottom();
|
2018-12-18 10:45:06 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 13:26:06 +00:00
|
|
|
void unloadHeavyPart() override;
|
|
|
|
bool hasHeavyPart() const override;
|
2020-05-28 13:05:44 +00:00
|
|
|
|
2018-12-18 10:45:06 +00:00
|
|
|
private:
|
2020-05-28 13:05:44 +00:00
|
|
|
void ensureMediaCreated() const;
|
|
|
|
|
2018-12-18 10:45:06 +00:00
|
|
|
QSize countOptimalSize() override;
|
|
|
|
QSize countCurrentSize(int newWidth) override;
|
|
|
|
|
|
|
|
TextSelection toDescriptionSelection(TextSelection selection) const;
|
|
|
|
TextSelection fromDescriptionSelection(TextSelection selection) const;
|
|
|
|
|
2020-05-28 13:05:44 +00:00
|
|
|
const not_null<Data::CloudImage*> _data;
|
|
|
|
mutable std::shared_ptr<Data::CloudImageView> _media;
|
2019-06-12 13:26:04 +00:00
|
|
|
Ui::Text::String _title, _description;
|
2018-12-18 10:45:06 +00:00
|
|
|
ClickHandlerPtr _link;
|
|
|
|
|
|
|
|
int fullWidth() const;
|
|
|
|
int fullHeight() const;
|
|
|
|
|
|
|
|
};
|
2019-08-02 13:21:09 +00:00
|
|
|
|
|
|
|
} // namespace HistoryView
|