mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Improved UX in box for link creation when user has link in clipboard.
This commit is contained in:
parent
22a3093815
commit
4288ba2449
1 changed files with 22 additions and 0 deletions
|
@ -220,6 +220,9 @@ void EditLinkBox(
|
||||||
if (startText.isEmpty()) {
|
if (startText.isEmpty()) {
|
||||||
text->setFocusFast();
|
text->setFocusFast();
|
||||||
} else {
|
} else {
|
||||||
|
if (!url->empty()) {
|
||||||
|
url->selectAll();
|
||||||
|
}
|
||||||
url->setFocusFast();
|
url->setFocusFast();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -227,12 +230,31 @@ void EditLinkBox(
|
||||||
url->customTab(true);
|
url->customTab(true);
|
||||||
text->customTab(true);
|
text->customTab(true);
|
||||||
|
|
||||||
|
const auto clearFullSelection = [=](not_null<Ui::InputField*> input) {
|
||||||
|
if (input->empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto cursor = input->rawTextEdit()->textCursor();
|
||||||
|
const auto hasFull = (!cursor.selectionStart()
|
||||||
|
&& (cursor.selectionEnd()
|
||||||
|
== (input->rawTextEdit()->document()->characterCount() - 1)));
|
||||||
|
if (hasFull) {
|
||||||
|
cursor.clearSelection();
|
||||||
|
input->setTextCursor(cursor);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
url->tabbed(
|
url->tabbed(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
clearFullSelection(url);
|
||||||
text->setFocus();
|
text->setFocus();
|
||||||
}, url->lifetime());
|
}, url->lifetime());
|
||||||
text->tabbed(
|
text->tabbed(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
|
if (!url->empty()) {
|
||||||
|
url->selectAll();
|
||||||
|
}
|
||||||
|
clearFullSelection(text);
|
||||||
url->setFocus();
|
url->setFocus();
|
||||||
}, text->lifetime());
|
}, text->lifetime());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue