From 2583ddea2ef17fb1862496b836389cb5d9466988 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 15 Jun 2022 17:23:01 +0400 Subject: [PATCH] Switch premium previews by keyboard. --- .../SourceFiles/boxes/premium_preview_box.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Telegram/SourceFiles/boxes/premium_preview_box.cpp b/Telegram/SourceFiles/boxes/premium_preview_box.cpp index 545de7cc47..bcbb6cabb1 100644 --- a/Telegram/SourceFiles/boxes/premium_preview_box.cpp +++ b/Telegram/SourceFiles/boxes/premium_preview_box.cpp @@ -1476,6 +1476,23 @@ void PreviewBox( }, box->lifetime()); } + box->events( + ) | rpl::start_with_next([=](not_null e) { + if (e->type() == QEvent::KeyPress) { + const auto key = static_cast(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()); }