mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
parent
a174119877
commit
9db2502cd0
3 changed files with 14 additions and 13 deletions
|
@ -123,9 +123,9 @@ constexpr auto kLinkProtocols = {
|
||||||
void EditLinkBox(
|
void EditLinkBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
const QString &startText,
|
const TextWithTags &startText,
|
||||||
const QString &startLink,
|
const QString &startLink,
|
||||||
Fn<void(QString, QString)> callback,
|
Fn<void(TextWithTags, QString)> callback,
|
||||||
const style::InputField *fieldStyle,
|
const style::InputField *fieldStyle,
|
||||||
Fn<QString(QString)> validate) {
|
Fn<QString(QString)> validate) {
|
||||||
Expects(callback != nullptr);
|
Expects(callback != nullptr);
|
||||||
|
@ -137,6 +137,7 @@ void EditLinkBox(
|
||||||
object_ptr<Ui::InputField>(
|
object_ptr<Ui::InputField>(
|
||||||
content,
|
content,
|
||||||
fieldSt,
|
fieldSt,
|
||||||
|
Ui::InputField::Mode::SingleLine,
|
||||||
tr::lng_formatting_link_text(),
|
tr::lng_formatting_link_text(),
|
||||||
startText),
|
startText),
|
||||||
st::markdownLinkFieldPadding);
|
st::markdownLinkFieldPadding);
|
||||||
|
@ -181,9 +182,9 @@ void EditLinkBox(
|
||||||
url->move(placeholder->pos());
|
url->move(placeholder->pos());
|
||||||
|
|
||||||
const auto submit = [=] {
|
const auto submit = [=] {
|
||||||
const auto linkText = text->getLastText();
|
const auto linkText = text->getTextWithTags();
|
||||||
const auto linkUrl = validate(url->getLastText());
|
const auto linkUrl = validate(url->getLastText());
|
||||||
if (linkText.isEmpty()) {
|
if (linkText.text.isEmpty()) {
|
||||||
text->showError();
|
text->showError();
|
||||||
return;
|
return;
|
||||||
} else if (linkUrl.isEmpty()) {
|
} else if (linkUrl.isEmpty()) {
|
||||||
|
@ -222,7 +223,7 @@ void EditLinkBox(
|
||||||
box->setWidth(st::boxWidth);
|
box->setWidth(st::boxWidth);
|
||||||
|
|
||||||
box->setFocusCallback([=] {
|
box->setFocusCallback([=] {
|
||||||
if (startText.isEmpty()) {
|
if (startText.text.isEmpty()) {
|
||||||
text->setFocusFast();
|
text->setFocusFast();
|
||||||
} else {
|
} else {
|
||||||
if (!url->empty()) {
|
if (!url->empty()) {
|
||||||
|
@ -383,7 +384,7 @@ bool EditTextChanged(
|
||||||
|
|
||||||
Fn<bool(
|
Fn<bool(
|
||||||
Ui::InputField::EditLinkSelection selection,
|
Ui::InputField::EditLinkSelection selection,
|
||||||
QString text,
|
TextWithTags text,
|
||||||
QString link,
|
QString link,
|
||||||
EditLinkAction action)> DefaultEditLinkCallback(
|
EditLinkAction action)> DefaultEditLinkCallback(
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
|
@ -392,14 +393,14 @@ Fn<bool(
|
||||||
const auto weak = Ui::MakeWeak(field);
|
const auto weak = Ui::MakeWeak(field);
|
||||||
return [=](
|
return [=](
|
||||||
EditLinkSelection selection,
|
EditLinkSelection selection,
|
||||||
QString text,
|
TextWithTags text,
|
||||||
QString link,
|
QString link,
|
||||||
EditLinkAction action) {
|
EditLinkAction action) {
|
||||||
if (action == EditLinkAction::Check) {
|
if (action == EditLinkAction::Check) {
|
||||||
return Ui::InputField::IsValidMarkdownLink(link)
|
return Ui::InputField::IsValidMarkdownLink(link)
|
||||||
&& !TextUtilities::IsMentionLink(link);
|
&& !TextUtilities::IsMentionLink(link);
|
||||||
}
|
}
|
||||||
auto callback = [=](const QString &text, const QString &link) {
|
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +471,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
||||||
|
|
||||||
[[nodiscard]] Fn<bool(
|
[[nodiscard]] Fn<bool(
|
||||||
Ui::InputField::EditLinkSelection selection,
|
Ui::InputField::EditLinkSelection selection,
|
||||||
QString text,
|
TextWithTags text,
|
||||||
QString link,
|
QString link,
|
||||||
EditLinkAction action)> FactcheckEditLinkCallback(
|
EditLinkAction action)> FactcheckEditLinkCallback(
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
|
@ -478,7 +479,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
||||||
const auto weak = Ui::MakeWeak(field);
|
const auto weak = Ui::MakeWeak(field);
|
||||||
return [=](
|
return [=](
|
||||||
EditLinkSelection selection,
|
EditLinkSelection selection,
|
||||||
QString text,
|
TextWithTags text,
|
||||||
QString link,
|
QString link,
|
||||||
EditLinkAction action) {
|
EditLinkAction action) {
|
||||||
const auto validate = [=](QString url) {
|
const auto validate = [=](QString url) {
|
||||||
|
@ -493,7 +494,7 @@ void InitMessageFieldHandlers(MessageFieldHandlersArgs &&args) {
|
||||||
if (action == EditLinkAction::Check) {
|
if (action == EditLinkAction::Check) {
|
||||||
return IsGoodFactcheckUrl(link);
|
return IsGoodFactcheckUrl(link);
|
||||||
}
|
}
|
||||||
auto callback = [=](const QString &text, const QString &link) {
|
auto callback = [=](const TextWithTags &text, const QString &link) {
|
||||||
if (const auto strong = weak.data()) {
|
if (const auto strong = weak.data()) {
|
||||||
strong->commitMarkdownLinkEdit(selection, text, link);
|
strong->commitMarkdownLinkEdit(selection, text, link);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class Show;
|
||||||
|
|
||||||
Fn<bool(
|
Fn<bool(
|
||||||
Ui::InputField::EditLinkSelection selection,
|
Ui::InputField::EditLinkSelection selection,
|
||||||
QString text,
|
TextWithTags text,
|
||||||
QString link,
|
QString link,
|
||||||
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
|
Ui::InputField::EditLinkAction action)> DefaultEditLinkCallback(
|
||||||
std::shared_ptr<Main::SessionShow> show,
|
std::shared_ptr<Main::SessionShow> show,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e052a8bff00c24d19c12e61b0adeb5fdf18770f0
|
Subproject commit 5fbb38cf872f2132b1ad0a564083c498e6cc6f14
|
Loading…
Add table
Reference in a new issue