tdesktop/Telegram/SourceFiles/ui/text/text_options.cpp

157 lines
3.3 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
*/
2020-10-10 09:15:37 +00:00
#include "ui/text/text_options.h"
2018-12-18 13:56:38 +00:00
#include "styles/style_window.h"
2020-10-10 09:15:37 +00:00
#include "styles/style_chat.h"
namespace Ui {
namespace {
TextParseOptions HistoryTextOptions = {
TextParseLinks
| TextParseMentions
| TextParseHashtags
| TextParseMultiline
| TextParseMarkdown, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
TextParseOptions HistoryBotOptions = {
TextParseLinks
| TextParseMentions
| TextParseHashtags
| TextParseBotCommands
| TextParseMultiline
| TextParseMarkdown, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
TextParseOptions HistoryServiceOptions = {
TextParseLinks
| TextParseMentions
//| TextParseMultiline
2022-01-07 03:50:06 +00:00
| TextParseHashtags, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // lang-dependent
};
TextParseOptions HistoryTextNoMonoOptions = {
TextParseLinks
| TextParseMentions
| TextParseHashtags
2022-01-07 03:50:06 +00:00
| TextParseMultiline, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
TextParseOptions HistoryBotNoMonoOptions = {
TextParseLinks
| TextParseMentions
| TextParseHashtags
| TextParseBotCommands
2022-01-07 03:50:06 +00:00
| TextParseMultiline, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
TextParseOptions TextNameOptions = {
0, // flags
4096, // maxw
1, // maxh
Qt::LayoutDirectionAuto, // lang-dependent
};
TextParseOptions TextDialogOptions = {
TextParsePlainLinks, // flags
0, // maxw is style-dependent
1, // maxh
Qt::LayoutDirectionAuto, // lang-dependent
};
TextParseOptions WebpageTitleOptions = {
2022-01-07 03:50:06 +00:00
TextParseMultiline, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
TextParseOptions WebpageDescriptionOptions = {
TextParseLinks
| TextParseMentions
| TextParseHashtags
| TextParseMultiline
| TextParseMarkdown, // flags
0, // maxw
0, // maxh
Qt::LayoutDirectionAuto, // dir
};
} // namespace
void InitTextOptions() {
HistoryServiceOptions.dir
= TextNameOptions.dir
= TextDialogOptions.dir
2020-10-10 09:15:37 +00:00
= Qt::LeftToRight;
TextDialogOptions.maxw = st::columnMaximalWidthLeft * 2;
WebpageTitleOptions.maxh = st::webPageTitleFont->height * 2;
WebpageTitleOptions.maxw
= WebpageDescriptionOptions.maxw
= st::msgMaxWidth
- st::msgPadding.left()
- st::webPageLeft
- st::msgPadding.right();
WebpageDescriptionOptions.maxh = st::webPageDescriptionFont->height * 3;
}
const TextParseOptions &ItemTextDefaultOptions() {
return HistoryTextOptions;
}
const TextParseOptions &ItemTextBotDefaultOptions() {
return HistoryBotOptions;
}
const TextParseOptions &ItemTextNoMonoOptions() {
return HistoryTextNoMonoOptions;
}
const TextParseOptions &ItemTextBotNoMonoOptions() {
return HistoryBotNoMonoOptions;
}
const TextParseOptions &ItemTextServiceOptions() {
return HistoryServiceOptions;
}
const TextParseOptions &WebpageTextTitleOptions() {
return WebpageTitleOptions;
}
2020-06-16 15:10:39 +00:00
const TextParseOptions &WebpageTextDescriptionOptions() {
return WebpageDescriptionOptions;
}
const TextParseOptions &NameTextOptions() {
return TextNameOptions;
}
const TextParseOptions &DialogTextOptions() {
return TextDialogOptions;
}
} // namespace Ui