mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-10 21:53:50 +00:00
Added ability to switch filters in share and forward boxes with hotkey.
This commit is contained in:
@@ -366,7 +366,10 @@ void ShareBox::prepare() {
|
||||
_inner->applyChatFilter(id);
|
||||
scrollToY(0);
|
||||
},
|
||||
Window::GifPauseReason::Layer);
|
||||
Window::GifPauseReason::Layer,
|
||||
nullptr,
|
||||
false,
|
||||
true);
|
||||
chatsFilters->lower();
|
||||
chatsFilters->heightValue() | rpl::on_next([this](int h) {
|
||||
updateScrollSkips();
|
||||
|
||||
@@ -35,6 +35,9 @@ public:
|
||||
void fitWidthToSections() override;
|
||||
void setUnreadCount(int index, int unreadCount, bool muted);
|
||||
void setLockedFrom(int index);
|
||||
[[nodiscard]] int lockedFrom() const {
|
||||
return _lockedFrom;
|
||||
}
|
||||
|
||||
[[nodiscard]] rpl::producer<int> contextMenuRequested() const;
|
||||
[[nodiscard]] rpl::producer<> lockedClicked() const;
|
||||
|
||||
@@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
#include "boxes/filters/edit_filter_box.h"
|
||||
#include "boxes/premium_limits_box.h"
|
||||
#include "core/application.h"
|
||||
#include "core/shortcuts.h"
|
||||
#include "core/ui_integration.h"
|
||||
#include "data/data_chat_filters.h"
|
||||
#include "data/data_peer_values.h" // Data::AmPremiumValue.
|
||||
@@ -204,7 +205,8 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||
Fn<void(FilterId)> choose,
|
||||
ChatHelpers::PauseReason pauseLevel,
|
||||
Window::SessionController *controller,
|
||||
bool trackActiveFilterAndUnreadAndReorder) {
|
||||
bool trackActiveFilterAndUnreadAndReorder,
|
||||
bool handleKeyboardSwitch) {
|
||||
|
||||
const auto wrap = Ui::CreateChild<Ui::SlideWrap<Ui::RpWidget>>(
|
||||
parent,
|
||||
@@ -523,6 +525,26 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||
wrap->resize(w, h);
|
||||
}, wrap->lifetime());
|
||||
|
||||
if (handleKeyboardSwitch) {
|
||||
Shortcuts::ChatSwitchRequests(
|
||||
) | rpl::filter([=](const Shortcuts::ChatSwitchRequest &request) {
|
||||
return wrap->toggled()
|
||||
&& ((request.action == Qt::Key_Tab)
|
||||
|| (request.action == Qt::Key_Backtab));
|
||||
}) | rpl::on_next([=](const Shortcuts::ChatSwitchRequest &request) {
|
||||
const auto count = slider->sectionsCount();
|
||||
const auto locked = slider->lockedFrom();
|
||||
const auto limit = locked ? locked : count;
|
||||
if (limit <= 1) {
|
||||
return;
|
||||
}
|
||||
const auto back = (request.action == Qt::Key_Backtab);
|
||||
const auto current = std::min(slider->activeSection(), limit - 1);
|
||||
const auto next = (current + (back ? -1 : 1) + limit) % limit;
|
||||
slider->setActiveSection(next);
|
||||
}, wrap->lifetime());
|
||||
}
|
||||
|
||||
return wrap;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ not_null<Ui::RpWidget*> AddChatFiltersTabsStrip(
|
||||
Fn<void(FilterId)> choose,
|
||||
ChatHelpers::PauseReason pauseLevel,
|
||||
Window::SessionController *controller = nullptr,
|
||||
bool trackActiveFilterAndUnreadAndReorder = false);
|
||||
bool trackActiveFilterAndUnreadAndReorder = false,
|
||||
bool handleKeyboardSwitch = false);
|
||||
|
||||
} // namespace Ui
|
||||
|
||||
@@ -3052,7 +3052,10 @@ base::weak_qptr<Ui::BoxContent> ShowForwardMessagesBox(
|
||||
*lastFilterId = id;
|
||||
applyFilter(box, id);
|
||||
},
|
||||
Window::GifPauseReason::Layer);
|
||||
Window::GifPauseReason::Layer,
|
||||
nullptr,
|
||||
false,
|
||||
true);
|
||||
chatsFilters->lower();
|
||||
rpl::combine(
|
||||
chatsFilters->heightValue(),
|
||||
|
||||
@@ -1901,7 +1901,8 @@ void SessionController::setupShortcuts() {
|
||||
return !window().locked()
|
||||
&& (_chatSwitchProcess
|
||||
|| (request.started
|
||||
&& (Core::App().activeWindow() == &window())));
|
||||
&& (Core::App().activeWindow() == &window())
|
||||
&& !isLayerShown()));
|
||||
}) | rpl::on_next([=](const ChatSwitchRequest &request) {
|
||||
if (!_chatSwitchProcess) {
|
||||
_chatSwitchProcess = std::make_unique<ChatSwitchProcess>(
|
||||
|
||||
Reference in New Issue
Block a user