Pass correct context to setMarkedText.

This commit is contained in:
John Preston 2020-06-24 12:22:27 +04:00
parent e7b8a52278
commit 99bf61ac8c
3 changed files with 24 additions and 4 deletions

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/view/history_view_cursor_state.h"
#include "history/view/media/history_view_media_common.h"
#include "ui/text_options.h"
#include "core/ui_integration.h"
#include "data/data_session.h"
#include "data/data_game.h"
#include "data/data_media_types.h"
@ -32,10 +33,14 @@ Game::Game(
, _title(st::msgMinWidth - st::webPageLeft)
, _description(st::msgMinWidth - st::webPageLeft) {
if (!consumed.text.isEmpty()) {
const auto context = Core::UiIntegration::Context{
.session = &history()->session()
};
_description.setMarkedText(
st::webPageDescriptionStyle,
consumed,
Ui::ItemTextOptions(parent->data()));
Ui::ItemTextOptions(parent->data()),
context);
}
history()->owner().registerGameView(_data, _parent);
}
@ -413,10 +418,14 @@ void Game::parentTextUpdated() {
if (const auto media = _parent->data()->media()) {
const auto consumed = media->consumedMessageText();
if (!consumed.text.isEmpty()) {
const auto context = Core::UiIntegration::Context{
.session = &history()->session()
};
_description.setMarkedText(
st::webPageDescriptionStyle,
consumed,
Ui::ItemTextOptions(_parent->data()));
Ui::ItemTextOptions(_parent->data()),
context);
} else {
_description = Ui::Text::String(st::msgMinWidth - st::webPageLeft);
}

View file

@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
#include "history/view/media/history_view_media.h"
#include "history/history.h"
#include "history/history_item.h"
#include "history/view/history_view_element.h"
#include "history/view/history_view_cursor_state.h"
@ -14,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "storage/storage_shared_media.h"
#include "data/data_document.h"
#include "ui/text_options.h"
#include "core/ui_integration.h"
#include "styles/style_history.h"
namespace HistoryView {
@ -137,6 +139,9 @@ Ui::Text::String Media::createCaption(
- st::msgPadding.left()
- st::msgPadding.right();
auto result = Ui::Text::String(minResizeWidth);
const auto context = Core::UiIntegration::Context{
.session = &history()->session()
};
result.setMarkedText(
st::messageTextStyle,
(timestampLinksDuration
@ -145,7 +150,8 @@ Ui::Text::String Media::createCaption(
timestampLinksDuration,
timestampLinkBase)
: item->originalText()),
Ui::ItemTextOptions(item));
Ui::ItemTextOptions(item),
context);
if (const auto width = _parent->skipBlockWidth()) {
result.updateSkipBlock(width, _parent->skipBlockHeight());
}

View file

@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/application.h"
#include "core/file_utilities.h"
#include "core/mime_type.h"
#include "core/ui_integration.h"
#include "ui/widgets/popup_menu.h"
#include "ui/widgets/buttons.h"
#include "ui/image/image.h"
@ -1868,10 +1869,14 @@ void OverlayWidget::refreshCaption(HistoryItem *item) {
const auto base = duration
? DocumentTimestampLinkBase(_document, item->fullId())
: QString();
const auto context = Core::UiIntegration::Context{
.session = &item->history()->session()
};
_caption.setMarkedText(
st::mediaviewCaptionStyle,
AddTimestampLinks(caption, duration, base),
Ui::ItemTextOptions(item));
Ui::ItemTextOptions(item),
context);
}
void OverlayWidget::refreshGroupThumbs() {