mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
version 0.8.49.dev - block/unblock users in profile, ask question and faq link in Settings, Windows 8/8.1/10 toast notifications
This commit is contained in:
@@ -75,7 +75,9 @@ HistoryList::HistoryList(HistoryWidget *historyWidget, ScrollArea *scroll, Histo
|
||||
|
||||
_trippleClickTimer.setSingleShot(true);
|
||||
|
||||
if (botInfo && !botInfo->inited) App::api()->requestFullPeer(hist->peer);
|
||||
if (botInfo && !botInfo->inited) {
|
||||
App::api()->requestFullPeer(hist->peer);
|
||||
}
|
||||
|
||||
setMouseTracking(true);
|
||||
}
|
||||
@@ -2200,7 +2202,9 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
, _toHistoryEnd(this, st::historyToEnd)
|
||||
, _attachMention(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)
|
||||
, _unblockRequest(0)
|
||||
, _attachDocument(this, st::btnAttachDocument)
|
||||
, _attachPhoto(this, st::btnAttachPhoto)
|
||||
, _attachEmoji(this, st::btnAttachEmoji)
|
||||
@@ -2243,6 +2247,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
connect(&_toHistoryEnd, SIGNAL(clicked()), this, SLOT(onHistoryToEnd()));
|
||||
connect(&_replyForwardPreviewCancel, SIGNAL(clicked()), this, SLOT(onReplyForwardPreviewCancel()));
|
||||
connect(&_send, SIGNAL(clicked()), this, SLOT(onSend()));
|
||||
connect(&_unblock, SIGNAL(clicked()), this, SLOT(onUnblock()));
|
||||
connect(&_botStart, SIGNAL(clicked()), this, SLOT(onBotStart()));
|
||||
connect(&_attachDocument, SIGNAL(clicked()), this, SLOT(onDocumentSelect()));
|
||||
connect(&_attachPhoto, SIGNAL(clicked()), this, SLOT(onPhotoSelect()));
|
||||
@@ -2305,6 +2310,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent)
|
||||
_field.hide();
|
||||
_field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width(), _send.height() - 2 * st::sendPadding);
|
||||
_send.hide();
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
|
||||
_attachDocument.hide();
|
||||
@@ -2368,8 +2374,8 @@ void HistoryWidget::onTextChange() {
|
||||
}
|
||||
if (updateCmdStartShown()) {
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
}
|
||||
|
||||
if (!_history || _synthedTextUpdate) return;
|
||||
@@ -2482,7 +2488,7 @@ void HistoryWidget::sendActionDone(const MTPBool &result, mtpRequestId req) {
|
||||
void HistoryWidget::activate() {
|
||||
if (_history) updateListSize(0, true);
|
||||
if (_list) {
|
||||
if (_selCount || (_list && _list->wasSelectedText()) || _recording || isBotStart()) {
|
||||
if (_selCount || (_list && _list->wasSelectedText()) || _recording || isBotStart() || isBlocked()) {
|
||||
_list->setFocus();
|
||||
} else {
|
||||
_field.setFocus();
|
||||
@@ -2776,6 +2782,7 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) {
|
||||
}
|
||||
|
||||
_peer = peerId ? App::peer(peerId) : 0;
|
||||
_unblockRequest = 0;
|
||||
|
||||
_titlePeerText = QString();
|
||||
_titlePeerTextWidth = 0;
|
||||
@@ -2890,6 +2897,7 @@ void HistoryWidget::updateControlsVisibility() {
|
||||
_scroll.hide();
|
||||
_kbScroll.hide();
|
||||
_send.hide();
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
_attachMention.hide();
|
||||
_field.hide();
|
||||
@@ -2914,7 +2922,25 @@ void HistoryWidget::updateControlsVisibility() {
|
||||
}
|
||||
if ((_peer->chat && !_peer->asChat()->forbidden && !_peer->asChat()->left) || (!_peer->chat && _peer->asUser()->access != UserNoAccess)) {
|
||||
checkMentionDropdown();
|
||||
if (isBotStart()) {
|
||||
if (isBlocked()) {
|
||||
_botStart.hide();
|
||||
if (_unblock.isHidden()) {
|
||||
_unblock.clearState();
|
||||
_unblock.show();
|
||||
_kbShown = false;
|
||||
}
|
||||
_send.hide();
|
||||
_field.hide();
|
||||
_attachEmoji.hide();
|
||||
_kbShow.hide();
|
||||
_kbHide.hide();
|
||||
_cmdStart.hide();
|
||||
_attachDocument.hide();
|
||||
_attachPhoto.hide();
|
||||
_kbScroll.hide();
|
||||
_replyForwardPreviewCancel.hide();
|
||||
} else if (isBotStart()) {
|
||||
_unblock.hide();
|
||||
if (_botStart.isHidden()) {
|
||||
_botStart.clearState();
|
||||
_botStart.show();
|
||||
@@ -2931,6 +2957,7 @@ void HistoryWidget::updateControlsVisibility() {
|
||||
_kbScroll.hide();
|
||||
_replyForwardPreviewCancel.hide();
|
||||
} else {
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
if (cHasAudioCapture() && _field.getLastText().isEmpty() && !App::main()->hasForwardingItems()) {
|
||||
_send.hide();
|
||||
@@ -3007,6 +3034,7 @@ void HistoryWidget::updateControlsVisibility() {
|
||||
} else {
|
||||
_attachMention.hide();
|
||||
_send.hide();
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
_attachDocument.hide();
|
||||
_attachPhoto.hide();
|
||||
@@ -3321,6 +3349,29 @@ void HistoryWidget::onSend(bool ctrlShiftEnter, MsgId replyTo) {
|
||||
if (!_keyboard.hasMarkup() && _keyboard.forceReply() && !_kbReplyTo) onKbToggle();
|
||||
}
|
||||
|
||||
void HistoryWidget::onUnblock() {
|
||||
if (_unblockRequest) return;
|
||||
if (!_peer || _peer->chat || _peer->asUser()->blocked != UserIsBlocked) {
|
||||
updateControlsVisibility();
|
||||
return;
|
||||
}
|
||||
|
||||
_unblockRequest = MTP::send(MTPcontacts_Unblock(_peer->asUser()->inputUser), rpcDone(&HistoryWidget::unblockDone, _peer), rpcFail(&HistoryWidget::unblockFail));
|
||||
}
|
||||
|
||||
void HistoryWidget::unblockDone(PeerData *peer, const MTPBool &result) {
|
||||
if (peer->chat) return;
|
||||
_unblockRequest = 0;
|
||||
peer->asUser()->blocked = UserIsNotBlocked;
|
||||
emit App::main()->peerUpdated(peer);
|
||||
}
|
||||
|
||||
bool HistoryWidget::unblockFail(const RPCError &error) {
|
||||
if (error.type().startsWith(qsl("FLOOD_WAIT_"))) return false;
|
||||
// _unblockRequest = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void HistoryWidget::onBotStart() {
|
||||
if (!_peer || _peer->chat || !_peer->asUser()->botInfo) {
|
||||
updateControlsVisibility();
|
||||
@@ -3418,6 +3469,7 @@ void HistoryWidget::animShow(const QPixmap &bgAnimCache, const QPixmap &bgAnimTo
|
||||
_field.hide();
|
||||
_replyForwardPreviewCancel.hide();
|
||||
_send.hide();
|
||||
_unblock.hide();
|
||||
_botStart.hide();
|
||||
a_coord = back ? anim::ivalue(-st::introSlideShift, 0) : anim::ivalue(st::introSlideShift, 0);
|
||||
a_alpha = anim::fvalue(0, 1);
|
||||
@@ -3470,7 +3522,7 @@ void HistoryWidget::animStop() {
|
||||
bool HistoryWidget::recordStep(float64 ms) {
|
||||
float64 dt = ms / st::btnSend.duration;
|
||||
bool res = true;
|
||||
if (dt >= 1 || !_send.isHidden() || isBotStart()) {
|
||||
if (dt >= 1 || !_send.isHidden() || isBotStart() || isBlocked()) {
|
||||
res = false;
|
||||
a_recordOver.finish();
|
||||
a_recordDown.finish();
|
||||
@@ -3787,10 +3839,14 @@ bool HistoryWidget::isBotStart() const {
|
||||
return !_peer->asUser()->botInfo->startToken.isEmpty() || (_history->isEmpty() && !_history->lastMsg);
|
||||
}
|
||||
|
||||
bool HistoryWidget::isBlocked() const {
|
||||
return _peer && !_peer->chat && _peer->asUser()->blocked == UserIsBlocked;
|
||||
}
|
||||
|
||||
bool HistoryWidget::updateCmdStartShown() {
|
||||
bool cmdStartShown = false;
|
||||
if (_history && _peer && ((_peer->chat && _peer->asChat()->botStatus > 0) || (!_peer->chat && _peer->asUser()->botInfo))) {
|
||||
if (!isBotStart() && !_keyboard.hasMarkup() && !_keyboard.forceReply()) {
|
||||
if (!isBotStart() && !isBlocked() && !_keyboard.hasMarkup() && !_keyboard.forceReply()) {
|
||||
if (_field.getLastText().isEmpty()) {
|
||||
cmdStartShown = true;
|
||||
}
|
||||
@@ -4069,6 +4125,7 @@ void HistoryWidget::onFieldResize() {
|
||||
_attachDocument.move(0, height() - kbh - _attachDocument.height());
|
||||
_attachPhoto.move(_attachDocument.x(), _attachDocument.y());
|
||||
_botStart.setGeometry(0, _attachDocument.y(), width(), _botStart.height());
|
||||
_unblock.setGeometry(0, _attachDocument.y(), width(), _unblock.height());
|
||||
_send.move(width() - _send.width(), _attachDocument.y());
|
||||
_attachEmoji.move(_send.x() - _attachEmoji.width(), height() - kbh - _attachEmoji.height());
|
||||
_kbShow.move(_attachEmoji.x() - _kbShow.width(), height() - kbh - _kbShow.height());
|
||||
@@ -4427,7 +4484,7 @@ void HistoryWidget::peerMessagesUpdated(PeerId peer) {
|
||||
if (_peer && _list && peer == _peer->id) {
|
||||
updateListSize();
|
||||
updateBotKeyboard();
|
||||
if (!_scroll.isHidden() && _botStart.isHidden() == isBotStart()) {
|
||||
if (!_scroll.isHidden() && !isBlocked() && _botStart.isHidden() == isBotStart()) {
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
}
|
||||
@@ -4468,6 +4525,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) {
|
||||
|
||||
_send.move(width() - _send.width(), _attachDocument.y());
|
||||
_botStart.setGeometry(0, _attachDocument.y(), width(), _botStart.height());
|
||||
_unblock.setGeometry(0, _attachDocument.y(), width(), _unblock.height());
|
||||
_attachEmoji.move(_send.x() - _attachEmoji.width(), height() - kbh - _attachEmoji.height());
|
||||
_kbShow.move(_attachEmoji.x() - _kbShow.width(), height() - kbh - _kbShow.height());
|
||||
_kbHide.move(_attachEmoji.x(), _attachEmoji.y());
|
||||
@@ -4537,7 +4595,9 @@ void HistoryWidget::updateListSize(int32 addToY, bool initial, bool loadedDown,
|
||||
}
|
||||
|
||||
int32 newScrollHeight = height();
|
||||
if (isBotStart()) {
|
||||
if (isBlocked()) {
|
||||
newScrollHeight -= _unblock.height();
|
||||
} else if (isBotStart()) {
|
||||
newScrollHeight -= _botStart.height();
|
||||
} else {
|
||||
if ((_peer->chat && !_peer->asChat()->forbidden && !_peer->asChat()->left) || (!_peer->chat && _peer->asUser()->access != UserNoAccess)) {
|
||||
@@ -4676,7 +4736,7 @@ void HistoryWidget::updateBotKeyboard() {
|
||||
bool hasMarkup = _keyboard.hasMarkup(), forceReply = _keyboard.forceReply() && !_replyTo;
|
||||
if (hasMarkup || forceReply) {
|
||||
if (_keyboard.singleUse() && _keyboard.hasMarkup() && _keyboard.forMsgId() == _history->lastKeyboardId && _history->lastKeyboardUsed) _kbWasHidden = true;
|
||||
if (!isBotStart() && (wasVisible || _replyTo || (_field.getLastText().isEmpty() && !_kbWasHidden))) {
|
||||
if (!isBotStart() && !isBlocked() && (wasVisible || _replyTo || (_field.getLastText().isEmpty() && !_kbWasHidden))) {
|
||||
if (!_showAnim.animating()) {
|
||||
if (hasMarkup) {
|
||||
_kbScroll.show();
|
||||
@@ -5094,6 +5154,9 @@ void HistoryWidget::onFullPeerUpdated(PeerData *data) {
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
update();
|
||||
} else if (!_scroll.isHidden() && _unblock.isHidden() == isBlocked()) {
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
}
|
||||
if (newScrollTop != _scroll.scrollTop()) {
|
||||
if (_scroll.isVisible()) {
|
||||
@@ -5110,6 +5173,11 @@ void HistoryWidget::peerUpdated(PeerData *data) {
|
||||
if (!_showAnim.animating()) updateControlsVisibility();
|
||||
if (data->chat && data->asChat()->count > 0 && data->asChat()->participants.isEmpty()) {
|
||||
App::api()->requestFullPeer(data);
|
||||
} else if (!data->chat && data->asUser()->blocked == UserBlockUnknown) {
|
||||
App::api()->requestFullPeer(data);
|
||||
} else if (!_scroll.isHidden() && _unblock.isHidden() == isBlocked()) {
|
||||
updateControlsVisibility();
|
||||
resizeEvent(0);
|
||||
}
|
||||
App::main()->updateOnlineDisplay();
|
||||
}
|
||||
@@ -5225,7 +5293,7 @@ void HistoryWidget::updateTopBarSelection() {
|
||||
updateControlsVisibility();
|
||||
updateListSize();
|
||||
if (!App::wnd()->layerShown() && !App::passcoded()) {
|
||||
if (_selCount || (_list && _list->wasSelectedText()) || _recording || isBotStart()) {
|
||||
if (_selCount || (_list && _list->wasSelectedText()) || _recording || isBotStart() || isBlocked()) {
|
||||
_list->setFocus();
|
||||
} else {
|
||||
_field.setFocus();
|
||||
|
Reference in New Issue
Block a user