Don't show report spam over the chat history.

This commit is contained in:
John Preston 2019-05-30 21:53:13 +03:00
parent a968e112e8
commit 619aca04f9
3 changed files with 49 additions and 21 deletions

View File

@ -260,10 +260,10 @@ void ReportSpamPanel::resizeEvent(QResizeEvent *e) {
void ReportSpamPanel::paintEvent(QPaintEvent *e) { void ReportSpamPanel::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
p.fillRect(QRect(0, 0, width(), height() - st::lineWidth), st::reportSpamBg); p.fillRect(QRect(0, 0, width(), height() - st::lineWidth), st::historyPinnedBg);
p.fillRect(Adaptive::OneColumn() ? 0 : st::lineWidth, height() - st::lineWidth, width() - (Adaptive::OneColumn() ? 0 : st::lineWidth), st::lineWidth, st::shadowFg); p.fillRect(Adaptive::OneColumn() ? 0 : st::lineWidth, height() - st::lineWidth, width() - (Adaptive::OneColumn() ? 0 : st::lineWidth), st::lineWidth, st::shadowFg);
if (!_clear->isHidden()) { if (!_clear->isHidden()) {
p.setPen(st::reportSpamFg); p.setPen(st::historyComposeAreaFg);
p.setFont(st::msgFont); p.setFont(st::msgFont);
p.drawText(QRect(_report->x(), (_clear->y() - st::msgFont->height) / 2, _report->width(), st::msgFont->height), lang(lng_report_spam_thanks), style::al_top); p.drawText(QRect(_report->x(), (_clear->y() - st::msgFont->height) / 2, _report->width(), st::msgFont->height), lang(lng_report_spam_thanks), style::al_top);
} }
@ -1061,6 +1061,9 @@ void HistoryWidget::orderWidgets() {
if (_reportSpamPanel) { if (_reportSpamPanel) {
_reportSpamPanel->raise(); _reportSpamPanel->raise();
} }
if (_pinnedBar) {
_pinnedBar->shadow->raise();
}
_topShadow->raise(); _topShadow->raise();
if (_membersDropdown) { if (_membersDropdown) {
_membersDropdown->raise(); _membersDropdown->raise();
@ -3748,7 +3751,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
_kbScroll->hide(); _kbScroll->hide();
_kbShown = false; _kbShown = false;
_field->setMaxHeight(st::historyComposeFieldMaxHeight); _field->setMaxHeight(computeMaxFieldHeight());
_kbReplyTo = nullptr; _kbReplyTo = nullptr;
if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_editMsgId && !_replyToId) { if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_editMsgId && !_replyToId) {
@ -3771,7 +3774,7 @@ void HistoryWidget::toggleKeyboard(bool manual) {
_kbScroll->hide(); _kbScroll->hide();
_kbShown = false; _kbShown = false;
_field->setMaxHeight(st::historyComposeFieldMaxHeight); _field->setMaxHeight(computeMaxFieldHeight());
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) _kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply())
? session().data().message(_keyboard->forMsgId()) ? session().data().message(_keyboard->forMsgId())
@ -3789,8 +3792,9 @@ void HistoryWidget::toggleKeyboard(bool manual) {
_kbScroll->show(); _kbScroll->show();
_kbShown = true; _kbShown = true;
int32 maxh = qMin(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2)); const auto maxheight = computeMaxFieldHeight();
_field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh); const auto kbheight = qMin(_keyboard->height(), maxheight - (maxheight / 2));
_field->setMaxHeight(maxheight - kbheight);
_kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply()) _kbReplyTo = (_peer->isChat() || _peer->isChannel() || _keyboard->forceReply())
? session().data().message(_keyboard->forMsgId()) ? session().data().message(_keyboard->forMsgId())
@ -3919,7 +3923,7 @@ void HistoryWidget::recountChatWidth() {
void HistoryWidget::moveFieldControls() { void HistoryWidget::moveFieldControls() {
auto keyboardHeight = 0; auto keyboardHeight = 0;
auto bottom = height(); auto bottom = height();
auto maxKeyboardHeight = st::historyComposeFieldMaxHeight - _field->height(); auto maxKeyboardHeight = computeMaxFieldHeight() - _field->height();
_keyboard->resizeToWidth(width(), maxKeyboardHeight); _keyboard->resizeToWidth(width(), maxKeyboardHeight);
if (_kbShown) { if (_kbShown) {
keyboardHeight = qMin(_keyboard->height(), maxKeyboardHeight); keyboardHeight = qMin(_keyboard->height(), maxKeyboardHeight);
@ -4810,12 +4814,16 @@ void HistoryWidget::updateControlsGeometry() {
moveFieldControls(); moveFieldControls();
auto scrollAreaTop = _topBar->bottomNoMargins(); const auto pinnedBarTop = _topBar->bottomNoMargins();
if (_pinnedBar) { if (_pinnedBar) {
_pinnedBar->cancel->moveToLeft(width() - _pinnedBar->cancel->width(), scrollAreaTop); _pinnedBar->cancel->moveToLeft(width() - _pinnedBar->cancel->width(), pinnedBarTop);
scrollAreaTop += st::historyReplyHeight; _pinnedBar->shadow->setGeometryToLeft(0, pinnedBarTop + st::historyReplyHeight, width(), st::lineWidth);
_pinnedBar->shadow->setGeometryToLeft(0, scrollAreaTop, width(), st::lineWidth);
} }
const auto reportSpamTop = pinnedBarTop + (_pinnedBar ? st::historyReplyHeight : 0);
if (_reportSpamPanel) {
_reportSpamPanel->setGeometryToLeft(0, reportSpamTop, width(), _reportSpamPanel->height());
}
const auto scrollAreaTop = reportSpamTop + (_reportSpamPanel ? (_reportSpamPanel->height() - st::lineWidth) : 0);
if (_scroll->y() != scrollAreaTop) { if (_scroll->y() != scrollAreaTop) {
_scroll->moveToLeft(0, scrollAreaTop); _scroll->moveToLeft(0, scrollAreaTop);
_fieldAutocomplete->setBoundings(_scroll->geometry()); _fieldAutocomplete->setBoundings(_scroll->geometry());
@ -4823,9 +4831,6 @@ void HistoryWidget::updateControlsGeometry() {
_supportAutocomplete->setBoundings(_scroll->geometry()); _supportAutocomplete->setBoundings(_scroll->geometry());
} }
} }
if (_reportSpamPanel) {
_reportSpamPanel->setGeometryToLeft(0, _scroll->y(), width(), _reportSpamPanel->height());
}
updateHistoryGeometry(false, false, { ScrollChangeAdd, App::main() ? App::main()->contentScrollAddToY() : 0 }); updateHistoryGeometry(false, false, { ScrollChangeAdd, App::main() ? App::main()->contentScrollAddToY() : 0 });
@ -4970,6 +4975,12 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S
} }
auto newScrollHeight = height() - _topBar->height(); auto newScrollHeight = height() - _topBar->height();
if (_pinnedBar) {
newScrollHeight -= st::historyReplyHeight;
}
if (_reportSpamPanel) {
newScrollHeight -= _reportSpamPanel->height() - st::lineWidth;
}
if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) { if (!editingMessage() && (isBlocked() || isBotStart() || isJoinChannel() || isMuteUnmute())) {
newScrollHeight -= _unblock->height(); newScrollHeight -= _unblock->height();
if (_aboutProxyPromotion) { if (_aboutProxyPromotion) {
@ -4989,8 +5000,8 @@ void HistoryWidget::updateHistoryGeometry(bool initial, bool loadedDown, const S
newScrollHeight -= _kbScroll->height(); newScrollHeight -= _kbScroll->height();
} }
} }
if (_pinnedBar) { if (newScrollHeight <= 0) {
newScrollHeight -= st::historyReplyHeight; return;
} }
auto wasScrollTop = _scroll->scrollTop(); auto wasScrollTop = _scroll->scrollTop();
auto wasScrollTopMax = _scroll->scrollTopMax(); auto wasScrollTopMax = _scroll->scrollTopMax();
@ -5189,8 +5200,9 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->hide(); _botCommandStart->hide();
} }
int32 maxh = hasMarkup ? qMin(_keyboard->height(), st::historyComposeFieldMaxHeight - (st::historyComposeFieldMaxHeight / 2)) : 0; const auto maxheight = computeMaxFieldHeight();
_field->setMaxHeight(st::historyComposeFieldMaxHeight - maxh); const auto kbheight = hasMarkup ? qMin(_keyboard->height(), maxheight - (maxheight / 2)) : 0;
_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())
@ -5207,7 +5219,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
_botKeyboardShow->show(); _botKeyboardShow->show();
_botCommandStart->hide(); _botCommandStart->hide();
} }
_field->setMaxHeight(st::historyComposeFieldMaxHeight); _field->setMaxHeight(computeMaxFieldHeight());
_kbShown = false; _kbShown = false;
_kbReplyTo = nullptr; _kbReplyTo = nullptr;
if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) { if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) {
@ -5223,7 +5235,7 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
_botKeyboardShow->hide(); _botKeyboardShow->hide();
_botCommandStart->show(); _botCommandStart->show();
} }
_field->setMaxHeight(st::historyComposeFieldMaxHeight); _field->setMaxHeight(computeMaxFieldHeight());
_kbShown = false; _kbShown = false;
_kbReplyTo = nullptr; _kbReplyTo = nullptr;
if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId && !_editMsgId) { if (!readyToForward() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId && !_editMsgId) {
@ -5235,6 +5247,22 @@ void HistoryWidget::updateBotKeyboard(History *h, bool force) {
update(); update();
} }
int HistoryWidget::computeMaxFieldHeight() const {
const auto available = height()
- _topBar->height()
- (_reportSpamPanel ? _reportSpamPanel->height() - st::lineWidth : 0)
- (_pinnedBar ? st::historyReplyHeight : 0)
- ((_editMsgId
|| replyToId()
|| readyToForward()
|| (_previewData && _previewData->pendingTill >= 0))
? st::historyReplyHeight
: 0)
- (2 * st::historySendPadding)
- st::historyReplyHeight; // at least this height for history.
return std::min(st::historyComposeFieldMaxHeight, available);
}
void HistoryWidget::updateHistoryDownPosition() { void HistoryWidget::updateHistoryDownPosition() {
// _historyDown is a child widget of _scroll, not me. // _historyDown is a child widget of _scroll, not me.
auto top = anim::interpolate(0, _historyDown->height() + st::historyToDownPosition.y(), _historyDownShown.value(_historyDownIsShown ? 1. : 0.)); auto top = anim::interpolate(0, _historyDown->height() + st::historyToDownPosition.y(), _historyDownShown.value(_historyDownIsShown ? 1. : 0.));

View File

@ -367,6 +367,7 @@ private:
void refreshAboutProxyPromotion(); void refreshAboutProxyPromotion();
void unreadCountUpdated(); void unreadCountUpdated();
[[nodiscard]] int computeMaxFieldHeight() const;
void toggleMuteUnmute(); void toggleMuteUnmute();
void toggleKeyboard(bool manual = true); void toggleKeyboard(bool manual = true);
void startBotCommand(); void startBotCommand();

View File

@ -716,7 +716,6 @@ HistoryItem *Instance::roundVideoItem() const {
&& !data->streamed->info.video.size.isEmpty()) && !data->streamed->info.video.size.isEmpty())
? Auth().data().message(data->streamed->id.contextId()) ? Auth().data().message(data->streamed->id.contextId())
: nullptr; : nullptr;
} }
void Instance::requestRoundVideoResize() const { void Instance::requestRoundVideoResize() const {