mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-03-25 04:38:23 +00:00
report spam panel added
This commit is contained in:
parent
c45d9e9860
commit
28e09ab39e
@ -485,6 +485,9 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org
|
||||
"lng_in_dlg_sticker" = "Sticker";
|
||||
"lng_in_dlg_sticker_emoji" = "{emoji} (sticker)";
|
||||
|
||||
"lng_report_spam" = "Report Spam";
|
||||
"lng_report_spam_hide" = "Hide";
|
||||
|
||||
"lng_send_button" = "Send";
|
||||
"lng_message_ph" = "Write a message..";
|
||||
"lng_record_cancel" = "Release outside this field to cancel";
|
||||
|
@ -1072,7 +1072,34 @@ textRectMargins: margins(-2px, -1px, -2px, -1px);
|
||||
taMsgField: flatTextarea(taDefFlat) {
|
||||
font: msgFont;
|
||||
}
|
||||
maxFieldHeight: 243px;
|
||||
maxFieldHeight: 220px;
|
||||
// historyMinHeight: 56px;
|
||||
|
||||
reportSpamButton: flatButton(topBarActionButton) {
|
||||
textTop: 6px;
|
||||
overTextTop: 6px;
|
||||
downTextTop: 7px;
|
||||
|
||||
width: -50px;
|
||||
height: 30px;
|
||||
|
||||
bgColor: #888;
|
||||
overBgColor: #7b7b7b;
|
||||
downBgColor: #7b7b7b;
|
||||
}
|
||||
reportSpamHide: flatButton(topBarButton) {
|
||||
height: 46px;
|
||||
|
||||
textTop: 15px;
|
||||
overTextTop: 15px;
|
||||
downTextTop: 16px;
|
||||
|
||||
bgColor: transparent;
|
||||
overBgColor: transparent;
|
||||
downBgColor: transparent;
|
||||
}
|
||||
reportSpamPadding: size(12px, 8px);
|
||||
reportSpamBg: #ffffffc0;
|
||||
|
||||
newMsgSound: ':/gui/art/newmsg.wav';
|
||||
|
||||
|
@ -2220,8 +2220,11 @@ QString formatSizeText(qint64 size) {
|
||||
qint64 sizeTenthMb = (size * 10 / (1024 * 1024));
|
||||
return QString::number(sizeTenthMb / 10) + '.' + QString::number(sizeTenthMb % 10) + qsl(" MB");
|
||||
}
|
||||
qint64 sizeTenthKb = (size * 10 / 1024);
|
||||
return QString::number(sizeTenthKb / 10) + '.' + QString::number(sizeTenthKb % 10) + qsl(" KB");
|
||||
if (size >= 1024) {
|
||||
qint64 sizeTenthKb = (size * 10 / 1024);
|
||||
return QString::number(sizeTenthKb / 10) + '.' + QString::number(sizeTenthKb % 10) + qsl(" KB");
|
||||
}
|
||||
return QString::number(size) + qsl(" B");
|
||||
}
|
||||
|
||||
QString formatDownloadText(qint64 ready, qint64 total) {
|
||||
@ -2231,11 +2234,15 @@ QString formatDownloadText(qint64 ready, qint64 total) {
|
||||
readyStr = QString::number(readyTenthMb / 10) + '.' + QString::number(readyTenthMb % 10);
|
||||
totalStr = QString::number(totalTenthMb / 10) + '.' + QString::number(totalTenthMb % 10);
|
||||
mb = qsl("MB");
|
||||
} else {
|
||||
} else if (total >= 1024) {
|
||||
qint64 readyKb = (ready / 1024), totalKb = (total / 1024);
|
||||
readyStr = QString::number(readyKb);
|
||||
totalStr = QString::number(totalKb);
|
||||
mb = qsl("KB");
|
||||
} else {
|
||||
readyStr = QString::number(ready);
|
||||
totalStr = QString::number(total);
|
||||
mb = qsl("B");
|
||||
}
|
||||
return lng_save_downloaded(lt_ready, readyStr, lt_total, totalStr, lt_mb, mb);
|
||||
}
|
||||
|
@ -1636,6 +1636,29 @@ void MessageField::focusInEvent(QFocusEvent *e) {
|
||||
emit focused();
|
||||
}
|
||||
|
||||
ReportSpamPanel::ReportSpamPanel(HistoryWidget *parent) : TWidget(parent),
|
||||
_report(this, lang(lng_report_spam), st::reportSpamButton), _hide(this, lang(lng_report_spam_hide), st::reportSpamHide) {
|
||||
resize(parent->width(), _hide.height() + st::titleShadow);
|
||||
|
||||
connect(&_report, SIGNAL(clicked()), this, SIGNAL(reportClicked()));
|
||||
connect(&_hide, SIGNAL(clicked()), this, SIGNAL(hideClicked()));
|
||||
}
|
||||
|
||||
void ReportSpamPanel::resizeEvent(QResizeEvent *e) {
|
||||
_report.moveToLeft(st::reportSpamPadding.width(), st::reportSpamPadding.height(), width());
|
||||
_hide.moveToRight(0, 0, width());
|
||||
}
|
||||
|
||||
void ReportSpamPanel::paintEvent(QPaintEvent *e) {
|
||||
Painter p(this);
|
||||
p.fillRect(QRect(0, 0, width(), height() - st::titleShadow), st::reportSpamBg->b);
|
||||
if (cWideMode()) {
|
||||
p.fillRect(st::titleShadow, height() - st::titleShadow, width() - st::titleShadow, st::titleShadow, st::titleShadowColor->b);
|
||||
} else {
|
||||
p.fillRect(0, height() - st::titleShadow, width(), st::titleShadow, st::titleShadowColor->b);
|
||||
}
|
||||
}
|
||||
|
||||
BotKeyboard::BotKeyboard() : _wasForMsgId(0), _height(0), _maxOuterHeight(0), _maximizeSize(false), _singleUse(false), _forceReply(false),
|
||||
_sel(-1), _down(-1), _hoverAnim(animFunc(this, &BotKeyboard::hoverStep)), _st(&st::botKbButton) {
|
||||
setGeometry(0, 0, _st->margin, _st->margin);
|
||||
@ -2217,6 +2240,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
, _histInited(false)
|
||||
, _toHistoryEnd(this, st::historyToEnd)
|
||||
, _attachMention(this)
|
||||
, _reportSpamPanel(this)
|
||||
, _send(this, lang(lng_send_button), st::btnSend)
|
||||
, _unblock(this, lang(lng_unblock_button), st::btnUnblock)
|
||||
, _botStart(this, lang(lng_bot_start), st::btnSend)
|
||||
@ -2329,6 +2353,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
|
||||
_reportSpamPanel.move(0, 0);
|
||||
_reportSpamPanel.hide();
|
||||
|
||||
_attachDocument.hide();
|
||||
_attachPhoto.hide();
|
||||
_attachEmoji.hide();
|
||||
@ -2920,12 +2947,10 @@ void HistoryWidget::updateReportSpamStatus() {
|
||||
_reportSpamStatus = ReportSpamShowButton;
|
||||
return;
|
||||
}
|
||||
if (!cContactsReceived()) {
|
||||
if ((!_history->loadedAtTop() && (_history->size() < 2 || _history->size() == 2 && _history->at(1)->size() < 2)) || !cContactsReceived() || _firstLoadRequest) {
|
||||
_reportSpamStatus = ReportSpamUnknown;
|
||||
} else if (_peer->chat) {
|
||||
if (_firstLoadRequest && !_peer->asChat()->inviterForSpamReport) {
|
||||
_reportSpamStatus = ReportSpamUnknown;
|
||||
} else if (_peer->asChat()->inviterForSpamReport > 0) {
|
||||
if (_peer->asChat()->inviterForSpamReport > 0) {
|
||||
UserData *user = App::userLoaded(_peer->asChat()->inviterForSpamReport);
|
||||
if (user && user->contact > 0) {
|
||||
_reportSpamStatus = ReportSpamNoButton;
|
||||
@ -2939,28 +2964,24 @@ void HistoryWidget::updateReportSpamStatus() {
|
||||
if (_peer->asUser()->contact > 0) {
|
||||
_reportSpamStatus = ReportSpamNoButton;
|
||||
} else {
|
||||
if (_firstLoadRequest) {
|
||||
_reportSpamStatus = ReportSpamUnknown;
|
||||
} else {
|
||||
bool anyFound = false, outFound = false;
|
||||
for (int32 i = 0, l = _history->size(); i < l; ++i) {
|
||||
for (int32 j = 0, c = _history->at(i)->size(); j < c; ++j) {
|
||||
anyFound = true;
|
||||
if (_history->at(i)->at(j)->out()) {
|
||||
outFound = true;
|
||||
break;
|
||||
}
|
||||
bool anyFound = false, outFound = false;
|
||||
for (int32 i = 0, l = _history->size(); i < l; ++i) {
|
||||
for (int32 j = 0, c = _history->at(i)->size(); j < c; ++j) {
|
||||
anyFound = true;
|
||||
if (_history->at(i)->at(j)->out()) {
|
||||
outFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (anyFound) {
|
||||
if (outFound) {
|
||||
_reportSpamStatus = ReportSpamNoButton;
|
||||
} else {
|
||||
_reportSpamStatus = ReportSpamShowButton;
|
||||
}
|
||||
}
|
||||
if (anyFound) {
|
||||
if (outFound) {
|
||||
_reportSpamStatus = ReportSpamNoButton;
|
||||
} else {
|
||||
_reportSpamStatus = ReportSpamUnknown;
|
||||
_reportSpamStatus = ReportSpamShowButton;
|
||||
}
|
||||
} else {
|
||||
_reportSpamStatus = ReportSpamUnknown;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2978,6 +2999,7 @@ void HistoryWidget::updateReportSpamStatus() {
|
||||
|
||||
void HistoryWidget::updateControlsVisibility() {
|
||||
if (!_history || _showAnim.animating()) {
|
||||
_reportSpamPanel.hide();
|
||||
_scroll.hide();
|
||||
_kbScroll.hide();
|
||||
_send.hide();
|
||||
@ -3004,6 +3026,11 @@ void HistoryWidget::updateControlsVisibility() {
|
||||
} else {
|
||||
_scroll.show();
|
||||
}
|
||||
if (_reportSpamStatus == ReportSpamShowButton) {
|
||||
_reportSpamPanel.show();
|
||||
} else {
|
||||
_reportSpamPanel.hide();
|
||||
}
|
||||
if ((_peer->chat && !_peer->asChat()->forbidden && !_peer->asChat()->left) || (!_peer->chat && _peer->asUser()->access != UserNoAccess)) {
|
||||
checkMentionDropdown();
|
||||
if (isBlocked()) {
|
||||
@ -3221,6 +3248,10 @@ void HistoryWidget::messagesReceived(const MTPmessages_Messages &messages, mtpRe
|
||||
addMessagesToFront(*histList);
|
||||
_preloadRequest = 0;
|
||||
onListScroll();
|
||||
if (_reportSpamStatus == ReportSpamUnknown) {
|
||||
updateReportSpamStatus();
|
||||
if (_reportSpamStatus != ReportSpamUnknown) updateControlsVisibility();
|
||||
}
|
||||
} else if (_preloadDownRequest == requestId) {
|
||||
addMessagesToBack(*histList);
|
||||
_preloadDownRequest = 0;
|
||||
@ -3542,6 +3573,7 @@ void HistoryWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo
|
||||
App::main()->topBar()->startAnim();
|
||||
_scroll.hide();
|
||||
_kbScroll.hide();
|
||||
_reportSpamPanel.hide();
|
||||
_toHistoryEnd.hide();
|
||||
_attachDocument.hide();
|
||||
_attachPhoto.hide();
|
||||
@ -4588,6 +4620,8 @@ void HistoryWidget::msgUpdated(PeerId peer, const HistoryItem *msg) {
|
||||
}
|
||||
|
||||
void HistoryWidget::resizeEvent(QResizeEvent *e) {
|
||||
_reportSpamPanel.resize(width(), _reportSpamPanel.height());
|
||||
|
||||
int32 maxKeyboardHeight = int(st::maxFieldHeight) - _field.height();
|
||||
_keyboard.resizeToWidth(width(), maxKeyboardHeight);
|
||||
|
||||
|
@ -208,6 +208,28 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class HistoryWidget;
|
||||
class ReportSpamPanel : public TWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
ReportSpamPanel(HistoryWidget *parent);
|
||||
|
||||
void resizeEvent(QResizeEvent *e);
|
||||
void paintEvent(QPaintEvent *e);
|
||||
|
||||
signals:
|
||||
|
||||
void hideClicked();
|
||||
void reportClicked();
|
||||
|
||||
private:
|
||||
|
||||
FlatButton _report, _hide;
|
||||
|
||||
};
|
||||
|
||||
class BotKeyboard : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@ -657,6 +679,8 @@ private:
|
||||
bool isBlocked() const;
|
||||
bool updateCmdStartShown();
|
||||
|
||||
ReportSpamPanel _reportSpamPanel;
|
||||
|
||||
FlatButton _send, _unblock, _botStart;
|
||||
mtpRequestId _unblockRequest;
|
||||
IconedButton _attachDocument, _attachPhoto, _attachEmoji, _kbShow, _kbHide, _cmdStart;
|
||||
|
@ -206,11 +206,15 @@ void MediaView::updateDocSize() {
|
||||
readyStr = QString::number(readyTenthMb / 10) + '.' + QString::number(readyTenthMb % 10);
|
||||
totalStr = QString::number(totalTenthMb / 10) + '.' + QString::number(totalTenthMb % 10);
|
||||
mb = qsl("MB");
|
||||
} else {
|
||||
} else if (total >= 1024) {
|
||||
qint64 readyKb = (ready / 1024), totalKb = (total / 1024);
|
||||
readyStr = QString::number(readyKb);
|
||||
totalStr = QString::number(totalKb);
|
||||
mb = qsl("KB");
|
||||
} else {
|
||||
readyStr = QString::number(ready);
|
||||
totalStr = QString::number(total);
|
||||
mb = qsl("B");
|
||||
}
|
||||
_docSize = lng_media_save_progress(lt_ready, readyStr, lt_total, totalStr, lt_mb, mb);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user