mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
Ctrl+Reply+Click replies in another chat.
This commit is contained in:
parent
edc6cfe210
commit
2c7089d47f
5 changed files with 36 additions and 46 deletions
|
@ -290,6 +290,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_error_cant_add_admin_invite" = "You can't add this user as an admin because they are not a member of this group and you are not allowed to add them.";
|
||||
"lng_error_cant_add_admin_unban" = "Sorry, you can't add this user as an admin because they are in the Removed Users list and you can't unban them.";
|
||||
"lng_error_cant_ban_admin" = "You can't ban this user because they are an admin in this group and you are not allowed to demote them.";
|
||||
"lng_error_cant_reply_other" = "This message can't be replied in another chat.";
|
||||
"lng_error_admin_limit" = "Sorry, you've reached the maximum number of admins for this group.";
|
||||
"lng_error_admin_limit_channel" = "Sorry, you've reached the maximum number of admins for this channel.";
|
||||
"lng_error_post_link_invalid" = "Unfortunately, you can't access this message. You aren't a member of the chat where it was posted.";
|
||||
|
|
|
@ -124,15 +124,6 @@ int BinarySearchBlocksOrItems(const T &list, int edge) {
|
|||
return start;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool CanSendReply(not_null<const HistoryItem*> item) {
|
||||
const auto peer = item->history()->peer;
|
||||
const auto topic = item->topic();
|
||||
return topic
|
||||
? Data::CanSendAnything(topic)
|
||||
: (Data::CanSendAnything(peer)
|
||||
&& (!peer->isChannel() || peer->asChannel()->amIn()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// flick scroll taken from http://qt-project.org/doc/qt-4.8/demos-embedded-anomaly-src-flickcharm-cpp.html
|
||||
|
@ -576,21 +567,13 @@ void HistoryInner::setupSwipeReply() {
|
|||
const auto replyToItemId = (selected.item
|
||||
? selected.item
|
||||
: still)->fullId();
|
||||
if (canSendReply) {
|
||||
_widget->replyToMessage({
|
||||
.messageId = replyToItemId,
|
||||
.quote = selected.text,
|
||||
.quoteOffset = selected.offset,
|
||||
});
|
||||
if (!selected.text.empty()) {
|
||||
_widget->clearSelected();
|
||||
}
|
||||
} else {
|
||||
HistoryView::Controls::ShowReplyToChatBox(show, {
|
||||
.messageId = replyToItemId,
|
||||
.quote = selected.text,
|
||||
.quoteOffset = selected.offset,
|
||||
});
|
||||
_widget->replyToMessage({
|
||||
.messageId = replyToItemId,
|
||||
.quote = selected.text,
|
||||
.quoteOffset = selected.offset,
|
||||
});
|
||||
if (!selected.text.empty()) {
|
||||
_widget->clearSelected();
|
||||
}
|
||||
};
|
||||
return false;
|
||||
|
@ -2575,26 +2558,13 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
|||
const auto quoteOffset = selected.offset;
|
||||
text.replace('&', u"&&"_q);
|
||||
_menu->addAction(text, [=] {
|
||||
const auto still = session->data().message(itemId);
|
||||
const auto forceAnotherChat = base::IsCtrlPressed()
|
||||
&& still
|
||||
&& still->allowsForward();
|
||||
if (canSendReply && !forceAnotherChat) {
|
||||
_widget->replyToMessage({
|
||||
.messageId = itemId,
|
||||
.quote = quote,
|
||||
.quoteOffset = quoteOffset,
|
||||
});
|
||||
if (!quote.empty()) {
|
||||
_widget->clearSelected();
|
||||
}
|
||||
} else {
|
||||
const auto show = controller->uiShow();
|
||||
HistoryView::Controls::ShowReplyToChatBox(show, {
|
||||
.messageId = itemId,
|
||||
.quote = quote,
|
||||
.quoteOffset = quoteOffset,
|
||||
});
|
||||
_widget->replyToMessage({
|
||||
.messageId = itemId,
|
||||
.quote = quote,
|
||||
.quoteOffset = quoteOffset,
|
||||
});
|
||||
if (!quote.empty()) {
|
||||
_widget->clearSelected();
|
||||
}
|
||||
}, &st::menuIconReply);
|
||||
}
|
||||
|
@ -4774,3 +4744,12 @@ auto HistoryInner::DelegateMixin()
|
|||
-> std::unique_ptr<HistoryMainElementDelegateMixin> {
|
||||
return std::make_unique<HistoryMainElementDelegate>();
|
||||
}
|
||||
|
||||
bool CanSendReply(not_null<const HistoryItem*> item) {
|
||||
const auto peer = item->history()->peer;
|
||||
const auto topic = item->topic();
|
||||
return topic
|
||||
? Data::CanSendAnything(topic)
|
||||
: (Data::CanSendAnything(peer)
|
||||
&& (!peer->isChannel() || peer->asChannel()->amIn()));
|
||||
}
|
||||
|
|
|
@ -553,3 +553,5 @@ private:
|
|||
ClickHandlerPtr _scrollDateLink;
|
||||
|
||||
};
|
||||
|
||||
[[nodiscard]] bool CanSendReply(not_null<const HistoryItem*> item);
|
||||
|
|
|
@ -7884,7 +7884,15 @@ void HistoryWidget::clearFieldText(
|
|||
|
||||
void HistoryWidget::replyToMessage(FullReplyTo id) {
|
||||
if (const auto item = session().data().message(id.messageId)) {
|
||||
replyToMessage(item, id.quote, id.quoteOffset);
|
||||
if (CanSendReply(item) && !base::IsCtrlPressed()) {
|
||||
replyToMessage(item, id.quote, id.quoteOffset);
|
||||
} else if (item->allowsForward()) {
|
||||
const auto show = controller()->uiShow();
|
||||
HistoryView::Controls::ShowReplyToChatBox(show, id);
|
||||
} else {
|
||||
controller()->showToast(
|
||||
tr::lng_error_cant_reply_other(tr::now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1879,7 +1879,7 @@ not_null<Ui::PathShiftGradient*> ListWidget::elementPathShiftGradient() {
|
|||
}
|
||||
|
||||
void ListWidget::elementReplyTo(const FullReplyTo &to) {
|
||||
replyToMessageRequestNotify(to);
|
||||
replyToMessageRequestNotify(to, base::IsCtrlPressed());
|
||||
}
|
||||
|
||||
void ListWidget::elementStartInteraction(not_null<const Element*> view) {
|
||||
|
|
Loading…
Add table
Reference in a new issue