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

Hide Edit and All Chats from context menu

This commit is contained in:
RadRussianRus
2020-09-07 15:00:44 +03:00
parent d4db0e0ec5
commit f0ceaf56ee
10 changed files with 82 additions and 12 deletions

View File

@@ -2659,4 +2659,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"ktg_filters_cloud_limit" = "Sorry, you can't create more cloud folders. You can create local folder instead.";
"ktg_filters_hide_folder" = "Hide folder";
"ktg_filters_hide_button" = "Hide button";
"ktg_filters_hide_all_chats_toast" = "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.";
"ktg_filters_hide_edit_toast" = "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.";
// Keys finished

View File

@@ -200,6 +200,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -200,6 +200,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -208,6 +208,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -200,6 +200,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -207,6 +207,10 @@
"ktg_filters_local": "локальная папка",
"ktg_filters_cloud": "облачная папка",
"ktg_filters_cloud_limit": "Вы создали максимальное число облачных папок. Вместо этого можно создать локальную папку.",
"ktg_filters_hide_folder": "Скрыть папку",
"ktg_filters_hide_button": "Скрыть кнопку",
"ktg_filters_hide_all_chats_toast": "Папка «Все чаты» скрыта.\nВы можете включить её обратно в настройках Kotatogram.",
"ktg_filters_hide_edit_toast": "Кнопка изменения скрыта.\nВы можете включить её обратно в настройках Kotatogram.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -200,6 +200,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -207,6 +207,10 @@
"ktg_filters_local": "local folder",
"ktg_filters_cloud": "cloud folder",
"ktg_filters_cloud_limit": "Sorry, you can't create more cloud folders. You can create local folder instead.",
"ktg_filters_hide_folder": "Hide folder",
"ktg_filters_hide_button": "Hide button",
"ktg_filters_hide_all_chats_toast": "\"All Chats\" folder is hidden.\nYou can enable it back in Kotatogram Settings.",
"ktg_filters_hide_edit_toast": "Edit button is hidden.\nYou can enable it back in Kotatogram Settings.",
// This string should always be last for better work with Git.
"dummy_last_string": ""

View File

@@ -20,6 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/filter_icons.h"
#include "ui/wrap/vertical_layout_reorder.h"
#include "ui/widgets/popup_menu.h"
#include "ui/toast/toast.h"
#include "boxes/confirm_box.h"
#include "boxes/filters/edit_filter_box.h"
#include "kotato/json_settings.h"
@@ -317,18 +318,18 @@ base::unique_qptr<Ui::SideBarButton> FiltersMenu::prepareButton(
}
}
});
if (id >= 0) {
raw->events(
) | rpl::filter([=](not_null<QEvent*> e) {
return e->type() == QEvent::ContextMenu;
}) | rpl::start_with_next([=] {
if (id){
showMenu(QCursor::pos(), id);
} else {
showAllMenu(QCursor::pos());
}
}, raw->lifetime());
}
raw->events(
) | rpl::filter([=](not_null<QEvent*> e) {
return e->type() == QEvent::ContextMenu;
}) | rpl::start_with_next([=] {
if (id == -1) {
showEditMenu(QCursor::pos());
} else if (id) {
showMenu(QCursor::pos(), id);
} else {
showAllMenu(QCursor::pos());
}
}, raw->lifetime());
return button;
}
@@ -376,10 +377,44 @@ void FiltersMenu::showAllMenu(QPoint position) {
tr::ktg_filters_context_make_default(tr::now),
crl::guard(&_outer, [=] { setDefaultFilter(0); }));
}
_popupMenu->addAction(
tr::ktg_filters_hide_folder(tr::now),
crl::guard(&_outer, [=] {
cSetHideFilterAllChats(true);
Kotato::JsonSettings::Write();
_all = nullptr;
Ui::Toast::Show(Ui::Toast::Config{
.text = { tr::ktg_filters_hide_all_chats_toast(tr::now) },
.st = &st::windowArchiveToast,
.multiline = true,
});
}));
_popupMenu->popup(position);
}
void FiltersMenu::showEditMenu(QPoint position) {
if (_popupMenu) {
_popupMenu = nullptr;
return;
}
_popupMenu = base::make_unique_q<Ui::PopupMenu>(_setup);
_popupMenu->addAction(
tr::ktg_filters_hide_button(tr::now),
crl::guard(&_outer, [=] {
cSetHideFilterEditButton(true);
Kotato::JsonSettings::Write();
_setup = nullptr;
Ui::Toast::Show(Ui::Toast::Config{
.text = { tr::ktg_filters_hide_edit_toast(tr::now) },
.st = &st::windowArchiveToast,
.multiline = true,
});
}));
_popupMenu->popup(position);
}
void FiltersMenu::setDefaultFilter(FilterId id) {
const auto defaultFilterId = _session->session().account().defaultFilterId();
if (defaultFilterId != id) {

View File

@@ -51,6 +51,7 @@ private:
void setupMainMenuIcon();
void showMenu(QPoint position, FilterId id);
void showAllMenu(QPoint position);
void showEditMenu(QPoint position);
void setDefaultFilter(FilterId id);
void showEditBox(FilterId id);
void showRemoveBox(FilterId id);