Replaced box for choosing of filter with submenu.
This commit is contained in:
parent
d15ff46eb4
commit
8440c44def
Binary file not shown.
After Width: | Height: | Size: 608 B |
Binary file not shown.
After Width: | Height: | Size: 1003 B |
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/text/text_utilities.h" // Ui::Text::Bold
|
||||||
#include "ui/toast/toast.h"
|
#include "ui/toast/toast.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
#include "ui/widgets/popup_menu.h"
|
||||||
#include "window/window_session_controller.h"
|
#include "window/window_session_controller.h"
|
||||||
#include "styles/style_settings.h"
|
#include "styles/style_settings.h"
|
||||||
#include "styles/style_payments.h" // paymentsSectionButton
|
#include "styles/style_payments.h" // paymentsSectionButton
|
||||||
|
#include "styles/style_media_player.h" // mediaPlayerMenuCheck
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -203,3 +205,31 @@ void ChooseFilterBox(
|
||||||
|
|
||||||
box->addButton(tr::lng_close(), [=] { box->closeBox(); });
|
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 {
|
namespace Ui {
|
||||||
class GenericBox;
|
class GenericBox;
|
||||||
|
class PopupMenu;
|
||||||
} // namespace Ui
|
} // namespace Ui
|
||||||
|
|
||||||
class History;
|
class History;
|
||||||
|
@ -31,3 +32,7 @@ private:
|
||||||
void ChooseFilterBox(
|
void ChooseFilterBox(
|
||||||
not_null<Ui::GenericBox*> box,
|
not_null<Ui::GenericBox*> box,
|
||||||
not_null<History*> history);
|
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 }};
|
menuIconSoundAdd: icon {{ "menu/sound_add", menuIconColor }};
|
||||||
menuIconFile: icon {{ "menu/file", menuIconColor }};
|
menuIconFile: icon {{ "menu/file", menuIconColor }};
|
||||||
menuIconPhoto: icon {{ "menu/image", menuIconColor }};
|
menuIconPhoto: icon {{ "menu/image", menuIconColor }};
|
||||||
|
menuIconAddToFolder: icon {{ "menu/add_to_folder", menuIconColor }};
|
||||||
|
|
||||||
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
menuIconTTLAny: icon {{ "menu/auto_delete_plain", menuIconColor }};
|
||||||
menuIconTTLAnyTextPosition: point(11px, 22px);
|
menuIconTTLAnyTextPosition: point(11px, 22px);
|
||||||
|
|
|
@ -420,27 +420,17 @@ void Filler::addInfo() {
|
||||||
|
|
||||||
void Filler::addToggleFolder() {
|
void Filler::addToggleFolder() {
|
||||||
const auto history = _request.key.history();
|
const auto history = _request.key.history();
|
||||||
if (!history) {
|
if (!history || history->owner().chatsFilters().list().empty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!_request.filterId) {
|
_addAction(PeerMenuCallback::Args{
|
||||||
if (!ChooseFilterValidator(history).canAdd()) {
|
.text = tr::lng_filters_menu_add(tr::now),
|
||||||
return;
|
.handler = nullptr,
|
||||||
}
|
.icon = &st::menuIconAddToFolder,
|
||||||
const auto window = _controller;
|
.fillSubmenu = [=](not_null<Ui::PopupMenu*> menu) {
|
||||||
_addAction(tr::lng_filters_menu_add(tr::now), [=] {
|
FillChooseFilterMenu(menu, history);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Filler::addToggleUnreadMark() {
|
void Filler::addToggleUnreadMark() {
|
||||||
|
|
Loading…
Reference in New Issue