mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Use MaskedInputField for URL input.
This commit is contained in:
parent
c32f2e71e8
commit
c535a7c564
1 changed files with 23 additions and 6 deletions
|
@ -150,13 +150,26 @@ void EditLinkBox::prepare() {
|
||||||
session);
|
session);
|
||||||
InitSpellchecker(_controller, text);
|
InitSpellchecker(_controller, text);
|
||||||
|
|
||||||
const auto url = content->add(
|
const auto placeholder = content->add(
|
||||||
object_ptr<Ui::InputField>(
|
object_ptr<Ui::RpWidget>(content),
|
||||||
|
st::markdownLinkFieldPadding);
|
||||||
|
placeholder->setAttribute(Qt::WA_TransparentForMouseEvents);
|
||||||
|
const auto url = Ui::AttachParentChild(
|
||||||
|
content,
|
||||||
|
object_ptr<Ui::MaskedInputField>(
|
||||||
content,
|
content,
|
||||||
st::defaultInputField,
|
st::defaultInputField,
|
||||||
tr::lng_formatting_link_url(),
|
tr::lng_formatting_link_url(),
|
||||||
_startLink.trimmed()),
|
_startLink.trimmed()));
|
||||||
st::markdownLinkFieldPadding);
|
url->heightValue(
|
||||||
|
) | rpl::start_with_next([placeholder](int height) {
|
||||||
|
placeholder->resize(placeholder->width(), height);
|
||||||
|
}, placeholder->lifetime());
|
||||||
|
placeholder->widthValue(
|
||||||
|
) | rpl::start_with_next([=](int width) {
|
||||||
|
url->resize(width, url->height());
|
||||||
|
}, placeholder->lifetime());
|
||||||
|
url->move(placeholder->pos());
|
||||||
|
|
||||||
const auto submit = [=] {
|
const auto submit = [=] {
|
||||||
const auto linkText = text->getLastText();
|
const auto linkText = text->getLastText();
|
||||||
|
@ -178,7 +191,7 @@ void EditLinkBox::prepare() {
|
||||||
connect(text, &Ui::InputField::submitted, [=] {
|
connect(text, &Ui::InputField::submitted, [=] {
|
||||||
url->setFocusFast();
|
url->setFocusFast();
|
||||||
});
|
});
|
||||||
connect(url, &Ui::InputField::submitted, [=] {
|
connect(url, &Ui::MaskedInputField::submitted, [=] {
|
||||||
if (text->getLastText().isEmpty()) {
|
if (text->getLastText().isEmpty()) {
|
||||||
text->setFocusFast();
|
text->setFocusFast();
|
||||||
} else {
|
} else {
|
||||||
|
@ -198,7 +211,11 @@ void EditLinkBox::prepare() {
|
||||||
setDimensions(st::boxWidth, content->height());
|
setDimensions(st::boxWidth, content->height());
|
||||||
|
|
||||||
_setInnerFocus = [=] {
|
_setInnerFocus = [=] {
|
||||||
(_startText.isEmpty() ? text : url)->setFocusFast();
|
if (_startText.isEmpty()) {
|
||||||
|
text->setFocusFast();
|
||||||
|
} else {
|
||||||
|
url->setFocusFast();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue