2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Set folder default from context menu

This commit is contained in:
RadRussianRus
2020-03-30 08:41:05 +03:00
parent d819c07823
commit d66325b45c
4 changed files with 43 additions and 3 deletions

View File

@@ -2461,5 +2461,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_settings_recent_stickers_limit_none" = "Recent stickers: hide all";
"ktg_filters_default" = "Default folder";
"ktg_filters_context_edit_all" = "Edit folders";
"ktg_filters_context_make_default" = "Make folder default";
// Keys finished

View File

@@ -98,5 +98,7 @@
"other": "Недавние стикеры: показывать {count} стикеров"
},
"ktg_settings_recent_stickers_limit_none": "Недавние стикеры: скрыть все",
"ktg_filters_default": "Папка по умолчанию"
"ktg_filters_default": "Папка по умолчанию",
"ktg_filters_context_edit_all": "Изменить папки",
"ktg_filters_context_make_default": "Сделать папкой по умолчанию"
}

View File

@@ -241,12 +241,16 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
}
}
});
if (id > 0) {
if (id >= 0) {
raw->events(
) | rpl::filter([=](not_null<QEvent*> e) {
return e->type() == QEvent::ContextMenu;
}) | rpl::start_with_next([=] {
showMenu(QCursor::pos(), id);
if (id){
showMenu(QCursor::pos(), id);
} else {
showAllMenu(QCursor::pos());
}
}, raw->lifetime());
}
return button;
@@ -265,12 +269,42 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) {
_popupMenu->addAction(
tr::lng_filters_context_edit(tr::now),
crl::guard(&_outer, [=] { showEditBox(id); }));
if (cDefaultFilterId() != id) {
_popupMenu->addAction(
tr::ktg_filters_context_make_default(tr::now),
crl::guard(&_outer, [=] { setDefaultFilter(id); }));
}
_popupMenu->addAction(
tr::lng_filters_context_remove(tr::now),
crl::guard(&_outer, [=] { showRemoveBox(id); }));
_popupMenu->popup(position);
}
void FiltersMenu::showAllMenu(QPoint position) {
if (_popupMenu) {
_popupMenu = nullptr;
return;
}
_popupMenu = base::make_unique_q<Ui::PopupMenu>(_all);
_popupMenu->addAction(
tr::ktg_filters_context_edit_all(tr::now),
crl::guard(&_outer, [=] { _session->showSettings(Settings::Type::Folders); }));
if (cDefaultFilterId() != 0) {
_popupMenu->addAction(
tr::ktg_filters_context_make_default(tr::now),
crl::guard(&_outer, [=] { setDefaultFilter(0); }));
}
_popupMenu->popup(position);
}
void FiltersMenu::setDefaultFilter(FilterId id) {
if (cDefaultFilterId() != id) {
cSetDefaultFilterId(id);
KotatoSettings::Write();
}
}
void FiltersMenu::showEditBox(FilterId id) {
EditExistingFilter(_session, id);
}

View File

@@ -46,6 +46,8 @@ private:
const QString &title,
Ui::FilterIcon icon);
void showMenu(QPoint position, FilterId id);
void showAllMenu(QPoint position);
void setDefaultFilter(FilterId id);
void showEditBox(FilterId id);
void showRemoveBox(FilterId id);
void remove(FilterId id);