mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15:08 +02:00
Added ability to switch filters in share and forward boxes with hotkey.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user