mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-03 21:54:05 +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()) {
|
||||
text->setFocusFast();
|
||||
} else {
|
||||
if (!url->empty()) {
|
||||
url->selectAll();
|
||||
}
|
||||
url->setFocusFast();
|
||||
}
|
||||
});
|
||||
|
@ -227,12 +230,31 @@ void EditLinkBox(
|
|||
url->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(
|
||||
) | rpl::start_with_next([=] {
|
||||
clearFullSelection(url);
|
||||
text->setFocus();
|
||||
}, url->lifetime());
|
||||
text->tabbed(
|
||||
) | rpl::start_with_next([=] {
|
||||
if (!url->empty()) {
|
||||
url->selectAll();
|
||||
}
|
||||
clearFullSelection(text);
|
||||
url->setFocus();
|
||||
}, text->lifetime());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue