mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Slightly improved code style of history widget.
This commit is contained in:
parent
b753448052
commit
1db8ada2aa
1 changed files with 268 additions and 123 deletions
|
@ -43,6 +43,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/effects/spoiler_mess.h"
|
#include "ui/effects/spoiler_mess.h"
|
||||||
#include "ui/image/image.h"
|
#include "ui/image/image.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/rect.h"
|
||||||
#include "ui/power_saving.h"
|
#include "ui/power_saving.h"
|
||||||
#include "ui/controls/emoji_button.h"
|
#include "ui/controls/emoji_button.h"
|
||||||
#include "ui/controls/send_button.h"
|
#include "ui/controls/send_button.h"
|
||||||
|
@ -101,10 +102,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "history/view/history_view_element.h"
|
#include "history/view/history_view_element.h"
|
||||||
#include "history/view/history_view_scheduled_section.h"
|
#include "history/view/history_view_scheduled_section.h"
|
||||||
#include "history/view/history_view_schedule_box.h"
|
#include "history/view/history_view_schedule_box.h"
|
||||||
#include "history/view/history_view_webpage_preview.h"
|
|
||||||
#include "history/view/history_view_top_bar_widget.h"
|
#include "history/view/history_view_top_bar_widget.h"
|
||||||
#include "history/view/history_view_contact_status.h"
|
#include "history/view/history_view_contact_status.h"
|
||||||
#include "history/view/history_view_context_menu.h"
|
|
||||||
#include "history/view/history_view_paid_reaction_toast.h"
|
#include "history/view/history_view_paid_reaction_toast.h"
|
||||||
#include "history/view/history_view_pinned_tracker.h"
|
#include "history/view/history_view_pinned_tracker.h"
|
||||||
#include "history/view/history_view_pinned_section.h"
|
#include "history/view/history_view_pinned_section.h"
|
||||||
|
@ -127,8 +126,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "menu/menu_send.h"
|
#include "menu/menu_send.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "mainwidget.h"
|
|
||||||
#include "mainwindow.h"
|
|
||||||
#include "settings/business/settings_quick_replies.h"
|
#include "settings/business/settings_quick_replies.h"
|
||||||
#include "storage/localimageloader.h"
|
#include "storage/localimageloader.h"
|
||||||
#include "storage/storage_account.h"
|
#include "storage/storage_account.h"
|
||||||
|
@ -171,9 +168,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "dialogs/dialogs_key.h"
|
#include "dialogs/dialogs_key.h"
|
||||||
#include "calls/calls_instance.h"
|
#include "calls/calls_instance.h"
|
||||||
#include "styles/style_chat.h"
|
#include "styles/style_chat.h"
|
||||||
#include "styles/style_dialogs.h"
|
|
||||||
#include "styles/style_window.h"
|
#include "styles/style_window.h"
|
||||||
#include "styles/style_boxes.h"
|
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
#include "styles/style_info.h"
|
#include "styles/style_info.h"
|
||||||
|
|
||||||
|
@ -247,8 +242,14 @@ HistoryWidget::HistoryWidget(
|
||||||
? object_ptr<Support::Autocomplete>(this, &session())
|
? object_ptr<Support::Autocomplete>(this, &session())
|
||||||
: nullptr)
|
: nullptr)
|
||||||
, _send(std::make_shared<Ui::SendButton>(this, st::historySend))
|
, _send(std::make_shared<Ui::SendButton>(this, st::historySend))
|
||||||
, _unblock(this, tr::lng_unblock_button(tr::now).toUpper(), st::historyUnblock)
|
, _unblock(
|
||||||
, _botStart(this, tr::lng_bot_start(tr::now).toUpper(), st::historyComposeButton)
|
this,
|
||||||
|
tr::lng_unblock_button(tr::now).toUpper(),
|
||||||
|
st::historyUnblock)
|
||||||
|
, _botStart(
|
||||||
|
this,
|
||||||
|
tr::lng_bot_start(tr::now).toUpper(),
|
||||||
|
st::historyComposeButton)
|
||||||
, _joinChannel(
|
, _joinChannel(
|
||||||
this,
|
this,
|
||||||
tr::lng_profile_join_channel(tr::now).toUpper(),
|
tr::lng_profile_join_channel(tr::now).toUpper(),
|
||||||
|
@ -297,8 +298,7 @@ HistoryWidget::HistoryWidget(
|
||||||
, _topShadow(this) {
|
, _topShadow(this) {
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
session().downloaderTaskFinished(
|
session().downloaderTaskFinished() | rpl::start_with_next([=] {
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
update();
|
update();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
|
@ -311,8 +311,7 @@ HistoryWidget::HistoryWidget(
|
||||||
? base::EventFilterResult::Cancel
|
? base::EventFilterResult::Cancel
|
||||||
: base::EventFilterResult::Continue;
|
: base::EventFilterResult::Continue;
|
||||||
});
|
});
|
||||||
_scroll->scrolls(
|
_scroll->scrolls() | rpl::start_with_next([=] {
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
handleScroll();
|
handleScroll();
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
_scroll->geometryChanged(
|
_scroll->geometryChanged(
|
||||||
|
@ -1209,7 +1208,9 @@ void HistoryWidget::supportShareContact(Support::Contact contact) {
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::scrollToCurrentVoiceMessage(FullMsgId fromId, FullMsgId toId) {
|
void HistoryWidget::scrollToCurrentVoiceMessage(
|
||||||
|
FullMsgId fromId,
|
||||||
|
FullMsgId toId) {
|
||||||
if (crl::now() <= _lastUserScrolled + kScrollToVoiceAfterScrolledMs) {
|
if (crl::now() <= _lastUserScrolled + kScrollToVoiceAfterScrolledMs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1234,8 @@ void HistoryWidget::scrollToCurrentVoiceMessage(FullMsgId fromId, FullMsgId toId
|
||||||
auto scrollTop = _scroll->scrollTop();
|
auto scrollTop = _scroll->scrollTop();
|
||||||
auto scrollBottom = scrollTop + _scroll->height();
|
auto scrollBottom = scrollTop + _scroll->height();
|
||||||
auto toBottom = toTop + toView->height();
|
auto toBottom = toTop + toView->height();
|
||||||
if ((toTop < scrollTop && toBottom < scrollBottom) || (toTop > scrollTop && toBottom > scrollBottom)) {
|
if ((toTop < scrollTop && toBottom < scrollBottom)
|
||||||
|
|| (toTop > scrollTop && toBottom > scrollBottom)) {
|
||||||
animatedScrollToItem(to->id);
|
animatedScrollToItem(to->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1313,7 +1315,8 @@ void HistoryWidget::scrollToAnimationCallback(
|
||||||
if (itemTop < 0) {
|
if (itemTop < 0) {
|
||||||
_scrollToAnimation.stop();
|
_scrollToAnimation.stop();
|
||||||
} else {
|
} else {
|
||||||
synteticScrollToY(qRound(_scrollToAnimation.value(relativeTo)) + itemTop);
|
synteticScrollToY(qRound(_scrollToAnimation.value(relativeTo))
|
||||||
|
+ itemTop);
|
||||||
}
|
}
|
||||||
if (!_scrollToAnimation.animating()) {
|
if (!_scrollToAnimation.animating()) {
|
||||||
preloadHistoryByScroll();
|
preloadHistoryByScroll();
|
||||||
|
@ -1480,9 +1483,9 @@ void HistoryWidget::updateInlineBotQuery() {
|
||||||
_inlineBot = nullptr;
|
_inlineBot = nullptr;
|
||||||
_inlineLookingUpBot = true;
|
_inlineLookingUpBot = true;
|
||||||
const auto username = _inlineBotUsername;
|
const auto username = _inlineBotUsername;
|
||||||
_inlineBotResolveRequestId = _api.request(MTPcontacts_ResolveUsername(
|
_inlineBotResolveRequestId = _api.request(
|
||||||
MTP_string(username)
|
MTPcontacts_ResolveUsername(MTP_string(username))
|
||||||
)).done([=](const MTPcontacts_ResolvedPeer &result) {
|
).done([=](const MTPcontacts_ResolvedPeer &result) {
|
||||||
const auto &data = result.data();
|
const auto &data = result.data();
|
||||||
const auto resolvedBot = [&]() -> UserData* {
|
const auto resolvedBot = [&]() -> UserData* {
|
||||||
if (const auto user = session().data().processUsers(
|
if (const auto user = session().data().processUsers(
|
||||||
|
@ -1646,7 +1649,8 @@ Ui::ChatTheme *HistoryWidget::customChatTheme() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::fieldChanged() {
|
void HistoryWidget::fieldChanged() {
|
||||||
const auto updateTyping = (_textUpdateEvents & TextUpdateEvent::SendTyping);
|
const auto updateTyping = (_textUpdateEvents
|
||||||
|
& TextUpdateEvent::SendTyping);
|
||||||
|
|
||||||
InvokeQueued(this, [=] {
|
InvokeQueued(this, [=] {
|
||||||
updateInlineBotQuery();
|
updateInlineBotQuery();
|
||||||
|
@ -1997,7 +2001,8 @@ bool HistoryWidget::applyDraft(FieldHistoryAction fieldHistoryAction) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!draft || (!editDraft && !fieldAvailable)) {
|
if (!draft || (!editDraft && !fieldAvailable)) {
|
||||||
auto fieldWillBeHiddenAfterEdit = (!fieldAvailable && _editMsgId != 0);
|
const auto fieldWillBeHiddenAfterEdit = (!fieldAvailable
|
||||||
|
&& _editMsgId != 0);
|
||||||
clearFieldText(0, fieldHistoryAction);
|
clearFieldText(0, fieldHistoryAction);
|
||||||
setInnerFocus();
|
setInnerFocus();
|
||||||
_processingReplyItem = _replyEditMsg = nullptr;
|
_processingReplyItem = _replyEditMsg = nullptr;
|
||||||
|
@ -3399,7 +3404,8 @@ void HistoryWidget::messagesReceived(
|
||||||
channel->ptsReceived(d.vpts().v);
|
channel->ptsReceived(d.vpts().v);
|
||||||
channel->processTopics(d.vtopics());
|
channel->processTopics(d.vtopics());
|
||||||
} else {
|
} else {
|
||||||
LOG(("API Error: received messages.channelMessages when no channel was passed! (HistoryWidget::messagesReceived)"));
|
LOG(("API Error: received messages.channelMessages when "
|
||||||
|
"no channel was passed! (HistoryWidget::messagesReceived)"));
|
||||||
}
|
}
|
||||||
_history->owner().processUsers(d.vusers());
|
_history->owner().processUsers(d.vusers());
|
||||||
_history->owner().processChats(d.vchats());
|
_history->owner().processChats(d.vchats());
|
||||||
|
@ -3407,7 +3413,8 @@ void HistoryWidget::messagesReceived(
|
||||||
count = d.vcount().v;
|
count = d.vcount().v;
|
||||||
} break;
|
} break;
|
||||||
case mtpc_messages_messagesNotModified: {
|
case mtpc_messages_messagesNotModified: {
|
||||||
LOG(("API Error: received messages.messagesNotModified! (HistoryWidget::messagesReceived)"));
|
LOG(("API Error: received messages.messagesNotModified! "
|
||||||
|
"(HistoryWidget::messagesReceived)"));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3556,7 +3563,8 @@ void HistoryWidget::firstLoadMessages() {
|
||||||
const auto history = from;
|
const auto history = from;
|
||||||
const auto type = Data::Histories::RequestType::History;
|
const auto type = Data::Histories::RequestType::History;
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
_firstLoadRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
_firstLoadRequest = histories.sendRequest(history, type, [=](
|
||||||
|
Fn<void()> finish) {
|
||||||
return history->session().api().request(MTPmessages_GetHistory(
|
return history->session().api().request(MTPmessages_GetHistory(
|
||||||
history->peer->input,
|
history->peer->input,
|
||||||
MTP_int(offsetId),
|
MTP_int(offsetId),
|
||||||
|
@ -3613,7 +3621,8 @@ void HistoryWidget::loadMessages() {
|
||||||
const auto history = from;
|
const auto history = from;
|
||||||
const auto type = Data::Histories::RequestType::History;
|
const auto type = Data::Histories::RequestType::History;
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
_preloadRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
_preloadRequest = histories.sendRequest(history, type, [=](
|
||||||
|
Fn<void()> finish) {
|
||||||
return history->session().api().request(MTPmessages_GetHistory(
|
return history->session().api().request(MTPmessages_GetHistory(
|
||||||
history->peer->input,
|
history->peer->input,
|
||||||
MTP_int(offsetId),
|
MTP_int(offsetId),
|
||||||
|
@ -3642,8 +3651,11 @@ void HistoryWidget::loadMessagesDown() {
|
||||||
return firstLoadMessages();
|
return firstLoadMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto loadMigrated = _migrated && !(_migrated->isEmpty() || _migrated->loadedAtBottom() || (!_history->isEmpty() && !_history->loadedAtTop()));
|
const auto loadMigrated = _migrated
|
||||||
auto from = loadMigrated ? _migrated : _history;
|
&& !(_migrated->isEmpty()
|
||||||
|
|| _migrated->loadedAtBottom()
|
||||||
|
|| (!_history->isEmpty() && !_history->loadedAtTop()));
|
||||||
|
const auto from = loadMigrated ? _migrated : _history;
|
||||||
if (from->loadedAtBottom()) {
|
if (from->loadedAtBottom()) {
|
||||||
if (_sponsoredMessagesStateKnown) {
|
if (_sponsoredMessagesStateKnown) {
|
||||||
session().sponsoredMessages().request(_history, nullptr);
|
session().sponsoredMessages().request(_history, nullptr);
|
||||||
|
@ -3655,7 +3667,9 @@ void HistoryWidget::loadMessagesDown() {
|
||||||
auto addOffset = -loadCount;
|
auto addOffset = -loadCount;
|
||||||
auto offsetId = from->maxMsgId();
|
auto offsetId = from->maxMsgId();
|
||||||
if (!offsetId) {
|
if (!offsetId) {
|
||||||
if (loadMigrated || !_migrated) return;
|
if (loadMigrated || !_migrated) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
++offsetId;
|
++offsetId;
|
||||||
++addOffset;
|
++addOffset;
|
||||||
}
|
}
|
||||||
|
@ -3673,7 +3687,8 @@ void HistoryWidget::loadMessagesDown() {
|
||||||
const auto history = from;
|
const auto history = from;
|
||||||
const auto type = Data::Histories::RequestType::History;
|
const auto type = Data::Histories::RequestType::History;
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
_preloadDownRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
_preloadDownRequest = histories.sendRequest(history, type, [=](
|
||||||
|
Fn<void()> finish) {
|
||||||
return history->session().api().request(MTPmessages_GetHistory(
|
return history->session().api().request(MTPmessages_GetHistory(
|
||||||
history->peer->input,
|
history->peer->input,
|
||||||
MTP_int(offsetId + 1),
|
MTP_int(offsetId + 1),
|
||||||
|
@ -3738,7 +3753,9 @@ void HistoryWidget::delayedShowAt(
|
||||||
offset = -loadCount / 2;
|
offset = -loadCount / 2;
|
||||||
offsetId = _delayedShowAtMsgId;
|
offsetId = _delayedShowAtMsgId;
|
||||||
} else if (_delayedShowAtMsgId < 0 && _history->peer->isChannel()) {
|
} else if (_delayedShowAtMsgId < 0 && _history->peer->isChannel()) {
|
||||||
if (_delayedShowAtMsgId < 0 && -_delayedShowAtMsgId < ServerMaxMsgId && _migrated) {
|
if ((_delayedShowAtMsgId < 0)
|
||||||
|
&& (-_delayedShowAtMsgId < ServerMaxMsgId)
|
||||||
|
&& _migrated) {
|
||||||
from = _migrated;
|
from = _migrated;
|
||||||
offset = -loadCount / 2;
|
offset = -loadCount / 2;
|
||||||
offsetId = -_delayedShowAtMsgId;
|
offsetId = -_delayedShowAtMsgId;
|
||||||
|
@ -3752,7 +3769,8 @@ void HistoryWidget::delayedShowAt(
|
||||||
const auto history = from;
|
const auto history = from;
|
||||||
const auto type = Data::Histories::RequestType::History;
|
const auto type = Data::Histories::RequestType::History;
|
||||||
auto &histories = history->owner().histories();
|
auto &histories = history->owner().histories();
|
||||||
_delayedShowAtRequest = histories.sendRequest(history, type, [=](Fn<void()> finish) {
|
_delayedShowAtRequest = histories.sendRequest(history, type, [=](
|
||||||
|
Fn<void()> finish) {
|
||||||
return history->session().api().request(MTPmessages_GetHistory(
|
return history->session().api().request(MTPmessages_GetHistory(
|
||||||
history->peer->input,
|
history->peer->input,
|
||||||
MTP_int(offsetId),
|
MTP_int(offsetId),
|
||||||
|
@ -3799,14 +3817,14 @@ bool HistoryWidget::isItemCompletelyHidden(HistoryItem *item) const {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto top = _list ? _list->itemTop(item) : -2;
|
const auto top = _list ? _list->itemTop(item) : -2;
|
||||||
if (top < 0) {
|
if (top < 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bottom = top + view->height();
|
const auto bottom = top + view->height();
|
||||||
auto scrollTop = _scroll->scrollTop();
|
const auto scrollTop = _scroll->scrollTop();
|
||||||
auto scrollBottom = scrollTop + _scroll->height();
|
const auto scrollBottom = scrollTop + _scroll->height();
|
||||||
return (top >= scrollBottom || bottom <= scrollTop);
|
return (top >= scrollBottom || bottom <= scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4533,7 +4551,7 @@ void HistoryWidget::chooseAttach(
|
||||||
? FileDialog::PhotoVideoFilesFilter()
|
? FileDialog::PhotoVideoFilesFilter()
|
||||||
: FileDialog::AllOrImagesFilter();
|
: FileDialog::AllOrImagesFilter();
|
||||||
|
|
||||||
FileDialog::GetOpenPaths(this, tr::lng_choose_files(tr::now), filter, crl::guard(this, [=](
|
const auto callbackOnResult = crl::guard(this, [=](
|
||||||
FileDialog::OpenResult &&result) {
|
FileDialog::OpenResult &&result) {
|
||||||
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
if (result.paths.isEmpty() && result.remoteContent.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -4560,7 +4578,13 @@ void HistoryWidget::chooseAttach(
|
||||||
list.overrideSendImagesAsPhotos = overrideSendImagesAsPhotos;
|
list.overrideSendImagesAsPhotos = overrideSendImagesAsPhotos;
|
||||||
confirmSendingFiles(std::move(list));
|
confirmSendingFiles(std::move(list));
|
||||||
}
|
}
|
||||||
}), nullptr);
|
});
|
||||||
|
FileDialog::GetOpenPaths(
|
||||||
|
this,
|
||||||
|
tr::lng_choose_files(tr::now),
|
||||||
|
filter,
|
||||||
|
callbackOnResult,
|
||||||
|
nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::sendButtonClicked() {
|
void HistoryWidget::sendButtonClicked() {
|
||||||
|
@ -4579,7 +4603,7 @@ void HistoryWidget::leaveEventHook(QEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::mouseMoveEvent(QMouseEvent *e) {
|
void HistoryWidget::mouseMoveEvent(QMouseEvent *e) {
|
||||||
auto pos = e ? e->pos() : mapFromGlobal(QCursor::pos());
|
const auto pos = e ? e->pos() : mapFromGlobal(QCursor::pos());
|
||||||
updateOverStates(pos);
|
updateOverStates(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4621,7 +4645,8 @@ void HistoryWidget::updateOverStates(QPoint pos) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::leaveToChildEvent(QEvent *e, QWidget *child) { // e -- from enterEvent() of child TWidget
|
void HistoryWidget::leaveToChildEvent(QEvent *e, QWidget *child) {
|
||||||
|
// e -- from enterEvent() of child TWidget
|
||||||
if (hasMouseTracking()) {
|
if (hasMouseTracking()) {
|
||||||
updateOverStates(mapFromGlobal(QCursor::pos()));
|
updateOverStates(mapFromGlobal(QCursor::pos()));
|
||||||
}
|
}
|
||||||
|
@ -4660,8 +4685,12 @@ void HistoryWidget::sendBotCommand(const Bot::SendCommandRequest &request) {
|
||||||
cancelReply();
|
cancelReply();
|
||||||
saveCloudDraft();
|
saveCloudDraft();
|
||||||
}
|
}
|
||||||
if (_keyboard->singleUse() && _keyboard->hasMarkup() && lastKeyboardUsed) {
|
if (_keyboard->singleUse()
|
||||||
if (_kbShown) toggleKeyboard(false);
|
&& _keyboard->hasMarkup()
|
||||||
|
&& lastKeyboardUsed) {
|
||||||
|
if (_kbShown) {
|
||||||
|
toggleKeyboard(false);
|
||||||
|
}
|
||||||
_history->lastKeyboardUsed = true;
|
_history->lastKeyboardUsed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4674,7 +4703,7 @@ void HistoryWidget::hideSingleUseKeyboard(FullMsgId replyToId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lastKeyboardUsed = (_keyboard->forMsgId() == replyToId)
|
const auto lastKeyboardUsed = (_keyboard->forMsgId() == replyToId)
|
||||||
&& (_keyboard->forMsgId()
|
&& (_keyboard->forMsgId()
|
||||||
== FullMsgId(_peer->id, _history->lastKeyboardId));
|
== FullMsgId(_peer->id, _history->lastKeyboardId));
|
||||||
if (replyToId) {
|
if (replyToId) {
|
||||||
|
@ -4698,20 +4727,27 @@ bool HistoryWidget::insertBotCommand(const QString &cmd) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto insertingInlineBot = !cmd.isEmpty() && (cmd.at(0) == '@');
|
const auto insertingInlineBot = !cmd.isEmpty() && (cmd.at(0) == '@');
|
||||||
auto toInsert = cmd;
|
auto toInsert = cmd;
|
||||||
if (!toInsert.isEmpty() && !insertingInlineBot) {
|
if (!toInsert.isEmpty() && !insertingInlineBot) {
|
||||||
auto bot = _peer->isUser()
|
auto bot = (PeerData*)(_peer->asUser());
|
||||||
? _peer
|
if (!bot) {
|
||||||
: (HistoryView::Element::HoveredLink()
|
if (const auto link = HistoryView::Element::HoveredLink()) {
|
||||||
? HistoryView::Element::HoveredLink()->data()->fromOriginal().get()
|
bot = link->data()->fromOriginal().get();
|
||||||
: nullptr);
|
}
|
||||||
|
}
|
||||||
if (bot && (!bot->isUser() || !bot->asUser()->isBot())) {
|
if (bot && (!bot->isUser() || !bot->asUser()->isBot())) {
|
||||||
bot = nullptr;
|
bot = nullptr;
|
||||||
}
|
}
|
||||||
auto username = bot ? bot->asUser()->username() : QString();
|
const auto username = bot ? bot->asUser()->username() : QString();
|
||||||
auto botStatus = _peer->isChat() ? _peer->asChat()->botStatus : (_peer->isMegagroup() ? _peer->asChannel()->mgInfo->botStatus : -1);
|
const auto botStatus = _peer->isChat()
|
||||||
if (toInsert.indexOf('@') < 0 && !username.isEmpty() && (botStatus == 0 || botStatus == 2)) {
|
? _peer->asChat()->botStatus
|
||||||
|
: _peer->isMegagroup()
|
||||||
|
? _peer->asChannel()->mgInfo->botStatus
|
||||||
|
: -1;
|
||||||
|
if ((toInsert.indexOf('@') < 0)
|
||||||
|
&& !username.isEmpty()
|
||||||
|
&& (botStatus == 0 || botStatus == 2)) {
|
||||||
toInsert += '@' + username;
|
toInsert += '@' + username;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4719,20 +4755,20 @@ bool HistoryWidget::insertBotCommand(const QString &cmd) {
|
||||||
|
|
||||||
if (!insertingInlineBot) {
|
if (!insertingInlineBot) {
|
||||||
auto &textWithTags = _field->getTextWithTags();
|
auto &textWithTags = _field->getTextWithTags();
|
||||||
TextWithTags textWithTagsToSet;
|
auto textWithTagsToSet = TextWithTags();
|
||||||
const auto m = QRegularExpression(u"^/[A-Za-z_0-9]{0,64}(@[A-Za-z_0-9]{0,32})?(\\s|$)"_q).match(textWithTags.text);
|
const auto m = QRegularExpression(
|
||||||
if (m.hasMatch()) {
|
u"^/[A-Za-z_0-9]{0,64}(@[A-Za-z_0-9]{0,32})?(\\s|$)"_q).match(
|
||||||
textWithTagsToSet = _field->getTextWithTagsPart(m.capturedLength());
|
textWithTags.text);
|
||||||
} else {
|
textWithTagsToSet = m.hasMatch()
|
||||||
textWithTagsToSet = textWithTags;
|
? _field->getTextWithTagsPart(m.capturedLength())
|
||||||
}
|
: textWithTags;
|
||||||
textWithTagsToSet.text = toInsert + textWithTagsToSet.text;
|
textWithTagsToSet.text = toInsert + textWithTagsToSet.text;
|
||||||
for (auto &tag : textWithTagsToSet.tags) {
|
for (auto &tag : textWithTagsToSet.tags) {
|
||||||
tag.offset += toInsert.size();
|
tag.offset += toInsert.size();
|
||||||
}
|
}
|
||||||
_field->setTextWithTags(textWithTagsToSet);
|
_field->setTextWithTags(textWithTagsToSet);
|
||||||
|
|
||||||
QTextCursor cur(_field->textCursor());
|
auto cur = QTextCursor(_field->textCursor());
|
||||||
cur.movePosition(QTextCursor::End);
|
cur.movePosition(QTextCursor::End);
|
||||||
_field->setTextCursor(cur);
|
_field->setTextCursor(cur);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4889,9 +4925,18 @@ bool HistoryWidget::updateCmdStartShown() {
|
||||||
const auto bot = (_peer && _peer->isUser() && _peer->asUser()->isBot())
|
const auto bot = (_peer && _peer->isUser() && _peer->asUser()->isBot())
|
||||||
? _peer->asUser()
|
? _peer->asUser()
|
||||||
: nullptr;
|
: nullptr;
|
||||||
bool cmdStartShown = false;
|
auto cmdStartShown = false;
|
||||||
if (_history && _peer && ((_peer->isChat() && _peer->asChat()->botStatus > 0) || (_peer->isMegagroup() && _peer->asChannel()->mgInfo->botStatus > 0))) {
|
if (_history
|
||||||
if (!isBotStart() && !isBlocked() && !_keyboard->hasMarkup() && !_keyboard->forceReply() && !_editMsgId) {
|
&& _peer
|
||||||
|
&& (false
|
||||||
|
|| (_peer->isChat() && _peer->asChat()->botStatus > 0)
|
||||||
|
|| (_peer->isMegagroup()
|
||||||
|
&& _peer->asChannel()->mgInfo->botStatus > 0))) {
|
||||||
|
if (!isBotStart()
|
||||||
|
&& !isBlocked()
|
||||||
|
&& !_keyboard->hasMarkup()
|
||||||
|
&& !_keyboard->forceReply()
|
||||||
|
&& !_editMsgId) {
|
||||||
if (!HasSendText(_field)) {
|
if (!HasSendText(_field)) {
|
||||||
cmdStartShown = true;
|
cmdStartShown = true;
|
||||||
}
|
}
|
||||||
|
@ -5025,9 +5070,7 @@ void HistoryWidget::switchToSearch(QString query) {
|
||||||
}, _composeSearch->lifetime());
|
}, _composeSearch->lifetime());
|
||||||
|
|
||||||
_composeSearch->destroyRequests(
|
_composeSearch->destroyRequests(
|
||||||
) | rpl::take(
|
) | rpl::take(1) | rpl::start_with_next([=] {
|
||||||
1
|
|
||||||
) | rpl::start_with_next([=] {
|
|
||||||
_composeSearch = nullptr;
|
_composeSearch = nullptr;
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
@ -5053,7 +5096,7 @@ void HistoryWidget::showKeyboardHideButton() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::toggleKeyboard(bool manual) {
|
void HistoryWidget::toggleKeyboard(bool manual) {
|
||||||
auto fieldEnabled = canWriteMessage() && !_showAnimation;
|
const auto fieldEnabled = canWriteMessage() && !_showAnimation;
|
||||||
if (_kbShown || _kbReplyTo) {
|
if (_kbShown || _kbReplyTo) {
|
||||||
_botKeyboardHide->hide();
|
_botKeyboardHide->hide();
|
||||||
if (_kbShown) {
|
if (_kbShown) {
|
||||||
|
@ -5095,7 +5138,10 @@ void HistoryWidget::toggleKeyboard(bool manual) {
|
||||||
|
|
||||||
_field->setMaxHeight(computeMaxFieldHeight());
|
_field->setMaxHeight(computeMaxFieldHeight());
|
||||||
|
|
||||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply())
|
_kbReplyTo = (false
|
||||||
|
|| _peer->isChat()
|
||||||
|
|| _peer->isChannel()
|
||||||
|
|| _keyboard->forceReply())
|
||||||
? session().data().message(_keyboard->forMsgId())
|
? session().data().message(_keyboard->forMsgId())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (_kbReplyTo && !_editMsgId && !_replyTo && fieldEnabled) {
|
if (_kbReplyTo && !_editMsgId && !_replyTo && fieldEnabled) {
|
||||||
|
@ -5112,10 +5158,15 @@ void HistoryWidget::toggleKeyboard(bool manual) {
|
||||||
_kbShown = true;
|
_kbShown = true;
|
||||||
|
|
||||||
const auto maxheight = computeMaxFieldHeight();
|
const auto maxheight = computeMaxFieldHeight();
|
||||||
const auto kbheight = qMin(_keyboard->height(), maxheight - (maxheight / 2));
|
const auto kbheight = qMin(
|
||||||
|
_keyboard->height(),
|
||||||
|
maxheight - (maxheight / 2));
|
||||||
_field->setMaxHeight(maxheight - kbheight);
|
_field->setMaxHeight(maxheight - kbheight);
|
||||||
|
|
||||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply())
|
_kbReplyTo = (false
|
||||||
|
|| _peer->isChat()
|
||||||
|
|| _peer->isChannel()
|
||||||
|
|| _keyboard->forceReply())
|
||||||
? session().data().message(_keyboard->forMsgId())
|
? session().data().message(_keyboard->forMsgId())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (_kbReplyTo && !_editMsgId && !_replyTo) {
|
if (_kbReplyTo && !_editMsgId && !_replyTo) {
|
||||||
|
@ -5128,7 +5179,9 @@ void HistoryWidget::toggleKeyboard(bool manual) {
|
||||||
}
|
}
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
updateFieldPlaceholder();
|
updateFieldPlaceholder();
|
||||||
if (_botKeyboardHide->isHidden() && canWriteMessage() && !_showAnimation) {
|
if (_botKeyboardHide->isHidden()
|
||||||
|
&& canWriteMessage()
|
||||||
|
&& !_showAnimation) {
|
||||||
_tabbedSelectorToggle->show();
|
_tabbedSelectorToggle->show();
|
||||||
} else {
|
} else {
|
||||||
_tabbedSelectorToggle->hide();
|
_tabbedSelectorToggle->hide();
|
||||||
|
@ -5174,7 +5227,9 @@ void HistoryWidget::showMembersDropdown() {
|
||||||
|
|
||||||
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax());
|
_membersDropdown->setMaxHeight(countMembersDropdownHeightMax());
|
||||||
_membersDropdown->moveToLeft(0, _topBar->height());
|
_membersDropdown->moveToLeft(0, _topBar->height());
|
||||||
_membersDropdown->setHiddenCallback([this] { _membersDropdown.destroyDelayed(); });
|
_membersDropdown->setHiddenCallback([this] {
|
||||||
|
_membersDropdown.destroyDelayed();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
_membersDropdown->otherEnter();
|
_membersDropdown->otherEnter();
|
||||||
}
|
}
|
||||||
|
@ -5289,16 +5344,21 @@ void HistoryWidget::moveFieldControls() {
|
||||||
auto left = st::historySendRight;
|
auto left = st::historySendRight;
|
||||||
if (_botMenu.button) {
|
if (_botMenu.button) {
|
||||||
const auto skip = st::historyBotMenuSkip;
|
const auto skip = st::historyBotMenuSkip;
|
||||||
_botMenu.button->moveToLeft(left + skip, buttonsBottom + skip); left += skip + _botMenu.button->width();
|
_botMenu.button->moveToLeft(left + skip, buttonsBottom + skip);
|
||||||
|
left += skip + _botMenu.button->width();
|
||||||
}
|
}
|
||||||
if (_replaceMedia) {
|
if (_replaceMedia) {
|
||||||
_replaceMedia->moveToLeft(left, buttonsBottom);
|
_replaceMedia->moveToLeft(left, buttonsBottom);
|
||||||
}
|
}
|
||||||
_attachToggle->moveToLeft(left, buttonsBottom); left += _attachToggle->width();
|
_attachToggle->moveToLeft(left, buttonsBottom);
|
||||||
|
left += _attachToggle->width();
|
||||||
if (_sendAs) {
|
if (_sendAs) {
|
||||||
_sendAs->moveToLeft(left, buttonsBottom); left += _sendAs->width();
|
_sendAs->moveToLeft(left, buttonsBottom);
|
||||||
|
left += _sendAs->width();
|
||||||
}
|
}
|
||||||
_field->moveToLeft(left, bottom - _field->height() - st::historySendPadding);
|
_field->moveToLeft(
|
||||||
|
left,
|
||||||
|
bottom - _field->height() - st::historySendPadding);
|
||||||
if (_fieldDisabled) {
|
if (_fieldDisabled) {
|
||||||
_fieldDisabled->moveToLeft(
|
_fieldDisabled->moveToLeft(
|
||||||
left,
|
left,
|
||||||
|
@ -5308,7 +5368,8 @@ void HistoryWidget::moveFieldControls() {
|
||||||
_send->moveToRight(right, buttonsBottom); right += _send->width();
|
_send->moveToRight(right, buttonsBottom); right += _send->width();
|
||||||
_voiceRecordBar->moveToLeft(0, bottom - _voiceRecordBar->height());
|
_voiceRecordBar->moveToLeft(0, bottom - _voiceRecordBar->height());
|
||||||
_tabbedSelectorToggle->moveToRight(right, buttonsBottom);
|
_tabbedSelectorToggle->moveToRight(right, buttonsBottom);
|
||||||
_botKeyboardHide->moveToRight(right, buttonsBottom); right += _botKeyboardHide->width();
|
_botKeyboardHide->moveToRight(right, buttonsBottom);
|
||||||
|
right += _botKeyboardHide->width();
|
||||||
_botKeyboardShow->moveToRight(right, buttonsBottom);
|
_botKeyboardShow->moveToRight(right, buttonsBottom);
|
||||||
_botCommandStart->moveToRight(right, buttonsBottom);
|
_botCommandStart->moveToRight(right, buttonsBottom);
|
||||||
if (_silent) {
|
if (_silent) {
|
||||||
|
@ -5326,7 +5387,9 @@ void HistoryWidget::moveFieldControls() {
|
||||||
_ttlInfo->move(width() - right - _ttlInfo->width(), buttonsBottom);
|
_ttlInfo->move(width() - right - _ttlInfo->width(), buttonsBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
_fieldBarCancel->moveToRight(0, _field->y() - st::historySendPadding - _fieldBarCancel->height());
|
_fieldBarCancel->moveToRight(
|
||||||
|
0,
|
||||||
|
_field->y() - st::historySendPadding - _fieldBarCancel->height());
|
||||||
if (_inlineResults) {
|
if (_inlineResults) {
|
||||||
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
_inlineResults->moveBottom(_field->y() - st::historySendPadding);
|
||||||
}
|
}
|
||||||
|
@ -5877,30 +5940,36 @@ void HistoryWidget::updateControlsGeometry() {
|
||||||
_groupCallBar->move(0, groupCallTop);
|
_groupCallBar->move(0, groupCallTop);
|
||||||
_groupCallBar->resizeToWidth(width());
|
_groupCallBar->resizeToWidth(width());
|
||||||
}
|
}
|
||||||
const auto requestsTop = groupCallTop + (_groupCallBar ? _groupCallBar->height() : 0);
|
const auto requestsTop = groupCallTop
|
||||||
|
+ (_groupCallBar ? _groupCallBar->height() : 0);
|
||||||
if (_requestsBar) {
|
if (_requestsBar) {
|
||||||
_requestsBar->move(0, requestsTop);
|
_requestsBar->move(0, requestsTop);
|
||||||
_requestsBar->resizeToWidth(width());
|
_requestsBar->resizeToWidth(width());
|
||||||
}
|
}
|
||||||
const auto pinnedBarTop = requestsTop + (_requestsBar ? _requestsBar->height() : 0);
|
const auto pinnedBarTop = requestsTop
|
||||||
|
+ (_requestsBar ? _requestsBar->height() : 0);
|
||||||
if (_pinnedBar) {
|
if (_pinnedBar) {
|
||||||
_pinnedBar->move(0, pinnedBarTop);
|
_pinnedBar->move(0, pinnedBarTop);
|
||||||
_pinnedBar->resizeToWidth(width());
|
_pinnedBar->resizeToWidth(width());
|
||||||
}
|
}
|
||||||
const auto translateTop = pinnedBarTop + (_pinnedBar ? _pinnedBar->height() : 0);
|
const auto translateTop = pinnedBarTop
|
||||||
|
+ (_pinnedBar ? _pinnedBar->height() : 0);
|
||||||
if (_translateBar) {
|
if (_translateBar) {
|
||||||
_translateBar->move(0, translateTop);
|
_translateBar->move(0, translateTop);
|
||||||
_translateBar->resizeToWidth(width());
|
_translateBar->resizeToWidth(width());
|
||||||
}
|
}
|
||||||
const auto contactStatusTop = translateTop + (_translateBar ? _translateBar->height() : 0);
|
const auto contactStatusTop = translateTop
|
||||||
|
+ (_translateBar ? _translateBar->height() : 0);
|
||||||
if (_contactStatus) {
|
if (_contactStatus) {
|
||||||
_contactStatus->bar().move(0, contactStatusTop);
|
_contactStatus->bar().move(0, contactStatusTop);
|
||||||
}
|
}
|
||||||
const auto businessBotTop = contactStatusTop + (_contactStatus ? _contactStatus->bar().height() : 0);
|
const auto businessBotTop = contactStatusTop
|
||||||
|
+ (_contactStatus ? _contactStatus->bar().height() : 0);
|
||||||
if (_businessBotStatus) {
|
if (_businessBotStatus) {
|
||||||
_businessBotStatus->bar().move(0, businessBotTop);
|
_businessBotStatus->bar().move(0, businessBotTop);
|
||||||
}
|
}
|
||||||
const auto scrollAreaTop = businessBotTop + (_businessBotStatus ? _businessBotStatus->bar().height() : 0);
|
const auto scrollAreaTop = businessBotTop
|
||||||
|
+ (_businessBotStatus ? _businessBotStatus->bar().height() : 0);
|
||||||
if (_scroll->y() != scrollAreaTop) {
|
if (_scroll->y() != scrollAreaTop) {
|
||||||
_scroll->moveToLeft(0, scrollAreaTop);
|
_scroll->moveToLeft(0, scrollAreaTop);
|
||||||
if (_autocomplete) {
|
if (_autocomplete) {
|
||||||
|
@ -6114,12 +6183,15 @@ void HistoryWidget::updateHistoryGeometry(
|
||||||
const auto guard = gsl::finally([&] {
|
const auto guard = gsl::finally([&] {
|
||||||
_itemRevealPending.clear();
|
_itemRevealPending.clear();
|
||||||
});
|
});
|
||||||
if (!_history || (initial && _historyInited) || (!initial && !_historyInited)) {
|
if (!_history
|
||||||
|
|| (initial && _historyInited)
|
||||||
|
|| (!initial && !_historyInited)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_firstLoadRequest || _showAnimation) {
|
if (_firstLoadRequest || _showAnimation) {
|
||||||
_updateHistoryGeometryRequired = true;
|
_updateHistoryGeometryRequired = true;
|
||||||
return; // scrollTopMax etc are not working after recountHistoryGeometry()
|
// scrollTopMax etc are not working after recountHistoryGeometry()
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto newScrollHeight = height() - _topBar->height();
|
auto newScrollHeight = height() - _topBar->height();
|
||||||
|
@ -6176,8 +6248,9 @@ void HistoryWidget::updateHistoryGeometry(
|
||||||
|| (_scroll->height() != newScrollHeight);
|
|| (_scroll->height() != newScrollHeight);
|
||||||
if (needResize) {
|
if (needResize) {
|
||||||
_scroll->resize(width(), newScrollHeight);
|
_scroll->resize(width(), newScrollHeight);
|
||||||
// on initial updateListSize we didn't put the _scroll->scrollTop correctly yet
|
// on initial updateListSize we didn't put the _scroll->scrollTop
|
||||||
// so visibleAreaUpdated() call will erase it with the new (undefined) value
|
// correctly yet so visibleAreaUpdated() call will erase it
|
||||||
|
// with the new (undefined) value
|
||||||
if (!initial) {
|
if (!initial) {
|
||||||
visibleAreaUpdated();
|
visibleAreaUpdated();
|
||||||
}
|
}
|
||||||
|
@ -6423,7 +6496,9 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
_kbScroll->scrollTo({ 0, 0 });
|
_kbScroll->scrollTo({ 0, 0 });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasMarkup = _keyboard->hasMarkup(), forceReply = _keyboard->forceReply() && (!_replyTo || !_replyEditMsg);
|
const auto hasMarkup = _keyboard->hasMarkup();
|
||||||
|
const auto forceReply = _keyboard->forceReply()
|
||||||
|
&& (!_replyTo || !_replyEditMsg);
|
||||||
if (hasMarkup || forceReply) {
|
if (hasMarkup || forceReply) {
|
||||||
if (_keyboard->singleUse()
|
if (_keyboard->singleUse()
|
||||||
&& _keyboard->hasMarkup()
|
&& _keyboard->hasMarkup()
|
||||||
|
@ -6432,7 +6507,13 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
&& _history->lastKeyboardUsed) {
|
&& _history->lastKeyboardUsed) {
|
||||||
_history->lastKeyboardHiddenId = _history->lastKeyboardId;
|
_history->lastKeyboardHiddenId = _history->lastKeyboardId;
|
||||||
}
|
}
|
||||||
if (!isSearching() && !isBotStart() && !isBlocked() && _canSendMessages && (wasVisible || (_replyTo && _replyEditMsg) || (!HasSendText(_field) && !kbWasHidden()))) {
|
if (!isSearching()
|
||||||
|
&& !isBotStart()
|
||||||
|
&& !isBlocked()
|
||||||
|
&& _canSendMessages
|
||||||
|
&& (wasVisible
|
||||||
|
|| (_replyTo && _replyEditMsg)
|
||||||
|
|| (!HasSendText(_field) && !kbWasHidden()))) {
|
||||||
if (!_showAnimation) {
|
if (!_showAnimation) {
|
||||||
if (hasMarkup) {
|
if (hasMarkup) {
|
||||||
_kbScroll->show();
|
_kbScroll->show();
|
||||||
|
@ -6447,10 +6528,14 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
|
||||||
_botCommandStart->hide();
|
_botCommandStart->hide();
|
||||||
}
|
}
|
||||||
const auto maxheight = computeMaxFieldHeight();
|
const auto maxheight = computeMaxFieldHeight();
|
||||||
const auto kbheight = hasMarkup ? qMin(_keyboard->height(), maxheight - (maxheight / 2)) : 0;
|
const auto kbheight = hasMarkup
|
||||||
|
? qMin(_keyboard->height(), maxheight - (maxheight / 2))
|
||||||
|
: 0;
|
||||||
_field->setMaxHeight(maxheight - kbheight);
|
_field->setMaxHeight(maxheight - kbheight);
|
||||||
_kbShown = hasMarkup;
|
_kbShown = hasMarkup;
|
||||||
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply())
|
_kbReplyTo = (_peer->isChat()
|
||||||
|
|| _peer->isChannel()
|
||||||
|
|| _keyboard->forceReply())
|
||||||
? session().data().message(_keyboard->forMsgId())
|
? session().data().message(_keyboard->forMsgId())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
if (_kbReplyTo && !_replyTo) {
|
if (_kbReplyTo && !_replyTo) {
|
||||||
|
@ -6746,7 +6831,8 @@ void HistoryWidget::keyPressEvent(QKeyEvent *e) {
|
||||||
sendWithModifiers(e->modifiers());
|
sendWithModifiers(e->modifiers());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e->key() == Qt::Key_O && e->modifiers() == Qt::ControlModifier) {
|
} else if ((e->key() == Qt::Key_O)
|
||||||
|
&& (e->modifiers() == Qt::ControlModifier)) {
|
||||||
chooseAttach();
|
chooseAttach();
|
||||||
} else {
|
} else {
|
||||||
e->ignore();
|
e->ignore();
|
||||||
|
@ -6959,7 +7045,9 @@ void HistoryWidget::updatePinnedViewer() {
|
||||||
MsgId(0), // topicRootId
|
MsgId(0), // topicRootId
|
||||||
_migrated ? _migrated->peer.get() : nullptr);
|
_migrated ? _migrated->peer.get() : nullptr);
|
||||||
}
|
}
|
||||||
if (_pinnedClickedId && _minPinnedId && _minPinnedId >= _pinnedClickedId) {
|
if (_pinnedClickedId
|
||||||
|
&& _minPinnedId
|
||||||
|
&& (_minPinnedId >= _pinnedClickedId)) {
|
||||||
// After click on the last pinned message we should the top one.
|
// After click on the last pinned message we should the top one.
|
||||||
_pinnedTracker->trackAround(ServerMaxMsgId - 1);
|
_pinnedTracker->trackAround(ServerMaxMsgId - 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -7441,7 +7529,9 @@ bool HistoryWidget::sendExistingDocument(
|
||||||
//_saveDraftText = true;
|
//_saveDraftText = true;
|
||||||
//_saveDraftStart = crl::now();
|
//_saveDraftStart = crl::now();
|
||||||
//saveDraft();
|
//saveDraft();
|
||||||
saveCloudDraft(); // won't be needed if SendInlineBotResult will clear the cloud draft
|
|
||||||
|
// won't be needed if SendInlineBotResult will clear the cloud draft
|
||||||
|
saveCloudDraft();
|
||||||
}
|
}
|
||||||
|
|
||||||
hideSelectorControlsAnimated();
|
hideSelectorControlsAnimated();
|
||||||
|
@ -7788,7 +7878,8 @@ bool HistoryWidget::lastForceReplyReplied(const FullMsgId &replyTo) const {
|
||||||
return _peer
|
return _peer
|
||||||
&& (replyTo.peer == _peer->id)
|
&& (replyTo.peer == _peer->id)
|
||||||
&& _keyboard->forceReply()
|
&& _keyboard->forceReply()
|
||||||
&& _keyboard->forMsgId() == FullMsgId(_peer->id, _history->lastKeyboardId)
|
&& (_keyboard->forMsgId()
|
||||||
|
== FullMsgId(_peer->id, _history->lastKeyboardId))
|
||||||
&& _keyboard->forMsgId().msg == replyTo.msg;
|
&& _keyboard->forMsgId().msg == replyTo.msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7820,7 +7911,8 @@ bool HistoryWidget::cancelReply(bool lastKeyboardUsed) {
|
||||||
updateControlsVisibility();
|
updateControlsVisibility();
|
||||||
updateControlsGeometry();
|
updateControlsGeometry();
|
||||||
update();
|
update();
|
||||||
} else if (const auto localDraft = (_history ? _history->localDraft({}) : nullptr)) {
|
} else if (const auto localDraft
|
||||||
|
= (_history ? _history->localDraft({}) : nullptr)) {
|
||||||
if (localDraft->reply) {
|
if (localDraft->reply) {
|
||||||
if (localDraft->textWithTags.text.isEmpty()) {
|
if (localDraft->textWithTags.text.isEmpty()) {
|
||||||
_history->clearLocalDraft({});
|
_history->clearLocalDraft({});
|
||||||
|
@ -7852,7 +7944,8 @@ void HistoryWidget::cancelReplyAfterMediaSend(bool lastKeyboardUsed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int HistoryWidget::countMembersDropdownHeightMax() const {
|
int HistoryWidget::countMembersDropdownHeightMax() const {
|
||||||
int result = height() - st::membersInnerDropdown.padding.top() - st::membersInnerDropdown.padding.bottom();
|
auto result = height()
|
||||||
|
- rect::m::sum::v(st::membersInnerDropdown.padding);
|
||||||
result -= _tabbedSelectorToggle->height();
|
result -= _tabbedSelectorToggle->height();
|
||||||
accumulate_min(result, st::membersInnerHeightMax);
|
accumulate_min(result, st::membersInnerHeightMax);
|
||||||
return result;
|
return result;
|
||||||
|
@ -7949,8 +8042,9 @@ void HistoryWidget::handlePeerUpdate() {
|
||||||
if (_peer->isChat() && _peer->asChat()->noParticipantInfo()) {
|
if (_peer->isChat() && _peer->asChat()->noParticipantInfo()) {
|
||||||
session().api().requestFullPeer(_peer);
|
session().api().requestFullPeer(_peer);
|
||||||
} else if (_peer->isUser()
|
} else if (_peer->isUser()
|
||||||
&& (_peer->asUser()->blockStatus() == UserData::BlockStatus::Unknown
|
&& ((_peer->asUser()->blockStatus() == UserData::BlockStatus::Unknown)
|
||||||
|| _peer->asUser()->callsStatus() == UserData::CallsStatus::Unknown)) {
|
|| (_peer->asUser()->callsStatus()
|
||||||
|
== UserData::CallsStatus::Unknown))) {
|
||||||
session().api().requestFullPeer(_peer);
|
session().api().requestFullPeer(_peer);
|
||||||
} else if (auto channel = _peer->asMegagroup()) {
|
} else if (auto channel = _peer->asMegagroup()) {
|
||||||
if (!channel->mgInfo->botStatus) {
|
if (!channel->mgInfo->botStatus) {
|
||||||
|
@ -7963,7 +8057,8 @@ void HistoryWidget::handlePeerUpdate() {
|
||||||
if (!_showAnimation) {
|
if (!_showAnimation) {
|
||||||
const auto blockChanged = (_unblock->isHidden() == isBlocked());
|
const auto blockChanged = (_unblock->isHidden() == isBlocked());
|
||||||
if (blockChanged
|
if (blockChanged
|
||||||
|| (!isBlocked() && _joinChannel->isHidden() == isJoinChannel())) {
|
|| (!isBlocked()
|
||||||
|
&& (_joinChannel->isHidden() == isJoinChannel()))) {
|
||||||
resize = true;
|
resize = true;
|
||||||
}
|
}
|
||||||
if (updateCanSendMessage()) {
|
if (updateCanSendMessage()) {
|
||||||
|
@ -8084,7 +8179,8 @@ void HistoryWidget::clearSelected() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryItem *HistoryWidget::getItemFromHistoryOrMigrated(MsgId genericMsgId) const {
|
HistoryItem *HistoryWidget::getItemFromHistoryOrMigrated(
|
||||||
|
MsgId genericMsgId) const {
|
||||||
return (genericMsgId < 0 && -genericMsgId < ServerMaxMsgId && _migrated)
|
return (genericMsgId < 0 && -genericMsgId < ServerMaxMsgId && _migrated)
|
||||||
? session().data().message(_migrated->peer, -genericMsgId)
|
? session().data().message(_migrated->peer, -genericMsgId)
|
||||||
: _peer
|
: _peer
|
||||||
|
@ -8376,7 +8472,8 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
: 0.;
|
: 0.;
|
||||||
auto to = QRect(
|
auto to = QRect(
|
||||||
replyLeft,
|
replyLeft,
|
||||||
backy + (st::historyReplyHeight - st::historyReplyPreview) / 2,
|
(st::historyReplyHeight - st::historyReplyPreview) / 2
|
||||||
|
+ backy,
|
||||||
st::historyReplyPreview,
|
st::historyReplyPreview,
|
||||||
st::historyReplyPreview);
|
st::historyReplyPreview);
|
||||||
p.drawPixmap(to.x(), to.y(), preview->pixSingle(
|
p.drawPixmap(to.x(), to.y(), preview->pixSingle(
|
||||||
|
@ -8408,14 +8505,26 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
if (_editMsgId) {
|
if (_editMsgId) {
|
||||||
paintEditHeader(p, rect, replyLeft, backy);
|
paintEditHeader(p, rect, replyLeft, backy);
|
||||||
} else {
|
} else {
|
||||||
_replyToName.drawElided(p, replyLeft, backy + st::msgReplyPadding.top(), width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right());
|
_replyToName.drawElided(
|
||||||
|
p,
|
||||||
|
replyLeft,
|
||||||
|
backy + st::msgReplyPadding.top(),
|
||||||
|
width()
|
||||||
|
- replyLeft
|
||||||
|
- _fieldBarCancel->width()
|
||||||
|
- st::msgReplyPadding.right());
|
||||||
}
|
}
|
||||||
p.setPen(st::historyComposeAreaFg);
|
p.setPen(st::historyComposeAreaFg);
|
||||||
_replyEditMsgText.draw(p, {
|
_replyEditMsgText.draw(p, {
|
||||||
.position = QPoint(
|
.position = QPoint(
|
||||||
replyLeft,
|
replyLeft,
|
||||||
backy + st::msgReplyPadding.top() + st::msgServiceNameFont->height),
|
st::msgReplyPadding.top()
|
||||||
.availableWidth = width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right(),
|
+ st::msgServiceNameFont->height
|
||||||
|
+ backy),
|
||||||
|
.availableWidth = width()
|
||||||
|
- replyLeft
|
||||||
|
- _fieldBarCancel->width()
|
||||||
|
- st::msgReplyPadding.right(),
|
||||||
.palette = &st::historyComposeAreaPalette,
|
.palette = &st::historyComposeAreaPalette,
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = now,
|
.now = now,
|
||||||
|
@ -8426,10 +8535,22 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
} else {
|
} else {
|
||||||
p.setFont(st::msgDateFont);
|
p.setFont(st::msgDateFont);
|
||||||
p.setPen(st::historyComposeAreaFgService);
|
p.setPen(st::historyComposeAreaFgService);
|
||||||
p.drawText(replyLeft, backy + (st::historyReplyHeight - st::msgDateFont->height) / 2 + st::msgDateFont->ascent, st::msgDateFont->elided(tr::lng_profile_loading(tr::now), width() - replyLeft - _fieldBarCancel->width() - st::msgReplyPadding.right()));
|
p.drawText(
|
||||||
|
replyLeft,
|
||||||
|
backy
|
||||||
|
+ (st::historyReplyHeight - st::msgDateFont->height) / 2
|
||||||
|
+ st::msgDateFont->ascent,
|
||||||
|
st::msgDateFont->elided(
|
||||||
|
tr::lng_profile_loading(tr::now),
|
||||||
|
width()
|
||||||
|
- replyLeft
|
||||||
|
- _fieldBarCancel->width()
|
||||||
|
- st::msgReplyPadding.right()));
|
||||||
}
|
}
|
||||||
} else if (hasForward) {
|
} else if (hasForward) {
|
||||||
st::historyForwardIcon.paint(p, st::historyReplyIconPosition + QPoint(0, backy), width());
|
st::historyForwardIcon.paint(
|
||||||
|
p,
|
||||||
|
st::historyReplyIconPosition + QPoint(0, backy), width());
|
||||||
const auto x = st::historyReplySkip;
|
const auto x = st::historyReplySkip;
|
||||||
const auto available = width()
|
const auto available = width()
|
||||||
- x
|
- x
|
||||||
|
@ -8439,27 +8560,40 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int top) const {
|
void HistoryWidget::paintEditHeader(
|
||||||
if (!rect.intersects(myrtlrect(left, top, width() - left, st::normalFont->height))) {
|
Painter &p,
|
||||||
|
const QRect &rect,
|
||||||
|
int left,
|
||||||
|
int top) const {
|
||||||
|
if (!rect.intersects(
|
||||||
|
myrtlrect(left, top, width() - left, st::normalFont->height))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setFont(st::msgServiceNameFont);
|
p.setFont(st::msgServiceNameFont);
|
||||||
p.drawTextLeft(left, top + st::msgReplyPadding.top(), width(), tr::lng_edit_message(tr::now));
|
p.drawTextLeft(
|
||||||
|
left,
|
||||||
|
top + st::msgReplyPadding.top(),
|
||||||
|
width(),
|
||||||
|
tr::lng_edit_message(tr::now));
|
||||||
|
|
||||||
if (!_replyEditMsg
|
if (!_replyEditMsg
|
||||||
|| _replyEditMsg->history()->peer->canEditMessagesIndefinitely()) {
|
|| _replyEditMsg->history()->peer->canEditMessagesIndefinitely()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString editTimeLeftText;
|
auto editTimeLeftText = QString();
|
||||||
int updateIn = -1;
|
auto updateIn = int(-1);
|
||||||
auto timeSinceMessage = ItemDateTime(_replyEditMsg).msecsTo(QDateTime::currentDateTime());
|
auto timeSinceMessage = ItemDateTime(_replyEditMsg).msecsTo(
|
||||||
auto editTimeLeft = (session().serverConfig().editTimeLimit * 1000LL) - timeSinceMessage;
|
QDateTime::currentDateTime());
|
||||||
|
auto editTimeLeft = (session().serverConfig().editTimeLimit * 1000LL)
|
||||||
|
- timeSinceMessage;
|
||||||
if (editTimeLeft < 2) {
|
if (editTimeLeft < 2) {
|
||||||
editTimeLeftText = u"0:00"_q;
|
editTimeLeftText = u"0:00"_q;
|
||||||
} else if (editTimeLeft > kDisplayEditTimeWarningMs) {
|
} else if (editTimeLeft > kDisplayEditTimeWarningMs) {
|
||||||
updateIn = static_cast<int>(qMin(editTimeLeft - kDisplayEditTimeWarningMs, qint64(kFullDayInMs)));
|
updateIn = static_cast<int>(qMin(
|
||||||
|
editTimeLeft - kDisplayEditTimeWarningMs,
|
||||||
|
qint64(kFullDayInMs)));
|
||||||
} else {
|
} else {
|
||||||
updateIn = static_cast<int>(editTimeLeft % 1000);
|
updateIn = static_cast<int>(editTimeLeft % 1000);
|
||||||
if (!updateIn) {
|
if (!updateIn) {
|
||||||
|
@ -8468,24 +8602,33 @@ void HistoryWidget::paintEditHeader(Painter &p, const QRect &rect, int left, int
|
||||||
++updateIn;
|
++updateIn;
|
||||||
|
|
||||||
editTimeLeft = (editTimeLeft - 1) / 1000; // seconds
|
editTimeLeft = (editTimeLeft - 1) / 1000; // seconds
|
||||||
editTimeLeftText = u"%1:%2"_q.arg(editTimeLeft / 60).arg(editTimeLeft % 60, 2, 10, QChar('0'));
|
editTimeLeftText = u"%1:%2"_q
|
||||||
|
.arg(editTimeLeft / 60)
|
||||||
|
.arg(editTimeLeft % 60, 2, 10, QChar('0'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restart timer only if we are sure that we've painted the whole timer.
|
// Restart timer only if we are sure that we've painted the whole timer.
|
||||||
if (rect.contains(myrtlrect(left, top, width() - left, st::normalFont->height)) && updateIn > 0) {
|
if (rect.contains(
|
||||||
|
myrtlrect(left, top, width() - left, st::normalFont->height))
|
||||||
|
&& (updateIn > 0)) {
|
||||||
_updateEditTimeLeftDisplay.callOnce(updateIn);
|
_updateEditTimeLeftDisplay.callOnce(updateIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!editTimeLeftText.isEmpty()) {
|
if (!editTimeLeftText.isEmpty()) {
|
||||||
p.setFont(st::normalFont);
|
p.setFont(st::normalFont);
|
||||||
p.setPen(st::historyComposeAreaFgService);
|
p.setPen(st::historyComposeAreaFgService);
|
||||||
p.drawText(left + st::msgServiceNameFont->width(tr::lng_edit_message(tr::now)) + st::normalFont->spacew, top + st::msgReplyPadding.top() + st::msgServiceNameFont->ascent, editTimeLeftText);
|
p.drawText(
|
||||||
|
left
|
||||||
|
+ st::msgServiceNameFont->width(tr::lng_edit_message(tr::now))
|
||||||
|
+ st::normalFont->spacew,
|
||||||
|
top + st::msgReplyPadding.top() + st::msgServiceNameFont->ascent,
|
||||||
|
editTimeLeftText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryWidget::paintShowAnimationFrame() {
|
bool HistoryWidget::paintShowAnimationFrame() {
|
||||||
if (_showAnimation) {
|
if (_showAnimation) {
|
||||||
QPainter p(this);
|
auto p = QPainter(this);
|
||||||
_showAnimation->paintContents(p);
|
_showAnimation->paintContents(p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8521,7 +8664,8 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const auto w = st::msgServiceFont->width(tr::lng_willbe_history(tr::now))
|
const auto w = 0
|
||||||
|
+ st::msgServiceFont->width(tr::lng_willbe_history(tr::now))
|
||||||
+ st::msgPadding.left()
|
+ st::msgPadding.left()
|
||||||
+ st::msgPadding.right();
|
+ st::msgPadding.right();
|
||||||
const auto h = st::msgServiceFont->height
|
const auto h = st::msgServiceFont->height
|
||||||
|
@ -8542,10 +8686,11 @@ void HistoryWidget::paintEvent(QPaintEvent *e) {
|
||||||
|
|
||||||
p.setPen(st->msgServiceFg());
|
p.setPen(st->msgServiceFg());
|
||||||
p.setFont(st::msgServiceFont->f);
|
p.setFont(st::msgServiceFont->f);
|
||||||
p.drawTextLeft(tr.left() + st::msgPadding.left(), tr.top() + st::msgServicePadding.top(), width(), tr::lng_willbe_history(tr::now));
|
p.drawTextLeft(
|
||||||
|
tr.left() + st::msgPadding.left(),
|
||||||
//AssertIsDebug();
|
tr.top() + st::msgServicePadding.top(),
|
||||||
//Ui::EmptyUserpic::PaintRepliesMessages(p, width() / 4, width() / 4, width(), width() / 2);
|
width(),
|
||||||
|
tr::lng_willbe_history(tr::now));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue