mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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;
|
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()),
|
v::text::take_plain(std::move(args.confirmText), tr::lng_box_ok()),
|
||||||
[=, c = prepareCallback(args.confirmed)]() {
|
[=, c = prepareCallback(args.confirmed)]() {
|
||||||
lifetime->destroy();
|
lifetime->destroy();
|
||||||
c();
|
c();
|
||||||
},
|
},
|
||||||
args.confirmStyle ? *args.confirmStyle : defaultButtonStyle);
|
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) {
|
if (!args.inform) {
|
||||||
const auto cancelButton = box->addButton(
|
const auto cancelButton = box->addButton(
|
||||||
|
|
Loading…
Add table
Reference in a new issue