mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Switch premium previews by keyboard.
This commit is contained in:
parent
855d4692fe
commit
2583ddea2e
1 changed files with 17 additions and 0 deletions
|
@ -1476,6 +1476,23 @@ void PreviewBox(
|
|||
}, box->lifetime());
|
||||
}
|
||||
|
||||
box->events(
|
||||
) | rpl::start_with_next([=](not_null<QEvent*> e) {
|
||||
if (e->type() == QEvent::KeyPress) {
|
||||
const auto key = static_cast<QKeyEvent*>(e.get())->key();
|
||||
using Type = PremiumPreview;
|
||||
if (key == Qt::Key_Left) {
|
||||
const auto count = int(Type::kCount);
|
||||
const auto now = state->selected.current();
|
||||
state->selected = Type((int(now) + count - 1) % count);
|
||||
} else if (key == Qt::Key_Right) {
|
||||
const auto count = int(Type::kCount);
|
||||
const auto now = state->selected.current();
|
||||
state->selected = Type((int(now) + 1) % count);
|
||||
}
|
||||
}
|
||||
}, box->lifetime());
|
||||
|
||||
if (const auto &hidden = descriptor.hiddenCallback) {
|
||||
box->boxClosing() | rpl::start_with_next(hidden, box->lifetime());
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue