mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 13:47:05 +02:00
Partially (italic+colored) support blockquotes.
This commit is contained in:
parent
859e41f95a
commit
d5147c9d28
9 changed files with 40 additions and 3 deletions
|
@ -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";
|
||||
|
|
|
@ -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<MTPMessageEntity> 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<MTPMessageEntity> 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())) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
QAction *psItalic = nullptr;
|
||||
QAction *psUnderline = nullptr;
|
||||
QAction *psStrikeOut = nullptr;
|
||||
QAction *psBlockquote = nullptr;
|
||||
QAction *psMonospace = nullptr;
|
||||
QAction *psClearFormat = nullptr;
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ private:
|
|||
QAction *psItalic = nullptr;
|
||||
QAction *psUnderline = nullptr;
|
||||
QAction *psStrikeOut = nullptr;
|
||||
QAction *psBlockquote = nullptr;
|
||||
QAction *psMonospace = nullptr;
|
||||
QAction *psClearFormat = nullptr;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue