Added experimental macOS option for instant reply on Cmd + Up/Down.

This commit is contained in:
23rd
2026-06-10 19:41:12 +03:00
parent 66faf6c612
commit cf2e06b886
4 changed files with 27 additions and 3 deletions
@@ -63,6 +63,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/ui_utility.h"
#include "inline_bots/inline_bot_result.h"
#include "base/event_filter.h"
#include "base/options.h"
#include "base/qt_signal_producer.h"
#include "base/qt/qt_key_modifiers.h"
#include "base/unixtime.h"
@@ -106,6 +107,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_streamed_drafts.h"
#include "history/history_unread_things.h"
#include "history/admin_log/history_admin_log_section.h"
#include "history/view/controls/compose_controls_common.h"
#include "history/view/controls/history_view_characters_limit.h"
#include "history/view/controls/history_view_compose_ai_button.h"
#include "history/view/controls/history_view_compose_ai_tooltip.h"
@@ -5844,7 +5846,9 @@ bool HistoryWidget::eventFilter(QObject *obj, QEvent *e) {
if (k->key() == Qt::Key_Up) {
#ifdef Q_OS_MAC
// Cmd + Up is used instead of Home.
if (HasSendText(_field)) {
if (HasSendText(_field)
&& !base::options::value<bool>(
HistoryView::Controls::kOptionMacCmdReplyImmediately)) {
return false;
}
#endif
@@ -5852,7 +5856,9 @@ bool HistoryWidget::eventFilter(QObject *obj, QEvent *e) {
} else if (k->key() == Qt::Key_Down) {
#ifdef Q_OS_MAC
// Cmd + Down is used instead of End.
if (HasSendText(_field)) {
if (HasSendText(_field)
&& !base::options::value<bool>(
HistoryView::Controls::kOptionMacCmdReplyImmediately)) {
return false;
}
#endif
@@ -23,6 +23,8 @@ class History;
namespace HistoryView::Controls {
extern const char kOptionMacCmdReplyImmediately[];
struct MessageToEdit {
FullMsgId fullId;
Api::SendOptions options;
@@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "base/call_delayed.h"
#include "base/event_filter.h"
#include "base/options.h"
#include "base/platform/base_platform_info.h"
#include "base/qt_signal_producer.h"
#include "base/random.h"
@@ -142,6 +143,15 @@ constexpr auto kCommonModifiers = 0
| Qt::MetaModifier
| Qt::ControlModifier;
base::options::toggle MacCmdReplyImmediately({
.id = Controls::kOptionMacCmdReplyImmediately,
.name = "Mac: instant reply on Cmd + Up/Down",
.description = "Reply to the previous or next message right away on "
"Cmd + Up/Down, instead of first moving the text cursor to the start "
"or end of the input field. Hold Shift to move the cursor as before.",
.scope = base::options::macos,
});
using FileChosen = ComposeControls::FileChosen;
using PhotoChosen = ComposeControls::PhotoChosen;
using MessageToEdit = ComposeControls::MessageToEdit;
@@ -153,6 +163,10 @@ using ForwardPanel = Controls::ForwardPanel;
} // namespace
namespace Controls {
const char kOptionMacCmdReplyImmediately[] = "mac-cmd-reply-immediately";
} // namespace Controls
const ChatHelpers::PauseReason kDefaultPanelsLevel
= ChatHelpers::PauseReason::TabbedPanel;
@@ -2359,7 +2373,7 @@ void ComposeControls::initKeyHandler() {
const auto isUp = (k->key() == Qt::Key_Up);
const auto isDown = (k->key() == Qt::Key_Down);
if (isUp || isDown) {
if (Platform::IsMac()) {
if (Platform::IsMac() && !MacCmdReplyImmediately.value()) {
// Cmd + Up is used instead of Home.
if ((isUp && (!_field->textCursor().atStart()))
// Cmd + Down is used instead of End.
@@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "dialogs/dialogs_widget.h"
#include "dialogs/ui/dialogs_layout.h"
#include "history/history_item_components.h"
#include "history/view/controls/compose_controls_common.h"
#include "history/view/history_view_message.h"
#include "info/profile/info_profile_actions.h"
#include "lang/lang_keys.h"
@@ -300,6 +301,7 @@ void SetupExperimental(
addToggle(ChatHelpers::kOptionUnlimitedRecentStickers);
addToggle(Ui::kOptionHideAiButton);
addToggle(HistoryView::kOptionUnlimitedMessageWidth);
addToggle(HistoryView::Controls::kOptionMacCmdReplyImmediately);
}
} // namespace