diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 1572839ca..aca64ad73 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2759,6 +2759,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_menu_formatting_italic" = "Italic"; "lng_menu_formatting_underline" = "Underline"; "lng_menu_formatting_strike_out" = "Strike-through"; +"lng_menu_formatting_blockquote" = "Quote"; "lng_menu_formatting_monospace" = "Monospace"; "lng_menu_formatting_spoiler" = "Spoiler"; "lng_menu_formatting_link_create" = "Create link"; diff --git a/Telegram/SourceFiles/api/api_text_entities.cpp b/Telegram/SourceFiles/api/api_text_entities.cpp index 1bfe1142f..6c434bc9b 100644 --- a/Telegram/SourceFiles/api/api_text_entities.cpp +++ b/Telegram/SourceFiles/api/api_text_entities.cpp @@ -114,6 +114,7 @@ EntitiesInText EntitiesFromMTP( case mtpc_messageEntityStrike: { auto &d = entity.c_messageEntityStrike(); result.push_back({ EntityType::StrikeOut, d.voffset().v, d.vlength().v }); } break; case mtpc_messageEntityCode: { auto &d = entity.c_messageEntityCode(); result.push_back({ EntityType::Code, d.voffset().v, d.vlength().v }); } break; case mtpc_messageEntityPre: { auto &d = entity.c_messageEntityPre(); result.push_back({ EntityType::Pre, d.voffset().v, d.vlength().v, qs(d.vlanguage()) }); } break; + case mtpc_messageEntityBlockquote: { auto &d = entity.c_messageEntityBlockquote(); result.push_back({ EntityType::Blockquote, d.voffset().v, d.vlength().v }); } break; case mtpc_messageEntityBankCard: break; // Skipping cards. // #TODO entities case mtpc_messageEntitySpoiler: { auto &d = entity.c_messageEntitySpoiler(); result.push_back({ EntityType::Spoiler, d.voffset().v, d.vlength().v }); } break; case mtpc_messageEntityCustomEmoji: { @@ -142,6 +143,7 @@ MTPVector EntitiesToMTP( && entity.type() != EntityType::StrikeOut && entity.type() != EntityType::Code // #TODO entities && entity.type() != EntityType::Pre + && entity.type() != EntityType::Blockquote && entity.type() != EntityType::Spoiler && entity.type() != EntityType::MentionName && entity.type() != EntityType::CustomUrl @@ -170,6 +172,7 @@ MTPVector EntitiesToMTP( case EntityType::StrikeOut: v.push_back(MTP_messageEntityStrike(offset, length)); break; case EntityType::Code: v.push_back(MTP_messageEntityCode(offset, length)); break; // #TODO entities case EntityType::Pre: v.push_back(MTP_messageEntityPre(offset, length, MTP_string(entity.data()))); break; + case EntityType::Blockquote: v.push_back(MTP_messageEntityBlockquote(offset, length)); break; case EntityType::Spoiler: v.push_back(MTP_messageEntitySpoiler(offset, length)); break; case EntityType::CustomEmoji: { if (const auto valid = CustomEmojiEntity(offset, length, entity.data())) { diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp index 1fe33e654..24a8bbee2 100644 --- a/Telegram/SourceFiles/core/ui_integration.cpp +++ b/Telegram/SourceFiles/core/ui_integration.cpp @@ -348,6 +348,10 @@ QString UiIntegration::phraseFormattingStrikeOut() { return tr::lng_menu_formatting_strike_out(tr::now); } +QString UiIntegration::phraseFormattingBlockquote() { + return tr::lng_menu_formatting_blockquote(tr::now); +} + QString UiIntegration::phraseFormattingMonospace() { return tr::lng_menu_formatting_monospace(tr::now); } diff --git a/Telegram/SourceFiles/core/ui_integration.h b/Telegram/SourceFiles/core/ui_integration.h index 0515c732f..4e23a63db 100644 --- a/Telegram/SourceFiles/core/ui_integration.h +++ b/Telegram/SourceFiles/core/ui_integration.h @@ -77,6 +77,7 @@ public: QString phraseFormattingItalic() override; QString phraseFormattingUnderline() override; QString phraseFormattingStrikeOut() override; + QString phraseFormattingBlockquote() override; QString phraseFormattingMonospace() override; QString phraseFormattingSpoiler() override; QString phraseButtonOk() override; diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp index 7fec6ec89..f4c400f32 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.cpp @@ -373,6 +373,15 @@ void MainWindow::createGlobalMenu() { }, Ui::kStrikeOutSequence); + psBlockquote = edit->addAction( + tr::lng_menu_formatting_blockquote(tr::now), + [] { + SendKeySequence( + Qt::Key_Period, + Qt::ControlModifier | Qt::ShiftModifier); + }, + Ui::kBlockquoteSequence); + psMonospace = edit->addAction( tr::lng_menu_formatting_monospace(tr::now), [] { @@ -534,6 +543,7 @@ void MainWindow::updateGlobalMenuHook() { ForceDisabled(psItalic, !markdownEnabled); ForceDisabled(psUnderline, !markdownEnabled); ForceDisabled(psStrikeOut, !markdownEnabled); + ForceDisabled(psBlockquote, !markdownEnabled); ForceDisabled(psMonospace, !markdownEnabled); ForceDisabled(psClearFormat, !markdownEnabled); } diff --git a/Telegram/SourceFiles/platform/linux/main_window_linux.h b/Telegram/SourceFiles/platform/linux/main_window_linux.h index 467f690b7..311ed3a74 100644 --- a/Telegram/SourceFiles/platform/linux/main_window_linux.h +++ b/Telegram/SourceFiles/platform/linux/main_window_linux.h @@ -57,6 +57,7 @@ private: QAction *psItalic = nullptr; QAction *psUnderline = nullptr; QAction *psStrikeOut = nullptr; + QAction *psBlockquote = nullptr; QAction *psMonospace = nullptr; QAction *psClearFormat = nullptr; diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.h b/Telegram/SourceFiles/platform/mac/main_window_mac.h index 96c0f49db..36dc140bd 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.h +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.h @@ -78,6 +78,7 @@ private: QAction *psItalic = nullptr; QAction *psUnderline = nullptr; QAction *psStrikeOut = nullptr; + QAction *psBlockquote = nullptr; QAction *psMonospace = nullptr; QAction *psClearFormat = nullptr; diff --git a/Telegram/SourceFiles/platform/mac/main_window_mac.mm b/Telegram/SourceFiles/platform/mac/main_window_mac.mm index e674ec8c8..d30a65809 100644 --- a/Telegram/SourceFiles/platform/mac/main_window_mac.mm +++ b/Telegram/SourceFiles/platform/mac/main_window_mac.mm @@ -406,6 +406,15 @@ void MainWindow::createGlobalMenu() { Qt::ControlModifier | Qt::ShiftModifier); }, Ui::kStrikeOutSequence); + psBlockquote = edit->addAction( + tr::lng_menu_formatting_blockquote(tr::now), + this, + [] { + SendKeySequence( + Qt::Key_Period, + Qt::ControlModifier | Qt::ShiftModifier); + }, + Ui::kBlockquoteSequence); psMonospace = edit->addAction( tr::lng_menu_formatting_monospace(tr::now), this, @@ -550,6 +559,7 @@ void MainWindow::updateGlobalMenuHook() { ForceDisabled(psItalic, !canApplyMarkdown); ForceDisabled(psUnderline, !canApplyMarkdown); ForceDisabled(psStrikeOut, !canApplyMarkdown); + ForceDisabled(psBlockquote, !canApplyMarkdown); ForceDisabled(psMonospace, !canApplyMarkdown); ForceDisabled(psClearFormat, !canApplyMarkdown); } diff --git a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_formatter_item.mm b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_formatter_item.mm index 2d04a140a..c719f7006 100644 --- a/Telegram/SourceFiles/platform/mac/touchbar/items/mac_formatter_item.mm +++ b/Telegram/SourceFiles/platform/mac/touchbar/items/mac_formatter_item.mm @@ -24,9 +24,10 @@ constexpr auto kCommandBold = 0x010; constexpr auto kCommandItalic = 0x011; constexpr auto kCommandUnderline = 0x012; constexpr auto kCommandStrikeOut = 0x013; -constexpr auto kCommandMonospace = 0x014; -constexpr auto kCommandClear = 0x015; -constexpr auto kCommandLink = 0x016; +constexpr auto kCommandBlockquote = 0x014; +constexpr auto kCommandMonospace = 0x015; +constexpr auto kCommandClear = 0x016; +constexpr auto kCommandLink = 0x017; const auto kPopoverFormatter = @"popoverInputFormatter"; @@ -44,6 +45,10 @@ void SendKeyEvent(int command) { case kCommandItalic: key = Qt::Key_I; break; + case kCommandBlockquote: + key = Qt::Key_Period; + modifier |= Qt::ShiftModifier; + break; case kCommandMonospace: key = Qt::Key_M; modifier |= Qt::ShiftModifier; @@ -103,6 +108,7 @@ void SendKeyEvent(int command) { tr::lng_menu_formatting_italic, tr::lng_menu_formatting_underline, tr::lng_menu_formatting_strike_out, + tr::lng_menu_formatting_blockquote, tr::lng_menu_formatting_monospace, tr::lng_menu_formatting_clear, tr::lng_info_link_label,