Parse markup in Ui::Text::String::setMarkedText by default.
This commit is contained in:
parent
bd7c4ee06d
commit
5214f96bba
3 changed files with 16 additions and 7 deletions
|
|
@ -147,14 +147,21 @@ bool IsBad(QChar ch) {
|
||||||
} // namespace Text
|
} // namespace Text
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
const TextParseOptions _defaultOptions = {
|
const TextParseOptions kDefaultTextOptions = {
|
||||||
TextParseLinks | TextParseMultiline, // flags
|
TextParseLinks | TextParseMultiline, // flags
|
||||||
0, // maxw
|
0, // maxw
|
||||||
0, // maxh
|
0, // maxh
|
||||||
Qt::LayoutDirectionAuto, // dir
|
Qt::LayoutDirectionAuto, // dir
|
||||||
};
|
};
|
||||||
|
|
||||||
const TextParseOptions _textPlainOptions = {
|
const TextParseOptions kMarkupTextOptions = {
|
||||||
|
TextParseLinks | TextParseMultiline | TextParseMarkdown, // flags
|
||||||
|
0, // maxw
|
||||||
|
0, // maxh
|
||||||
|
Qt::LayoutDirectionAuto, // dir
|
||||||
|
};
|
||||||
|
|
||||||
|
const TextParseOptions kPlainTextOptions = {
|
||||||
TextParseMultiline, // flags
|
TextParseMultiline, // flags
|
||||||
0, // maxw
|
0, // maxw
|
||||||
0, // maxh
|
0, // maxh
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,9 @@ struct TextParseOptions {
|
||||||
int32 maxh;
|
int32 maxh;
|
||||||
Qt::LayoutDirection dir;
|
Qt::LayoutDirection dir;
|
||||||
};
|
};
|
||||||
extern const TextParseOptions _defaultOptions, _textPlainOptions;
|
extern const TextParseOptions kDefaultTextOptions;
|
||||||
|
extern const TextParseOptions kMarkupTextOptions;
|
||||||
|
extern const TextParseOptions kPlainTextOptions;
|
||||||
|
|
||||||
enum class TextSelectType {
|
enum class TextSelectType {
|
||||||
Letters = 0x01,
|
Letters = 0x01,
|
||||||
|
|
@ -102,7 +104,7 @@ public:
|
||||||
String(
|
String(
|
||||||
const style::TextStyle &st,
|
const style::TextStyle &st,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const TextParseOptions &options = _defaultOptions,
|
const TextParseOptions &options = kDefaultTextOptions,
|
||||||
int32 minResizeWidth = QFIXED_MAX);
|
int32 minResizeWidth = QFIXED_MAX);
|
||||||
String(const String &other) = default;
|
String(const String &other) = default;
|
||||||
String(String &&other) = default;
|
String(String &&other) = default;
|
||||||
|
|
@ -113,8 +115,8 @@ public:
|
||||||
int countWidth(int width, bool breakEverywhere = false) const;
|
int countWidth(int width, bool breakEverywhere = false) const;
|
||||||
int countHeight(int width, bool breakEverywhere = false) const;
|
int countHeight(int width, bool breakEverywhere = false) const;
|
||||||
void countLineWidths(int width, QVector<int> *lineWidths, bool breakEverywhere = false) const;
|
void countLineWidths(int width, QVector<int> *lineWidths, bool breakEverywhere = false) const;
|
||||||
void setText(const style::TextStyle &st, const QString &text, const TextParseOptions &options = _defaultOptions);
|
void setText(const style::TextStyle &st, const QString &text, const TextParseOptions &options = kDefaultTextOptions);
|
||||||
void setMarkedText(const style::TextStyle &st, const TextWithEntities &textWithEntities, const TextParseOptions &options = _defaultOptions, const std::any &context = {});
|
void setMarkedText(const style::TextStyle &st, const TextWithEntities &textWithEntities, const TextParseOptions &options = kMarkupTextOptions, const std::any &context = {});
|
||||||
|
|
||||||
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
void setLink(uint16 lnkIndex, const ClickHandlerPtr &lnk);
|
||||||
bool hasLinks() const;
|
bool hasLinks() const;
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
|
||||||
|
|
||||||
_point = m;
|
_point = m;
|
||||||
_st = st;
|
_st = st;
|
||||||
_text = Text::String(_st->textStyle, text, _textPlainOptions, _st->widthMax);
|
_text = Text::String(_st->textStyle, text, kPlainTextOptions, _st->widthMax);
|
||||||
|
|
||||||
_useTransparency = Platform::TranslucentWindowsSupported(_point);
|
_useTransparency = Platform::TranslucentWindowsSupported(_point);
|
||||||
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
setAttribute(Qt::WA_OpaquePaintEvent, !_useTransparency);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue