2017-09-04 11:40:02 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2017-09-04 11:40:02 +00:00
|
|
|
*/
|
2018-12-18 10:45:06 +00:00
|
|
|
#include "history/media/history_media.h"
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
#include "history/history_item.h"
|
2018-01-14 16:02:25 +00:00
|
|
|
#include "history/view/history_view_element.h"
|
2018-01-27 13:59:24 +00:00
|
|
|
#include "history/view/history_view_cursor_state.h"
|
2017-09-04 11:40:02 +00:00
|
|
|
#include "storage/storage_shared_media.h"
|
2018-01-19 12:13:06 +00:00
|
|
|
#include "ui/text_options.h"
|
2018-10-25 13:22:44 +00:00
|
|
|
#include "styles/style_history.h"
|
2017-09-04 11:40:02 +00:00
|
|
|
|
2018-01-27 13:59:24 +00:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
using PointState = HistoryView::PointState;
|
|
|
|
using TextState = HistoryView::TextState;
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2017-09-04 11:40:02 +00:00
|
|
|
Storage::SharedMediaTypesMask HistoryMedia::sharedMediaTypes() const {
|
|
|
|
return {};
|
|
|
|
}
|
2018-01-13 12:45:11 +00:00
|
|
|
|
2019-01-03 12:36:01 +00:00
|
|
|
not_null<History*> HistoryMedia::history() const {
|
|
|
|
return _parent->history();
|
|
|
|
}
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
bool HistoryMedia::isDisplayed() const {
|
2018-01-17 16:21:01 +00:00
|
|
|
return true;
|
2018-01-13 12:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QSize HistoryMedia::countCurrentSize(int newWidth) {
|
|
|
|
return QSize(qMin(newWidth, maxWidth()), minHeight());
|
|
|
|
}
|
|
|
|
|
2018-01-19 12:13:06 +00:00
|
|
|
Text HistoryMedia::createCaption(not_null<HistoryItem*> item) const {
|
|
|
|
if (item->emptyText()) {
|
|
|
|
return Text();
|
|
|
|
}
|
|
|
|
const auto minResizeWidth = st::minPhotoSize
|
|
|
|
- st::msgPadding.left()
|
|
|
|
- st::msgPadding.right();
|
|
|
|
auto result = Text(minResizeWidth);
|
|
|
|
result.setMarkedText(
|
|
|
|
st::messageTextStyle,
|
|
|
|
item->originalText(),
|
|
|
|
Ui::ItemTextOptions(item));
|
|
|
|
if (const auto width = _parent->skipBlockWidth()) {
|
|
|
|
result.updateSkipBlock(width, _parent->skipBlockHeight());
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-01-13 12:45:11 +00:00
|
|
|
TextSelection HistoryMedia::skipSelection(TextSelection selection) const {
|
2018-01-14 16:02:25 +00:00
|
|
|
return HistoryView::UnshiftItemSelection(
|
|
|
|
selection,
|
|
|
|
fullSelectionLength());
|
2018-01-13 12:45:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TextSelection HistoryMedia::unskipSelection(TextSelection selection) const {
|
2018-01-14 16:02:25 +00:00
|
|
|
return HistoryView::ShiftItemSelection(
|
|
|
|
selection,
|
|
|
|
fullSelectionLength());
|
2018-01-13 12:45:11 +00:00
|
|
|
}
|
|
|
|
|
2018-01-27 13:59:24 +00:00
|
|
|
PointState HistoryMedia::pointState(QPoint point) const {
|
|
|
|
return QRect(0, 0, width(), height()).contains(point)
|
|
|
|
? PointState::Inside
|
|
|
|
: PointState::Outside;
|
|
|
|
}
|
|
|
|
|
|
|
|
TextState HistoryMedia::getStateGrouped(
|
2018-01-13 12:45:11 +00:00
|
|
|
const QRect &geometry,
|
|
|
|
QPoint point,
|
2018-01-27 13:59:24 +00:00
|
|
|
StateRequest request) const {
|
2018-01-13 12:45:11 +00:00
|
|
|
Unexpected("Grouping method call.");
|
|
|
|
}
|