init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
97
Telegram/lib_ui/ui/text/text_extended_data.cpp
Normal file
97
Telegram/lib_ui/ui/text/text_extended_data.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
// This file is part of Desktop App Toolkit,
|
||||
// a set of libraries for developing nice desktop applications.
|
||||
//
|
||||
// For license and copyright information please follow this link:
|
||||
// https://github.com/desktop-app/legal/blob/master/LEGAL
|
||||
//
|
||||
#include "ui/text/text_extended_data.h"
|
||||
|
||||
#include "ui/text/text.h"
|
||||
#include "ui/integration.h"
|
||||
|
||||
namespace Ui::Text {
|
||||
|
||||
SpoilerClickHandler::SpoilerClickHandler(
|
||||
not_null<String*> text,
|
||||
Fn<bool(const ClickContext&)> filter)
|
||||
: _text(text)
|
||||
, _filter(std::move(filter)) {
|
||||
}
|
||||
|
||||
not_null<String*> SpoilerClickHandler::text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
void SpoilerClickHandler::setText(not_null<String*> text) {
|
||||
_text = text;
|
||||
}
|
||||
|
||||
void SpoilerClickHandler::onClick(ClickContext context) const {
|
||||
if (_filter && !_filter(context)) {
|
||||
return;
|
||||
}
|
||||
_text->setSpoilerRevealed(true, anim::type::normal);
|
||||
}
|
||||
|
||||
PreClickHandler::PreClickHandler(
|
||||
not_null<String*> text,
|
||||
uint16 offset,
|
||||
uint16 length)
|
||||
: _text(text)
|
||||
, _offset(offset)
|
||||
, _length(length) {
|
||||
}
|
||||
|
||||
not_null<String*> PreClickHandler::text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
void PreClickHandler::setText(not_null<String*> text) {
|
||||
_text = text;
|
||||
}
|
||||
|
||||
void PreClickHandler::onClick(ClickContext context) const {
|
||||
if (context.button != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
const auto till = uint16(_offset + _length);
|
||||
auto text = _text->toTextForMimeData({ _offset, till });
|
||||
if (text.empty()) {
|
||||
return;
|
||||
} else if (!text.rich.text.endsWith('\n')) {
|
||||
text.rich.text.append('\n');
|
||||
}
|
||||
if (!text.expanded.endsWith('\n')) {
|
||||
text.expanded.append('\n');
|
||||
}
|
||||
if (Integration::Instance().copyPreOnClick(context.other)) {
|
||||
TextUtilities::SetClipboardText(std::move(text));
|
||||
}
|
||||
}
|
||||
|
||||
BlockquoteClickHandler::BlockquoteClickHandler(
|
||||
not_null<String*> text,
|
||||
int quoteIndex)
|
||||
: _text(text)
|
||||
, _quoteIndex(quoteIndex) {
|
||||
}
|
||||
|
||||
not_null<String*> BlockquoteClickHandler::text() const {
|
||||
return _text;
|
||||
}
|
||||
|
||||
void BlockquoteClickHandler::setText(not_null<String*> text) {
|
||||
_text = text;
|
||||
}
|
||||
|
||||
void BlockquoteClickHandler::onClick(ClickContext context) const {
|
||||
if (context.button != Qt::LeftButton) {
|
||||
return;
|
||||
}
|
||||
_text->setBlockquoteExpanded(
|
||||
_quoteIndex,
|
||||
!_text->blockquoteExpanded(_quoteIndex));
|
||||
}
|
||||
|
||||
} // namespace Ui::Text
|
||||
|
||||
Reference in New Issue
Block a user