mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-19 07:37:11 +02:00
Returned Enter shortcut to confirm box.
This commit is contained in:
parent
ffc0e04a1e
commit
2b8eefccca
1 changed files with 11 additions and 1 deletions
|
@ -42,13 +42,23 @@ void ConfirmBox(not_null<Ui::GenericBox*> box, ConfirmBoxArgs &&args) {
|
|||
|
||||
const auto &defaultButtonStyle = box->getDelegate()->style().button;
|
||||
|
||||
box->addButton(
|
||||
const auto confirmButton = box->addButton(
|
||||
v::text::take_plain(std::move(args.confirmText), tr::lng_box_ok()),
|
||||
[=, c = prepareCallback(args.confirmed)]() {
|
||||
lifetime->destroy();
|
||||
c();
|
||||
},
|
||||
args.confirmStyle ? *args.confirmStyle : defaultButtonStyle);
|
||||
box->events(
|
||||
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
if ((e->type() != QEvent::KeyPress) || !confirmButton) {
|
||||
return;
|
||||
}
|
||||
const auto k = static_cast<QKeyEvent*>(e.get());
|
||||
if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return) {
|
||||
confirmButton->clicked(Qt::KeyboardModifiers(), Qt::LeftButton);
|
||||
}
|
||||
}, box->lifetime());
|
||||
|
||||
if (!args.inform) {
|
||||
const auto cancelButton = box->addButton(
|
||||
|
|
Loading…
Add table
Reference in a new issue