diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index 476d240ad..db908093d 100644 --- a/Telegram/Resources/langs/rewrites/en.json +++ b/Telegram/Resources/langs/rewrites/en.json @@ -32,6 +32,7 @@ "ktg_settings_sticker_scale_both": "Apply to sticker width", "ktg_settings_sticker_scale_both_about": "When enabled, sticker maximum width will be changed along with sticker height.", "ktg_settings_emoji_outline": "Big emoji outline", + "ktg_settings_disable_up_edit": "Disable edit by Up key", "ktg_settings_always_show_scheduled": "Always show scheduled", "ktg_settings_chat_list_compact": "Compact chat list", "ktg_fonts_title": "Fonts", diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 78bbd7d9a..ad0555171 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6186,15 +6186,18 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) { } else if (e->key() == Qt::Key_Down && !commonModifiers) { _scroll->keyPressEvent(e); } else if (e->key() == Qt::Key_Up && !commonModifiers) { - const auto item = _history - ? _history->lastEditableMessage() - : nullptr; - if (item - && _field->empty() - && !_editMsgId - && !_replyToId) { - editMessage(item); - return; + if (!::Kotato::JsonSettings::GetBool("disable_up_edit")) { + const auto item = _history + ? _history->lastEditableMessage() + : nullptr; + if (item + && item->allowsEdit(base::unixtime::now()) + && _field->empty() + && !_editMsgId + && !_replyToId) { + editMessage(item); + return; + } } _scroll->keyPressEvent(e); } else if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 23862214b..6e33846c7 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "history/view/controls/history_view_compose_controls.h" +#include "kotato/kotato_settings.h" #include "base/event_filter.h" #include "base/platform/base_platform_info.h" #include "base/qt_signal_producer.h" @@ -1384,7 +1385,9 @@ void ComposeControls::initKeyHandler() { _attachRequests.fire({}); return; } - if (key == Qt::Key_Up && !hasModifiers) { + if (key == Qt::Key_Up + && !hasModifiers + && !::Kotato::JsonSettings::GetBool("disable_up_edit")) { if (!isEditingMessage() && _field->empty()) { _editLastMessageRequests.fire(std::move(keyEvent)); return; diff --git a/Telegram/SourceFiles/kotato/kotato_settings.cpp b/Telegram/SourceFiles/kotato/kotato_settings.cpp index 95aa3ea4a..b2a4bf772 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -316,6 +316,9 @@ const std::map> DefinitionMap { .type = SettingType::IntSetting, .defaultValue = 2, .limitHandler = IntLimit(1, 2, 2), }}, + { "disable_up_edit", { + .type = SettingType::BoolSetting, + .defaultValue = false, }}, }; using OldOptionKey = QString; diff --git a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp index 4f4867092..ffd0de742 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -105,6 +105,8 @@ void SetupKotatoChats( AddSkip(container); AddSubsectionTitle(container, rktr("ktg_settings_chats")); + SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit); + AddButton( container, rktr("ktg_settings_chat_list_compact"),