mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 22:46:10 +00:00
Copy text with expanded links only to external.
Paste valid custom links in message field if copied from messages.
This commit is contained in:
@@ -120,15 +120,14 @@ QString WithCaptionNotificationText(
|
||||
|
||||
} // namespace
|
||||
|
||||
TextWithEntities WithCaptionClipboardText(
|
||||
TextForMimeData WithCaptionClipboardText(
|
||||
const QString &attachType,
|
||||
TextWithEntities &&caption) {
|
||||
TextWithEntities result;
|
||||
result.text.reserve(5 + attachType.size() + caption.text.size());
|
||||
result.text.append(qstr("[ ")).append(attachType).append(qstr(" ]"));
|
||||
if (!caption.text.isEmpty()) {
|
||||
result.text.append(qstr("\n"));
|
||||
TextUtilities::Append(result, std::move(caption));
|
||||
TextForMimeData &&caption) {
|
||||
auto result = TextForMimeData();
|
||||
result.reserve(5 + attachType.size() + caption.expanded.size());
|
||||
result.append(qstr("[ ")).append(attachType).append(qstr(" ]"));
|
||||
if (!caption.empty()) {
|
||||
result.append('\n').append(std::move(caption));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -321,7 +320,7 @@ QString MediaPhoto::pinnedTextSubstring() const {
|
||||
return lang(lng_action_pinned_media_photo);
|
||||
}
|
||||
|
||||
TextWithEntities MediaPhoto::clipboardText() const {
|
||||
TextForMimeData MediaPhoto::clipboardText() const {
|
||||
return WithCaptionClipboardText(
|
||||
lang(lng_in_dlg_photo),
|
||||
parent()->clipboardText());
|
||||
@@ -629,7 +628,7 @@ QString MediaFile::pinnedTextSubstring() const {
|
||||
return lang(lng_action_pinned_media_file);
|
||||
}
|
||||
|
||||
TextWithEntities MediaFile::clipboardText() const {
|
||||
TextForMimeData MediaFile::clipboardText() const {
|
||||
const auto attachType = [&] {
|
||||
const auto name = _document->composeNameString();
|
||||
const auto addName = !name.isEmpty()
|
||||
@@ -816,7 +815,7 @@ QString MediaContact::pinnedTextSubstring() const {
|
||||
return lang(lng_action_pinned_media_contact);
|
||||
}
|
||||
|
||||
TextWithEntities MediaContact::clipboardText() const {
|
||||
TextForMimeData MediaContact::clipboardText() const {
|
||||
const auto text = qsl("[ ") + lang(lng_in_dlg_contact) + qsl(" ]\n")
|
||||
+ lng_full_name(
|
||||
lt_first_name,
|
||||
@@ -825,7 +824,7 @@ TextWithEntities MediaContact::clipboardText() const {
|
||||
_contact.lastName).trimmed()
|
||||
+ '\n'
|
||||
+ _contact.phoneNumber;
|
||||
return { text, EntitiesInText() };
|
||||
return TextForMimeData::Simple(text);
|
||||
}
|
||||
|
||||
bool MediaContact::updateInlineResultMedia(const MTPMessageMedia &media) {
|
||||
@@ -900,26 +899,22 @@ QString MediaLocation::pinnedTextSubstring() const {
|
||||
return lang(lng_action_pinned_media_location);
|
||||
}
|
||||
|
||||
TextWithEntities MediaLocation::clipboardText() const {
|
||||
TextWithEntities result = {
|
||||
qsl("[ ") + lang(lng_maps_point) + qsl(" ]\n"),
|
||||
EntitiesInText()
|
||||
};
|
||||
TextForMimeData MediaLocation::clipboardText() const {
|
||||
auto result = TextForMimeData::Simple(
|
||||
qstr("[ ") + lang(lng_maps_point) + qstr(" ]\n"));
|
||||
auto titleResult = TextUtilities::ParseEntities(
|
||||
TextUtilities::Clean(_title),
|
||||
Ui::WebpageTextTitleOptions().flags);
|
||||
auto descriptionResult = TextUtilities::ParseEntities(
|
||||
TextUtilities::Clean(_description),
|
||||
TextParseLinks | TextParseMultiline | TextParseRichText);
|
||||
if (!titleResult.text.isEmpty()) {
|
||||
TextUtilities::Append(result, std::move(titleResult));
|
||||
result.text.append('\n');
|
||||
if (!titleResult.empty()) {
|
||||
result.append(std::move(titleResult));
|
||||
}
|
||||
if (!descriptionResult.text.isEmpty()) {
|
||||
TextUtilities::Append(result, std::move(descriptionResult));
|
||||
result.text.append('\n');
|
||||
result.append(std::move(descriptionResult));
|
||||
}
|
||||
result.text += LocationClickHandler(_location->coords).dragText();
|
||||
result.append(LocationClickHandler(_location->coords).dragText());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -972,8 +967,9 @@ QString MediaCall::pinnedTextSubstring() const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
TextWithEntities MediaCall::clipboardText() const {
|
||||
return { qsl("[ ") + notificationText() + qsl(" ]"), EntitiesInText() };
|
||||
TextForMimeData MediaCall::clipboardText() const {
|
||||
return TextForMimeData::Simple(
|
||||
qstr("[ ") + notificationText() + qstr(" ]"));
|
||||
}
|
||||
|
||||
bool MediaCall::allowsForward() const {
|
||||
@@ -1071,8 +1067,8 @@ QString MediaWebPage::pinnedTextSubstring() const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
TextWithEntities MediaWebPage::clipboardText() const {
|
||||
return TextWithEntities();
|
||||
TextForMimeData MediaWebPage::clipboardText() const {
|
||||
return TextForMimeData();
|
||||
}
|
||||
|
||||
bool MediaWebPage::allowsEdit() const {
|
||||
@@ -1145,8 +1141,8 @@ QString MediaGame::pinnedTextSubstring() const {
|
||||
return lng_action_pinned_media_game(lt_game, title);
|
||||
}
|
||||
|
||||
TextWithEntities MediaGame::clipboardText() const {
|
||||
return TextWithEntities();
|
||||
TextForMimeData MediaGame::clipboardText() const {
|
||||
return TextForMimeData();
|
||||
}
|
||||
|
||||
QString MediaGame::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
@@ -1228,8 +1224,8 @@ QString MediaInvoice::pinnedTextSubstring() const {
|
||||
return QString();
|
||||
}
|
||||
|
||||
TextWithEntities MediaInvoice::clipboardText() const {
|
||||
return TextWithEntities();
|
||||
TextForMimeData MediaInvoice::clipboardText() const {
|
||||
return TextForMimeData();
|
||||
}
|
||||
|
||||
bool MediaInvoice::updateInlineResultMedia(const MTPMessageMedia &media) {
|
||||
@@ -1272,12 +1268,12 @@ QString MediaPoll::pinnedTextSubstring() const {
|
||||
return QChar(171) + _poll->question + QChar(187);
|
||||
}
|
||||
|
||||
TextWithEntities MediaPoll::clipboardText() const {
|
||||
const auto text = qsl("[ ")
|
||||
TextForMimeData MediaPoll::clipboardText() const {
|
||||
const auto text = qstr("[ ")
|
||||
+ lang(lng_in_dlg_poll)
|
||||
+ qsl(" : ")
|
||||
+ qstr(" : ")
|
||||
+ _poll->question
|
||||
+ qsl(" ]")
|
||||
+ qstr(" ]")
|
||||
+ ranges::accumulate(
|
||||
ranges::view::all(
|
||||
_poll->answers
|
||||
@@ -1285,7 +1281,7 @@ TextWithEntities MediaPoll::clipboardText() const {
|
||||
return "\n- " + answer.text;
|
||||
}),
|
||||
QString());
|
||||
return { text, EntitiesInText() };
|
||||
return TextForMimeData::Simple(text);
|
||||
}
|
||||
|
||||
QString MediaPoll::errorTextForForward(not_null<PeerData*> peer) const {
|
||||
|
@@ -89,7 +89,7 @@ public:
|
||||
virtual QString chatListText() const;
|
||||
virtual QString notificationText() const = 0;
|
||||
virtual QString pinnedTextSubstring() const = 0;
|
||||
virtual TextWithEntities clipboardText() const = 0;
|
||||
virtual TextForMimeData clipboardText() const = 0;
|
||||
virtual bool allowsForward() const;
|
||||
virtual bool allowsEdit() const;
|
||||
virtual bool allowsEditCaption() const;
|
||||
@@ -140,7 +140,7 @@ public:
|
||||
QString chatListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
bool allowsEditCaption() const override;
|
||||
bool allowsEditMedia() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
@@ -176,7 +176,7 @@ public:
|
||||
QString chatListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
bool allowsEditCaption() const override;
|
||||
bool allowsEditMedia() const override;
|
||||
bool forwardedBecomesUnread() const override;
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
const SharedContact *sharedContact() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
@@ -239,7 +239,7 @@ public:
|
||||
QString chatListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
@@ -265,7 +265,7 @@ public:
|
||||
const Call *call() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
bool allowsForward() const override;
|
||||
bool allowsRevoke() const override;
|
||||
|
||||
@@ -302,7 +302,7 @@ public:
|
||||
QString chatListText() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
bool allowsEdit() const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
Image *replyPreview() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
|
||||
bool consumeMessageText(const TextWithEntities &text) override;
|
||||
@@ -365,7 +365,7 @@ public:
|
||||
Image *replyPreview() const override;
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
bool updateSentMedia(const MTPMessageMedia &media) override;
|
||||
@@ -391,7 +391,7 @@ public:
|
||||
|
||||
QString notificationText() const override;
|
||||
QString pinnedTextSubstring() const override;
|
||||
TextWithEntities clipboardText() const override;
|
||||
TextForMimeData clipboardText() const override;
|
||||
QString errorTextForForward(not_null<PeerData*> peer) const override;
|
||||
|
||||
bool updateInlineResultMedia(const MTPMessageMedia &media) override;
|
||||
@@ -405,8 +405,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
TextWithEntities WithCaptionClipboardText(
|
||||
TextForMimeData WithCaptionClipboardText(
|
||||
const QString &attachType,
|
||||
TextWithEntities &&caption);
|
||||
TextForMimeData &&caption);
|
||||
|
||||
} // namespace Data
|
||||
|
Reference in New Issue
Block a user