diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 925d7ec24..658bcd857 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1501,7 +1501,7 @@ void Widget::updateControlsGeometry() { } auto smallLayoutWidth = (st::dialogsPadding.x() + st::dialogsPhotoSize + st::dialogsPadding.x()); auto smallLayoutRatio = (width() < st::columnMinimalWidthLeft) ? (st::columnMinimalWidthLeft - width()) / float64(st::columnMinimalWidthLeft - smallLayoutWidth) : 0.; - auto filterLeft = (controller()->filtersWidth() ? 0 : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x(); + auto filterLeft = (controller()->filtersWidth() ? st::dialogsFilterSkip : st::dialogsFilterPadding.x() + _mainMenuToggle->width()) + st::dialogsFilterPadding.x(); auto filterRight = (Global::LocalPasscode() ? (st::dialogsFilterPadding.x() + _lockUnlock->width()) : st::dialogsFilterSkip) + st::dialogsFilterPadding.x(); auto filterWidth = qMax(width(), st::columnMinimalWidthLeft) - filterLeft - filterRight; auto filterAreaHeight = st::topBarHeight; diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index 71c77dbc8..63aa4ddea 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -16,6 +16,55 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_window.h" namespace Window { +namespace { + +enum class Type { + Unread, + Unmuted, + Custom, +}; + +[[nodiscard]] Type ComputeType(const Data::ChatFilter &filter) { + using Flag = Data::ChatFilter::Flag; + + const auto all = Flag::Contacts + | Flag::NonContacts + | Flag::Groups + | Flag::Broadcasts + | Flag::Bots + | Flag::NoArchive; + if (!filter.always().empty()) { + return Type::Custom; + } else if (filter.flags() == (all | Flag::NoRead)) { + return Type::Unread; + } else if (filter.flags() == (all | Flag::NoMuted)) { + return Type::Unmuted; + } + return Type::Custom; +} + +[[nodiscard]] std::array ComputeIcons(Type type) { + switch (type) { + case Type::Unread: + return { + &st::windowFiltersUnread, + &st::windowFiltersUnreadActive + }; + case Type::Unmuted: + return { + &st::windowFiltersUnmuted, + &st::windowFiltersUnmutedActive + }; + case Type::Custom: + return { + &st::windowFiltersCustom, + &st::windowFiltersCustomActive + }; + } + Unexpected("Filter type in FiltersMenu::refresh."); +} + +} // namespace FiltersMenu::FiltersMenu( not_null parent, @@ -73,18 +122,20 @@ void FiltersMenu::refresh() { QString::number(0), "All Chats", QString(), - &st::windowFiltersCustom, - &st::windowFiltersCustomActive, + &st::windowFiltersAll, + &st::windowFiltersAllActive, st::windowFiltersIconTop }); const auto filters = &_session->session().data().chatsFilters(); for (const auto &filter : filters->list()) { + const auto type = ComputeType(filter); + const auto icons = ComputeIcons(type); items.push_back({ QString::number(filter.id()), filter.title(), QString(), - &st::windowFiltersCustom, - &st::windowFiltersCustomActive, + icons[0], + icons[1], st::windowFiltersIconTop }); }