mirror of https://github.com/procxx/kepka.git
Support markdown and replaces in media captions.
This commit is contained in:
parent
6f6ec217e3
commit
5e7642b42a
|
@ -40,7 +40,7 @@ lineWidth: 1px;
|
||||||
|
|
||||||
defaultTextPalette: TextPalette {
|
defaultTextPalette: TextPalette {
|
||||||
linkFg: windowActiveTextFg;
|
linkFg: windowActiveTextFg;
|
||||||
monoFg: windowSubTextFg;
|
monoFg: msgInMonoFg;
|
||||||
selectBg: msgInBgSelected;
|
selectBg: msgInBgSelected;
|
||||||
selectFg: transparent; // use painter current pen instead
|
selectFg: transparent; // use painter current pen instead
|
||||||
selectLinkFg: historyLinkInFgSelected;
|
selectLinkFg: historyLinkInFgSelected;
|
||||||
|
|
|
@ -3675,7 +3675,7 @@ void ApiWrap::sendVoiceMessage(
|
||||||
VoiceWaveform waveform,
|
VoiceWaveform waveform,
|
||||||
int duration,
|
int duration,
|
||||||
const SendOptions &options) {
|
const SendOptions &options) {
|
||||||
const auto caption = QString();
|
const auto caption = TextWithTags();
|
||||||
const auto to = FileLoadTaskOptions(options);
|
const auto to = FileLoadTaskOptions(options);
|
||||||
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
||||||
result,
|
result,
|
||||||
|
@ -3688,16 +3688,16 @@ void ApiWrap::sendVoiceMessage(
|
||||||
void ApiWrap::sendFiles(
|
void ApiWrap::sendFiles(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
QString caption,
|
TextWithTags &&caption,
|
||||||
std::shared_ptr<SendingAlbum> album,
|
std::shared_ptr<SendingAlbum> album,
|
||||||
const SendOptions &options) {
|
const SendOptions &options) {
|
||||||
if (list.files.size() > 1 && !caption.isEmpty()) {
|
if (list.files.size() > 1 && !caption.text.isEmpty()) {
|
||||||
auto message = MainWidget::MessageToSend(options.history);
|
auto message = MainWidget::MessageToSend(options.history);
|
||||||
message.textWithTags = { caption, TextWithTags::Tags() };
|
message.textWithTags = std::move(caption);
|
||||||
message.replyTo = options.replyTo;
|
message.replyTo = options.replyTo;
|
||||||
message.clearDraft = false;
|
message.clearDraft = false;
|
||||||
App::main()->sendMessage(message);
|
App::main()->sendMessage(message);
|
||||||
caption = QString();
|
caption = TextWithTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto to = FileLoadTaskOptions(options);
|
const auto to = FileLoadTaskOptions(options);
|
||||||
|
@ -3742,7 +3742,7 @@ void ApiWrap::sendFile(
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
const SendOptions &options) {
|
const SendOptions &options) {
|
||||||
auto to = FileLoadTaskOptions(options);
|
auto to = FileLoadTaskOptions(options);
|
||||||
auto caption = QString();
|
auto caption = TextWithTags();
|
||||||
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
_fileLoader->addTask(std::make_unique<FileLoadTask>(
|
||||||
QString(),
|
QString(),
|
||||||
fileContent,
|
fileContent,
|
||||||
|
|
|
@ -253,7 +253,7 @@ public:
|
||||||
void sendFiles(
|
void sendFiles(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
QString caption,
|
TextWithTags &&caption,
|
||||||
std::shared_ptr<SendingAlbum> album,
|
std::shared_ptr<SendingAlbum> album,
|
||||||
const SendOptions &options);
|
const SendOptions &options);
|
||||||
void sendFile(
|
void sendFile(
|
||||||
|
|
|
@ -329,6 +329,9 @@ void GroupInfoBox::prepare() {
|
||||||
langFactory(lng_create_group_description));
|
langFactory(lng_create_group_description));
|
||||||
_description->show();
|
_description->show();
|
||||||
_description->setMaxLength(kMaxChannelDescription);
|
_description->setMaxLength(kMaxChannelDescription);
|
||||||
|
_description->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_description->setInstantReplacesEnabled(
|
||||||
|
Global::ReplaceEmojiValue());
|
||||||
|
|
||||||
connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
|
connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
|
||||||
connect(_description, SIGNAL(submitted(bool)), this, SLOT(onNext()));
|
connect(_description, SIGNAL(submitted(bool)), this, SLOT(onNext()));
|
||||||
|
@ -1080,6 +1083,7 @@ void EditBioBox::prepare() {
|
||||||
connect(_bio, &Ui::InputField::resized, this, [this] { updateMaxHeight(); });
|
connect(_bio, &Ui::InputField::resized, this, [this] { updateMaxHeight(); });
|
||||||
connect(_bio, &Ui::InputField::changed, this, [this] { handleBioUpdated(); });
|
connect(_bio, &Ui::InputField::changed, this, [this] { handleBioUpdated(); });
|
||||||
_bio->setInstantReplaces(Ui::InstantReplaces::Default());
|
_bio->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_bio->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
handleBioUpdated();
|
handleBioUpdated();
|
||||||
updateMaxHeight();
|
updateMaxHeight();
|
||||||
}
|
}
|
||||||
|
@ -1161,6 +1165,8 @@ void EditChannelBox::prepare() {
|
||||||
|
|
||||||
_title->setMaxLength(kMaxGroupChannelTitle);
|
_title->setMaxLength(kMaxGroupChannelTitle);
|
||||||
_description->setMaxLength(kMaxChannelDescription);
|
_description->setMaxLength(kMaxChannelDescription);
|
||||||
|
_description->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_description->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
|
|
||||||
connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
|
connect(_description, SIGNAL(resized()), this, SLOT(onDescriptionResized()));
|
||||||
connect(_description, SIGNAL(submitted(bool)), this, SLOT(onSave()));
|
connect(_description, SIGNAL(submitted(bool)), this, SLOT(onSave()));
|
||||||
|
|
|
@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_photo.h"
|
#include "data/data_photo.h"
|
||||||
#include "data/data_document.h"
|
#include "data/data_document.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
|
#include "chat_helpers/message_field.h"
|
||||||
#include "window/window_controller.h"
|
#include "window/window_controller.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "layout.h"
|
#include "layout.h"
|
||||||
|
@ -50,7 +51,11 @@ EditCaptionBox::EditCaptionBox(
|
||||||
}
|
}
|
||||||
doc = document;
|
doc = document;
|
||||||
}
|
}
|
||||||
auto caption = item->originalText().text;
|
const auto original = item->originalText();
|
||||||
|
const auto editData = TextWithTags {
|
||||||
|
original.text,
|
||||||
|
ConvertEntitiesToTextTags(original.entities)
|
||||||
|
};
|
||||||
|
|
||||||
if (!_animated && (dimensions.isEmpty() || doc || image->isNull())) {
|
if (!_animated && (dimensions.isEmpty() || doc || image->isNull())) {
|
||||||
if (image->isNull()) {
|
if (image->isNull()) {
|
||||||
|
@ -135,10 +140,12 @@ EditCaptionBox::EditCaptionBox(
|
||||||
st::confirmCaptionArea,
|
st::confirmCaptionArea,
|
||||||
Ui::InputField::Mode::MultiLine,
|
Ui::InputField::Mode::MultiLine,
|
||||||
langFactory(lng_photo_caption),
|
langFactory(lng_photo_caption),
|
||||||
caption);
|
editData);
|
||||||
_field->setMaxLength(MaxPhotoCaption);
|
_field->setMaxLength(MaxPhotoCaption);
|
||||||
_field->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
|
_field->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
|
||||||
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
_field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_field->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
|
_field->setMarkdownReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditCaptionBox::prepareGifPreview(DocumentData *document) {
|
void EditCaptionBox::prepareGifPreview(DocumentData *document) {
|
||||||
|
@ -338,17 +345,29 @@ void EditCaptionBox::save() {
|
||||||
if (_previewCancelled) {
|
if (_previewCancelled) {
|
||||||
flags |= MTPmessages_EditMessage::Flag::f_no_webpage;
|
flags |= MTPmessages_EditMessage::Flag::f_no_webpage;
|
||||||
}
|
}
|
||||||
MTPVector<MTPMessageEntity> sentEntities;
|
const auto textWithTags = _field->getTextWithTags();
|
||||||
|
auto sending = TextWithEntities{
|
||||||
|
textWithTags.text,
|
||||||
|
ConvertTextTagsToEntities(textWithTags.tags)
|
||||||
|
};
|
||||||
|
const auto prepareFlags = Ui::ItemTextOptions(
|
||||||
|
item->history(),
|
||||||
|
App::self()).flags;
|
||||||
|
TextUtilities::PrepareForSending(sending, prepareFlags);
|
||||||
|
TextUtilities::Trim(sending);
|
||||||
|
|
||||||
|
const auto sentEntities = TextUtilities::EntitiesToMTP(
|
||||||
|
sending.entities,
|
||||||
|
TextUtilities::ConvertOption::SkipLocal);
|
||||||
if (!sentEntities.v.isEmpty()) {
|
if (!sentEntities.v.isEmpty()) {
|
||||||
flags |= MTPmessages_EditMessage::Flag::f_entities;
|
flags |= MTPmessages_EditMessage::Flag::f_entities;
|
||||||
}
|
}
|
||||||
auto text = TextUtilities::PrepareForSending(_field->getLastText(), TextUtilities::PrepareTextOption::CheckLinks);
|
|
||||||
_saveRequestId = MTP::send(
|
_saveRequestId = MTP::send(
|
||||||
MTPmessages_EditMessage(
|
MTPmessages_EditMessage(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
item->history()->peer->input,
|
item->history()->peer->input,
|
||||||
MTP_int(item->id),
|
MTP_int(item->id),
|
||||||
MTP_string(text),
|
MTP_string(sending.text),
|
||||||
MTPnullMarkup,
|
MTPnullMarkup,
|
||||||
sentEntities,
|
sentEntities,
|
||||||
MTP_inputGeoPointEmpty()),
|
MTP_inputGeoPointEmpty()),
|
||||||
|
|
|
@ -328,6 +328,8 @@ object_ptr<Ui::RpWidget> Controller::createDescriptionEdit() {
|
||||||
st::editPeerDescriptionMargins);
|
st::editPeerDescriptionMargins);
|
||||||
result->entity()->setMaxLength(kMaxChannelDescription);
|
result->entity()->setMaxLength(kMaxChannelDescription);
|
||||||
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
result->entity()->setInstantReplacesEnabled(
|
||||||
|
Global::ReplaceEmojiValue());
|
||||||
|
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
result->entity(),
|
result->entity(),
|
||||||
|
|
|
@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "storage/storage_media_prepare.h"
|
#include "storage/storage_media_prepare.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "history/history_media_types.h"
|
#include "history/history_media_types.h"
|
||||||
|
#include "chat_helpers/message_field.h"
|
||||||
#include "core/file_utilities.h"
|
#include "core/file_utilities.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -1578,6 +1579,8 @@ void SendFilesBox::setupCaption() {
|
||||||
Unexpected("action in MimeData hook.");
|
Unexpected("action in MimeData hook.");
|
||||||
});
|
});
|
||||||
_caption->setInstantReplaces(Ui::InstantReplaces::Default());
|
_caption->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_caption->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
|
_caption->setMarkdownReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFilesBox::captionResized() {
|
void SendFilesBox::captionResized() {
|
||||||
|
@ -1789,10 +1792,8 @@ void SendFilesBox::send(bool ctrlShiftEnter) {
|
||||||
_confirmed = true;
|
_confirmed = true;
|
||||||
if (_confirmedCallback) {
|
if (_confirmedCallback) {
|
||||||
auto caption = _caption
|
auto caption = _caption
|
||||||
? TextUtilities::PrepareForSending(
|
? _caption->getTextWithTags()
|
||||||
_caption->getLastText(),
|
: TextWithTags();
|
||||||
TextUtilities::PrepareTextOption::CheckLinks)
|
|
||||||
: QString();
|
|
||||||
_confirmedCallback(
|
_confirmedCallback(
|
||||||
std::move(_list),
|
std::move(_list),
|
||||||
way,
|
way,
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
base::lambda<void(
|
base::lambda<void(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendFilesWay way,
|
SendFilesWay way,
|
||||||
const QString &caption,
|
TextWithTags &&caption,
|
||||||
bool ctrlShiftEnter)> callback) {
|
bool ctrlShiftEnter)> callback) {
|
||||||
_confirmedCallback = std::move(callback);
|
_confirmedCallback = std::move(callback);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ private:
|
||||||
base::lambda<void(
|
base::lambda<void(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendFilesWay way,
|
SendFilesWay way,
|
||||||
const QString &caption,
|
TextWithTags &&caption,
|
||||||
bool ctrlShiftEnter)> _confirmedCallback;
|
bool ctrlShiftEnter)> _confirmedCallback;
|
||||||
base::lambda<void()> _cancelledCallback;
|
base::lambda<void()> _cancelledCallback;
|
||||||
bool _confirmed = false;
|
bool _confirmed = false;
|
||||||
|
|
|
@ -146,14 +146,8 @@ void InitMessageField(not_null<Ui::InputField*> field) {
|
||||||
|
|
||||||
field->customTab(true);
|
field->customTab(true);
|
||||||
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
field->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
field->enableInstantReplaces(Global::ReplaceEmoji());
|
field->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
field->enableMarkdownSupport(Global::ReplaceEmoji());
|
field->setMarkdownReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
auto &changed = Global::RefReplaceEmojiChanged();
|
|
||||||
Ui::AttachAsChild(field, changed.add_subscription([=] {
|
|
||||||
field->enableInstantReplaces(Global::ReplaceEmoji());
|
|
||||||
field->enableMarkdownSupport(Global::ReplaceEmoji());
|
|
||||||
}));
|
|
||||||
field->window()->activateWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasSendText(not_null<const Ui::InputField*> field) {
|
bool HasSendText(not_null<const Ui::InputField*> field) {
|
||||||
|
|
|
@ -711,4 +711,14 @@ DefineRefVar(Global, base::Variable<DBIWorkMode>, WorkMode);
|
||||||
DefineRefVar(Global, base::Observable<void>, UnreadCounterUpdate);
|
DefineRefVar(Global, base::Observable<void>, UnreadCounterUpdate);
|
||||||
DefineRefVar(Global, base::Observable<void>, PeerChooseCancel);
|
DefineRefVar(Global, base::Observable<void>, PeerChooseCancel);
|
||||||
|
|
||||||
|
rpl::producer<bool> ReplaceEmojiValue() {
|
||||||
|
return rpl::single(
|
||||||
|
Global::ReplaceEmoji()
|
||||||
|
) | rpl::then(base::ObservableViewer(
|
||||||
|
Global::RefReplaceEmojiChanged()
|
||||||
|
) | rpl::map([] {
|
||||||
|
return Global::ReplaceEmoji();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Global
|
} // namespace Global
|
||||||
|
|
|
@ -391,6 +391,8 @@ DeclareRefVar(base::Variable<DBIWorkMode>, WorkMode);
|
||||||
DeclareRefVar(base::Observable<void>, UnreadCounterUpdate);
|
DeclareRefVar(base::Observable<void>, UnreadCounterUpdate);
|
||||||
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
|
DeclareRefVar(base::Observable<void>, PeerChooseCancel);
|
||||||
|
|
||||||
|
rpl::producer<bool> ReplaceEmojiValue();
|
||||||
|
|
||||||
} // namespace Global
|
} // namespace Global
|
||||||
|
|
||||||
namespace Adaptive {
|
namespace Adaptive {
|
||||||
|
|
|
@ -4167,7 +4167,7 @@ bool HistoryWidget::confirmSendingFiles(
|
||||||
box->setConfirmedCallback(base::lambda_guarded(this, [=](
|
box->setConfirmedCallback(base::lambda_guarded(this, [=](
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendFilesWay way,
|
SendFilesWay way,
|
||||||
const QString &caption,
|
TextWithTags &&caption,
|
||||||
bool ctrlShiftEnter) {
|
bool ctrlShiftEnter) {
|
||||||
if (showSendingFilesError(list)) {
|
if (showSendingFilesError(list)) {
|
||||||
return;
|
return;
|
||||||
|
@ -4181,7 +4181,7 @@ bool HistoryWidget::confirmSendingFiles(
|
||||||
uploadFilesAfterConfirmation(
|
uploadFilesAfterConfirmation(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
type,
|
type,
|
||||||
caption,
|
std::move(caption),
|
||||||
replyToId(),
|
replyToId(),
|
||||||
album);
|
album);
|
||||||
}));
|
}));
|
||||||
|
@ -4282,18 +4282,17 @@ void HistoryWidget::uploadFiles(
|
||||||
SendMediaType type) {
|
SendMediaType type) {
|
||||||
ActivateWindowDelayed(controller());
|
ActivateWindowDelayed(controller());
|
||||||
|
|
||||||
auto caption = QString();
|
|
||||||
uploadFilesAfterConfirmation(
|
uploadFilesAfterConfirmation(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
type,
|
type,
|
||||||
caption,
|
TextWithTags(),
|
||||||
replyToId());
|
replyToId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::uploadFilesAfterConfirmation(
|
void HistoryWidget::uploadFilesAfterConfirmation(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
QString caption,
|
TextWithTags &&caption,
|
||||||
MsgId replyTo,
|
MsgId replyTo,
|
||||||
std::shared_ptr<SendingAlbum> album) {
|
std::shared_ptr<SendingAlbum> album) {
|
||||||
Assert(canWriteMessage());
|
Assert(canWriteMessage());
|
||||||
|
@ -4303,7 +4302,7 @@ void HistoryWidget::uploadFilesAfterConfirmation(
|
||||||
Auth().api().sendFiles(
|
Auth().api().sendFiles(
|
||||||
std::move(list),
|
std::move(list),
|
||||||
type,
|
type,
|
||||||
caption,
|
std::move(caption),
|
||||||
album,
|
album,
|
||||||
options);
|
options);
|
||||||
}
|
}
|
||||||
|
@ -4356,8 +4355,23 @@ void HistoryWidget::sendFileConfirmed(
|
||||||
options.generateLocal = true;
|
options.generateLocal = true;
|
||||||
Auth().api().sendAction(options);
|
Auth().api().sendAction(options);
|
||||||
|
|
||||||
auto flags = NewMessageFlags(peer) | MTPDmessage::Flag::f_media;
|
auto caption = TextWithEntities{
|
||||||
if (file->to.replyTo) flags |= MTPDmessage::Flag::f_reply_to_msg_id;
|
file->caption.text,
|
||||||
|
ConvertTextTagsToEntities(file->caption.tags)
|
||||||
|
};
|
||||||
|
const auto prepareFlags = Ui::ItemTextOptions(
|
||||||
|
history,
|
||||||
|
App::self()).flags;
|
||||||
|
TextUtilities::PrepareForSending(caption, prepareFlags);
|
||||||
|
TextUtilities::Trim(caption);
|
||||||
|
auto localEntities = TextUtilities::EntitiesToMTP(caption.entities);
|
||||||
|
|
||||||
|
auto flags = NewMessageFlags(peer)
|
||||||
|
| MTPDmessage::Flag::f_entities
|
||||||
|
| MTPDmessage::Flag::f_media;
|
||||||
|
if (file->to.replyTo) {
|
||||||
|
flags |= MTPDmessage::Flag::f_reply_to_msg_id;
|
||||||
|
}
|
||||||
bool channelPost = peer->isChannel() && !peer->isMegagroup();
|
bool channelPost = peer->isChannel() && !peer->isMegagroup();
|
||||||
bool silentPost = channelPost && file->to.silent;
|
bool silentPost = channelPost && file->to.silent;
|
||||||
if (channelPost) {
|
if (channelPost) {
|
||||||
|
@ -4393,10 +4407,10 @@ void HistoryWidget::sendFileConfirmed(
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_int(file->to.replyTo),
|
MTP_int(file->to.replyTo),
|
||||||
MTP_int(unixtime()),
|
MTP_int(unixtime()),
|
||||||
MTP_string(file->caption),
|
MTP_string(caption.text),
|
||||||
photo,
|
photo,
|
||||||
MTPnullMarkup,
|
MTPnullMarkup,
|
||||||
MTPnullEntities, // #TODO caption entities
|
localEntities,
|
||||||
MTP_int(1),
|
MTP_int(1),
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_string(messagePostAuthor),
|
MTP_string(messagePostAuthor),
|
||||||
|
@ -4418,10 +4432,10 @@ void HistoryWidget::sendFileConfirmed(
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_int(file->to.replyTo),
|
MTP_int(file->to.replyTo),
|
||||||
MTP_int(unixtime()),
|
MTP_int(unixtime()),
|
||||||
MTP_string(file->caption),
|
MTP_string(caption.text),
|
||||||
document,
|
document,
|
||||||
MTPnullMarkup,
|
MTPnullMarkup,
|
||||||
MTPnullEntities, // #TODO caption entities
|
localEntities,
|
||||||
MTP_int(1),
|
MTP_int(1),
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_string(messagePostAuthor),
|
MTP_string(messagePostAuthor),
|
||||||
|
@ -4446,10 +4460,10 @@ void HistoryWidget::sendFileConfirmed(
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_int(file->to.replyTo),
|
MTP_int(file->to.replyTo),
|
||||||
MTP_int(unixtime()),
|
MTP_int(unixtime()),
|
||||||
MTP_string(file->caption),
|
MTP_string(caption.text),
|
||||||
document,
|
document,
|
||||||
MTPnullMarkup,
|
MTPnullMarkup,
|
||||||
MTPnullEntities, // #TODO caption entities
|
localEntities,
|
||||||
MTP_int(1),
|
MTP_int(1),
|
||||||
MTPint(),
|
MTPint(),
|
||||||
MTP_string(messagePostAuthor),
|
MTP_string(messagePostAuthor),
|
||||||
|
|
|
@ -516,7 +516,7 @@ private:
|
||||||
void uploadFilesAfterConfirmation(
|
void uploadFilesAfterConfirmation(
|
||||||
Storage::PreparedList &&list,
|
Storage::PreparedList &&list,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
QString caption,
|
TextWithTags &&caption,
|
||||||
MsgId replyTo,
|
MsgId replyTo,
|
||||||
std::shared_ptr<SendingAlbum> album = nullptr);
|
std::shared_ptr<SendingAlbum> album = nullptr);
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@ mediaviewSaveMsgStyle: TextStyle(defaultTextStyle) {
|
||||||
}
|
}
|
||||||
mediaviewTextPalette: TextPalette(defaultTextPalette) {
|
mediaviewTextPalette: TextPalette(defaultTextPalette) {
|
||||||
linkFg: mediaviewTextLinkFg;
|
linkFg: mediaviewTextLinkFg;
|
||||||
|
monoFg: mediaviewCaptionFg;
|
||||||
}
|
}
|
||||||
|
|
||||||
mediaviewCaptionStyle: defaultTextStyle;
|
mediaviewCaptionStyle: defaultTextStyle;
|
||||||
|
|
|
@ -101,7 +101,10 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm);
|
||||||
const auto notificationReply = QString::fromUtf8([[[notification response] string] UTF8String]);
|
const auto notificationReply = QString::fromUtf8([[[notification response] string] UTF8String]);
|
||||||
const auto manager = _manager;
|
const auto manager = _manager;
|
||||||
crl::on_main(manager, [=] {
|
crl::on_main(manager, [=] {
|
||||||
manager->notificationReplied(notificationPeerId, notificationMsgId, notificationReply);
|
manager->notificationReplied(
|
||||||
|
notificationPeerId,
|
||||||
|
notificationMsgId,
|
||||||
|
{ notificationReply, {} });
|
||||||
});
|
});
|
||||||
} else if (notification.activationType == NSUserNotificationActivationTypeContentsClicked) {
|
} else if (notification.activationType == NSUserNotificationActivationTypeContentsClicked) {
|
||||||
const auto manager = _manager;
|
const auto manager = _manager;
|
||||||
|
|
|
@ -178,7 +178,7 @@ FileLoadResult::FileLoadResult(
|
||||||
TaskId taskId,
|
TaskId taskId,
|
||||||
uint64 id,
|
uint64 id,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption,
|
const TextWithTags &caption,
|
||||||
std::shared_ptr<SendingAlbum> album)
|
std::shared_ptr<SendingAlbum> album)
|
||||||
: taskId(taskId)
|
: taskId(taskId)
|
||||||
, id(id)
|
, id(id)
|
||||||
|
@ -193,7 +193,7 @@ FileLoadTask::FileLoadTask(
|
||||||
std::unique_ptr<FileMediaInformation> information,
|
std::unique_ptr<FileMediaInformation> information,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption,
|
const TextWithTags &caption,
|
||||||
std::shared_ptr<SendingAlbum> album)
|
std::shared_ptr<SendingAlbum> album)
|
||||||
: _id(rand_value<uint64>())
|
: _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
|
@ -210,7 +210,7 @@ FileLoadTask::FileLoadTask(
|
||||||
int32 duration,
|
int32 duration,
|
||||||
const VoiceWaveform &waveform,
|
const VoiceWaveform &waveform,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption)
|
const TextWithTags &caption)
|
||||||
: _id(rand_value<uint64>())
|
: _id(rand_value<uint64>())
|
||||||
, _to(to)
|
, _to(to)
|
||||||
, _content(voice)
|
, _content(voice)
|
||||||
|
|
|
@ -189,7 +189,7 @@ struct FileLoadResult {
|
||||||
TaskId taskId,
|
TaskId taskId,
|
||||||
uint64 id,
|
uint64 id,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption,
|
const TextWithTags &caption,
|
||||||
std::shared_ptr<SendingAlbum> album);
|
std::shared_ptr<SendingAlbum> album);
|
||||||
|
|
||||||
TaskId taskId;
|
TaskId taskId;
|
||||||
|
@ -217,7 +217,7 @@ struct FileLoadResult {
|
||||||
MTPDocument document;
|
MTPDocument document;
|
||||||
|
|
||||||
PreparedPhotoThumbs photoThumbs;
|
PreparedPhotoThumbs photoThumbs;
|
||||||
QString caption;
|
TextWithTags caption;
|
||||||
|
|
||||||
void setFileData(const QByteArray &filedata) {
|
void setFileData(const QByteArray &filedata) {
|
||||||
if (filedata.isEmpty()) {
|
if (filedata.isEmpty()) {
|
||||||
|
@ -281,14 +281,14 @@ public:
|
||||||
std::unique_ptr<FileMediaInformation> information,
|
std::unique_ptr<FileMediaInformation> information,
|
||||||
SendMediaType type,
|
SendMediaType type,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption,
|
const TextWithTags &caption,
|
||||||
std::shared_ptr<SendingAlbum> album = nullptr);
|
std::shared_ptr<SendingAlbum> album = nullptr);
|
||||||
FileLoadTask(
|
FileLoadTask(
|
||||||
const QByteArray &voice,
|
const QByteArray &voice,
|
||||||
int32 duration,
|
int32 duration,
|
||||||
const VoiceWaveform &waveform,
|
const VoiceWaveform &waveform,
|
||||||
const FileLoadTo &to,
|
const FileLoadTo &to,
|
||||||
const QString &caption);
|
const TextWithTags &caption);
|
||||||
|
|
||||||
uint64 fileid() const {
|
uint64 fileid() const {
|
||||||
return _id;
|
return _id;
|
||||||
|
@ -328,7 +328,7 @@ private:
|
||||||
int32 _duration = 0;
|
int32 _duration = 0;
|
||||||
VoiceWaveform _waveform;
|
VoiceWaveform _waveform;
|
||||||
SendMediaType _type;
|
SendMediaType _type;
|
||||||
QString _caption;
|
TextWithTags _caption;
|
||||||
|
|
||||||
std::shared_ptr<FileLoadResult> _result;
|
std::shared_ptr<FileLoadResult> _result;
|
||||||
|
|
||||||
|
|
|
@ -1168,16 +1168,24 @@ void InputField::onTouchTimer() {
|
||||||
_touchRightButton = true;
|
_touchRightButton = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputField::enableMarkdownSupport(bool enabled) {
|
|
||||||
_markdownEnabled = enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InputField::setInstantReplaces(const InstantReplaces &replaces) {
|
void InputField::setInstantReplaces(const InstantReplaces &replaces) {
|
||||||
_mutableInstantReplaces = replaces;
|
_mutableInstantReplaces = replaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputField::enableInstantReplaces(bool enabled) {
|
void InputField::setInstantReplacesEnabled(rpl::producer<bool> enabled) {
|
||||||
_instantReplacesEnabled = enabled;
|
std::move(
|
||||||
|
enabled
|
||||||
|
) | rpl::start_with_next([=](bool value) {
|
||||||
|
_instantReplacesEnabled = value;
|
||||||
|
}, lifetime());
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputField::setMarkdownReplacesEnabled(rpl::producer<bool> enabled) {
|
||||||
|
std::move(
|
||||||
|
enabled
|
||||||
|
) | rpl::start_with_next([=](bool value) {
|
||||||
|
_markdownEnabled = value;
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputField::setTagMimeProcessor(
|
void InputField::setTagMimeProcessor(
|
||||||
|
|
|
@ -187,7 +187,8 @@ public:
|
||||||
void setAdditionalMargin(int margin);
|
void setAdditionalMargin(int margin);
|
||||||
|
|
||||||
void setInstantReplaces(const InstantReplaces &replaces);
|
void setInstantReplaces(const InstantReplaces &replaces);
|
||||||
void enableInstantReplaces(bool enabled);
|
void setInstantReplacesEnabled(rpl::producer<bool> enabled);
|
||||||
|
void setMarkdownReplacesEnabled(rpl::producer<bool> enabled);
|
||||||
void commitInstantReplacement(
|
void commitInstantReplacement(
|
||||||
int from,
|
int from,
|
||||||
int till,
|
int till,
|
||||||
|
@ -229,8 +230,8 @@ public:
|
||||||
Both,
|
Both,
|
||||||
};
|
};
|
||||||
void setSubmitSettings(SubmitSettings settings);
|
void setSubmitSettings(SubmitSettings settings);
|
||||||
void enableMarkdownSupport(bool enabled = true);
|
|
||||||
void customUpDown(bool isCustom);
|
void customUpDown(bool isCustom);
|
||||||
|
void customTab(bool isCustom);
|
||||||
|
|
||||||
not_null<QTextDocument*> document();
|
not_null<QTextDocument*> document();
|
||||||
not_null<const QTextDocument*> document() const;
|
not_null<const QTextDocument*> document() const;
|
||||||
|
@ -381,6 +382,7 @@ private:
|
||||||
int _additionalMargin = 0;
|
int _additionalMargin = 0;
|
||||||
|
|
||||||
bool _customUpDown = false;
|
bool _customUpDown = false;
|
||||||
|
bool _customTab = false;
|
||||||
|
|
||||||
QString _placeholder;
|
QString _placeholder;
|
||||||
base::lambda<QString()> _placeholderFactory;
|
base::lambda<QString()> _placeholderFactory;
|
||||||
|
|
|
@ -440,13 +440,13 @@ void Manager::openNotificationMessage(
|
||||||
void Manager::notificationReplied(
|
void Manager::notificationReplied(
|
||||||
PeerId peerId,
|
PeerId peerId,
|
||||||
MsgId msgId,
|
MsgId msgId,
|
||||||
const QString &reply) {
|
const TextWithTags &reply) {
|
||||||
if (!peerId) return;
|
if (!peerId) return;
|
||||||
|
|
||||||
auto history = App::history(peerId);
|
auto history = App::history(peerId);
|
||||||
|
|
||||||
auto message = MainWidget::MessageToSend(history);
|
auto message = MainWidget::MessageToSend(history);
|
||||||
message.textWithTags = { reply, TextWithTags::Tags() };
|
message.textWithTags = reply;
|
||||||
message.replyTo = (msgId > 0 && !history->peer->isUser()) ? msgId : 0;
|
message.replyTo = (msgId > 0 && !history->peer->isUser()) ? msgId : 0;
|
||||||
message.clearDraft = false;
|
message.clearDraft = false;
|
||||||
if (auto main = App::main()) {
|
if (auto main = App::main()) {
|
||||||
|
|
|
@ -132,7 +132,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void notificationActivated(PeerId peerId, MsgId msgId);
|
void notificationActivated(PeerId peerId, MsgId msgId);
|
||||||
void notificationReplied(PeerId peerId, MsgId msgId, const QString &reply);
|
void notificationReplied(
|
||||||
|
PeerId peerId,
|
||||||
|
MsgId msgId,
|
||||||
|
const TextWithTags &reply);
|
||||||
|
|
||||||
struct DisplayOptions {
|
struct DisplayOptions {
|
||||||
bool hideNameAndPhoto;
|
bool hideNameAndPhoto;
|
||||||
|
|
|
@ -772,6 +772,8 @@ void Notification::showReplyField() {
|
||||||
_replyArea->setMaxLength(MaxMessageSize);
|
_replyArea->setMaxLength(MaxMessageSize);
|
||||||
_replyArea->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
|
_replyArea->setSubmitSettings(Ui::InputField::SubmitSettings::Both);
|
||||||
_replyArea->setInstantReplaces(Ui::InstantReplaces::Default());
|
_replyArea->setInstantReplaces(Ui::InstantReplaces::Default());
|
||||||
|
_replyArea->setInstantReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
|
_replyArea->setMarkdownReplacesEnabled(Global::ReplaceEmojiValue());
|
||||||
|
|
||||||
// Catch mouse press event to activate the window.
|
// Catch mouse press event to activate the window.
|
||||||
QCoreApplication::instance()->installEventFilter(this);
|
QCoreApplication::instance()->installEventFilter(this);
|
||||||
|
@ -795,7 +797,10 @@ void Notification::sendReply() {
|
||||||
|
|
||||||
auto peerId = _history->peer->id;
|
auto peerId = _history->peer->id;
|
||||||
auto msgId = _item ? _item->id : ShowAtUnreadMsgId;
|
auto msgId = _item ? _item->id : ShowAtUnreadMsgId;
|
||||||
manager()->notificationReplied(peerId, msgId, _replyArea->getLastText());
|
manager()->notificationReplied(
|
||||||
|
peerId,
|
||||||
|
msgId,
|
||||||
|
_replyArea->getTextWithTags());
|
||||||
|
|
||||||
manager()->startAllHiding();
|
manager()->startAllHiding();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue