mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-09-02 23:55:12 +00:00
Set folder default from context menu
This commit is contained in:
@@ -2461,5 +2461,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||||||
"ktg_settings_recent_stickers_limit_none" = "Recent stickers: hide all";
|
"ktg_settings_recent_stickers_limit_none" = "Recent stickers: hide all";
|
||||||
|
|
||||||
"ktg_filters_default" = "Default folder";
|
"ktg_filters_default" = "Default folder";
|
||||||
|
"ktg_filters_context_edit_all" = "Edit folders";
|
||||||
|
"ktg_filters_context_make_default" = "Make folder default";
|
||||||
|
|
||||||
// Keys finished
|
// Keys finished
|
||||||
|
@@ -98,5 +98,7 @@
|
|||||||
"other": "Недавние стикеры: показывать {count} стикеров"
|
"other": "Недавние стикеры: показывать {count} стикеров"
|
||||||
},
|
},
|
||||||
"ktg_settings_recent_stickers_limit_none": "Недавние стикеры: скрыть все",
|
"ktg_settings_recent_stickers_limit_none": "Недавние стикеры: скрыть все",
|
||||||
"ktg_filters_default": "Папка по умолчанию"
|
"ktg_filters_default": "Папка по умолчанию",
|
||||||
|
"ktg_filters_context_edit_all": "Изменить папки",
|
||||||
|
"ktg_filters_context_make_default": "Сделать папкой по умолчанию"
|
||||||
}
|
}
|
||||||
|
@@ -241,12 +241,16 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (id > 0) {
|
if (id >= 0) {
|
||||||
raw->events(
|
raw->events(
|
||||||
) | rpl::filter([=](not_null<QEvent*> e) {
|
) | rpl::filter([=](not_null<QEvent*> e) {
|
||||||
return e->type() == QEvent::ContextMenu;
|
return e->type() == QEvent::ContextMenu;
|
||||||
}) | rpl::start_with_next([=] {
|
}) | rpl::start_with_next([=] {
|
||||||
showMenu(QCursor::pos(), id);
|
if (id){
|
||||||
|
showMenu(QCursor::pos(), id);
|
||||||
|
} else {
|
||||||
|
showAllMenu(QCursor::pos());
|
||||||
|
}
|
||||||
}, raw->lifetime());
|
}, raw->lifetime());
|
||||||
}
|
}
|
||||||
return button;
|
return button;
|
||||||
@@ -265,12 +269,42 @@ void FiltersMenu::showMenu(QPoint position, FilterId id) {
|
|||||||
_popupMenu->addAction(
|
_popupMenu->addAction(
|
||||||
tr::lng_filters_context_edit(tr::now),
|
tr::lng_filters_context_edit(tr::now),
|
||||||
crl::guard(&_outer, [=] { showEditBox(id); }));
|
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(
|
_popupMenu->addAction(
|
||||||
tr::lng_filters_context_remove(tr::now),
|
tr::lng_filters_context_remove(tr::now),
|
||||||
crl::guard(&_outer, [=] { showRemoveBox(id); }));
|
crl::guard(&_outer, [=] { showRemoveBox(id); }));
|
||||||
_popupMenu->popup(position);
|
_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) {
|
void FiltersMenu::showEditBox(FilterId id) {
|
||||||
EditExistingFilter(_session, id);
|
EditExistingFilter(_session, id);
|
||||||
}
|
}
|
||||||
|
@@ -46,6 +46,8 @@ private:
|
|||||||
const QString &title,
|
const QString &title,
|
||||||
Ui::FilterIcon icon);
|
Ui::FilterIcon icon);
|
||||||
void showMenu(QPoint position, FilterId id);
|
void showMenu(QPoint position, FilterId id);
|
||||||
|
void showAllMenu(QPoint position);
|
||||||
|
void setDefaultFilter(FilterId id);
|
||||||
void showEditBox(FilterId id);
|
void showEditBox(FilterId id);
|
||||||
void showRemoveBox(FilterId id);
|
void showRemoveBox(FilterId id);
|
||||||
void remove(FilterId id);
|
void remove(FilterId id);
|
||||||
|
Reference in New Issue
Block a user