diff --git a/Telegram/Resources/langs/rewrites/en.json b/Telegram/Resources/langs/rewrites/en.json index ab91d5b32..31897cb43 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_fonts_title": "Fonts", "ktg_settings_fonts": "Change application fonts", diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 032793387..6042d3132 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -6742,15 +6742,17 @@ 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 - && !_replyTo) { - editMessage(item, {}); - return; + if (!::Kotato::JsonSettings::GetBool("disable_up_edit")) { + const auto item = _history + ? _history->lastEditableMessage() + : nullptr; + if (item + && _field->empty() + && !_editMsgId + && !_replyTo) { + editMessage(item, {}); + return; + } } _scroll->keyPressEvent(e); } else if (e->key() == Qt::Key_Up 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 9154d846e..d71f80099 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/call_delayed.h" #include "base/event_filter.h" #include "base/platform/base_platform_info.h" @@ -1539,7 +1540,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 ef853d8f4..240985d60 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings.cpp @@ -249,6 +249,9 @@ const std::map> DefinitionMap { .type = SettingType::IntSetting, .defaultValue = 2, .limitHandler = IntLimit(0, 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 9882eec70..c78b6b14d 100644 --- a/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp +++ b/Telegram/SourceFiles/kotato/kotato_settings_menu.cpp @@ -88,6 +88,7 @@ void SetupKotatoChats( Ui::AddSkip(container); Ui::AddSubsectionTitle(container, rktr("ktg_settings_chats")); + SettingsMenuJsonSwitch(ktg_settings_disable_up_edit, disable_up_edit); SettingsMenuJsonSwitch(ktg_settings_always_show_scheduled, always_show_scheduled); container->add(object_ptr