mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Replaced box for choosing of filter with submenu.
This commit is contained in:
parent
d15ff46eb4
commit
8440c44def
7 changed files with 45 additions and 19 deletions
BIN
Telegram/Resources/icons/menu/add_to_folder.png
Normal file
BIN
Telegram/Resources/icons/menu/add_to_folder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 608 B |
BIN
Telegram/Resources/icons/menu/add_to_folder@2x.png
Normal file
BIN
Telegram/Resources/icons/menu/add_to_folder@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1,003 B |
BIN
Telegram/Resources/icons/menu/add_to_folder@3x.png
Normal file
BIN
Telegram/Resources/icons/menu/add_to_folder@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
|
@ -19,9 +19,11 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "ui/text/text_utilities.h" // Ui::Text::Bold
|
||||
#include "ui/toast/toast.h"
|
||||
#include "ui/widgets/buttons.h"
|
||||
#include "ui/widgets/popup_menu.h"
|
||||
#include "window/window_session_controller.h"
|
||||
#include "styles/style_settings.h"
|
||||
#include "styles/style_payments.h" // paymentsSectionButton
|
||||
#include "styles/style_media_player.h" // mediaPlayerMenuCheck
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -203,3 +205,31 @@ void ChooseFilterBox(
|
|||
|
||||
box->addButton(tr::lng_close(), [=] { box->closeBox(); });
|
||||
}
|
||||
|
||||
void FillChooseFilterMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<History*> history) {
|
||||
const auto validator = ChooseFilterValidator(history);
|
||||
for (const auto &filter : history->owner().chatsFilters().list()) {
|
||||
const auto id = filter.id();
|
||||
const auto contains = filter.contains(history);
|
||||
const auto action = menu->addAction(filter.title(), [=] {
|
||||
if (filter.contains(history)) {
|
||||
if (validator.canRemove(id)) {
|
||||
validator.remove(id);
|
||||
}
|
||||
} else {
|
||||
if (validator.canAdd()) {
|
||||
validator.add(id);
|
||||
}
|
||||
}
|
||||
}, contains ? &st::mediaPlayerMenuCheck : nullptr);
|
||||
action->setEnabled(contains
|
||||
? validator.canRemove(id)
|
||||
: validator.canAdd());
|
||||
}
|
||||
history->owner().chatsFilters().changed(
|
||||
) | rpl::start_with_next([=] {
|
||||
menu->hideMenu();
|
||||
}, menu->lifetime());
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
|
||||
namespace Ui {
|
||||
class GenericBox;
|
||||
class PopupMenu;
|
||||
} // namespace Ui
|
||||
|
||||
class History;
|
||||
|
@ -31,3 +32,7 @@ private:
|
|||
void ChooseFilterBox(
|
||||
not_null<Ui::GenericBox*> box,
|
||||
not_null<History*> history);
|
||||
|
||||
void FillChooseFilterMenu(
|
||||
not_null<Ui::PopupMenu*> menu,
|
||||
not_null<History*> history);
|
||||
|
|
|
@ -111,6 +111,7 @@ menuIconSoundSelect: icon {{ "menu/sound_select", menuIconColor }};
|
|||
menuIconSoundAdd: icon {{ "menu/sound_add", menuIconColor }};
|
||||
menuIconFile: icon {{ "menu/file", menuIconColor }};
|
||||
menuIconPhoto: icon {{ "menu/image", menuIconColor }};
|
||||
menuIconAddToFolder: icon {{ "menu/add_to_folder", menuIconColor }};
|
||||
|
||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||
|
|
|
@ -420,27 +420,17 @@ void Filler::addInfo() {
|
|||
|
||||
void Filler::addToggleFolder() {
|
||||
const auto history = _request.key.history();
|
||||
if (!history) {
|
||||
if (!history || history->owner().chatsFilters().list().empty()) {
|
||||
return;
|
||||
}
|
||||
if (!_request.filterId) {
|
||||
if (!ChooseFilterValidator(history).canAdd()) {
|
||||
return;
|
||||
}
|
||||
const auto window = _controller;
|
||||
_addAction(tr::lng_filters_menu_add(tr::now), [=] {
|
||||
window->show(Box(ChooseFilterBox, history));
|
||||
}, nullptr);
|
||||
} else {
|
||||
const auto id = _request.filterId;
|
||||
const auto validator = ChooseFilterValidator(history);
|
||||
if (!validator.canRemove(id)) {
|
||||
return;
|
||||
}
|
||||
_addAction(tr::lng_filters_menu_remove(tr::now), [=] {
|
||||
validator.remove(id);
|
||||
}, nullptr);
|
||||
}
|
||||
_addAction(PeerMenuCallback::Args{
|
||||
.text = tr::lng_filters_menu_add(tr::now),
|
||||
.handler = nullptr,
|
||||
.icon = &st::menuIconAddToFolder,
|
||||
.fillSubmenu = [=](not_null<Ui::PopupMenu*> menu) {
|
||||
FillChooseFilterMenu(menu, history);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
void Filler::addToggleUnreadMark() {
|
||||
|
|
Loading…
Add table
Reference in a new issue