mirror of https://github.com/procxx/kepka.git
Show some special filter icons.
This commit is contained in:
parent
48d790de5e
commit
fcfb268677
|
@ -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;
|
||||
|
|
|
@ -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<const style::icon*, 2> 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<Ui::RpWidget*> 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
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue