From 11384743bcdd5099ca4f2cff28f324b6e5760a80 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 18 Jun 2015 20:24:54 +0300 Subject: [PATCH] improved mentions dropdown, version 0.8.28.dev --- Telegram/PrepareWin.bat | 8 +- Telegram/Resources/style.txt | 13 +-- Telegram/SourceFiles/app.cpp | 17 ++++ Telegram/SourceFiles/config.h | 4 +- Telegram/SourceFiles/dropdown.cpp | 75 ++++++++++------ Telegram/SourceFiles/dropdown.h | 2 +- Telegram/SourceFiles/gui/text.cpp | 4 +- Telegram/SourceFiles/history.cpp | 11 ++- Telegram/SourceFiles/historywidget.cpp | 95 +++++++++++++++----- Telegram/SourceFiles/historywidget.h | 7 +- Telegram/SourceFiles/mainwidget.cpp | 4 + Telegram/SourceFiles/mainwidget.h | 1 + Telegram/Telegram.plist | 2 +- Telegram/Telegram.rc | Bin 5540 -> 5540 bytes Telegram/Telegram.xcodeproj/project.pbxproj | 12 +-- Telegram/Version.sh | 2 +- 16 files changed, 179 insertions(+), 78 deletions(-) diff --git a/Telegram/PrepareWin.bat b/Telegram/PrepareWin.bat index 4bde9bfb09..0ff3979ada 100644 --- a/Telegram/PrepareWin.bat +++ b/Telegram/PrepareWin.bat @@ -1,9 +1,9 @@ @echo OFF -set "AppVersion=8027" -set "AppVersionStrSmall=0.8.27" -set "AppVersionStr=0.8.27" -set "AppVersionStrFull=0.8.27.0" +set "AppVersion=8028" +set "AppVersionStrSmall=0.8.28" +set "AppVersionStr=0.8.28" +set "AppVersionStrFull=0.8.28.0" set "DevChannel=1" if %DevChannel% neq 0 goto preparedev diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index 61e616352d..865b853dd9 100644 --- a/Telegram/Resources/style.txt +++ b/Telegram/Resources/style.txt @@ -1053,7 +1053,7 @@ textRectMargins: margins(-2px, -1px, -2px, -1px); taMsgField: flatTextarea(taDefFlat) { font: msgFont; } -maxFieldHeight: 265px; +maxFieldHeight: 223px; newMsgSound: ':/gui/art/newmsg.wav'; @@ -1664,8 +1664,9 @@ stickerPanPadding: 11px; stickerPanDelete: sprite(123px, 132px, 12px, 12px); stickerPanDeleteOpacity: 0.5; stickerIconPadding: 3px; -stickerIconHover: #e8ecef; -stickerIconSel: #dfe3e6; +stickerIconOpacity: 0.7; +stickerIconSel: 2px; +stickerIconSelColor: #58b2ed; stickerIconRecent: sprite(342px, 50px, 21px, 22px); stickerIconLeft: sprite(342px, 72px, 40px, 1px); stickerIconRight: sprite(342px, 73px, 40px, 1px); @@ -1680,9 +1681,9 @@ botKbFont: font(16px); botKbButton: botKeyboardButton { margin: 10px; padding: 10px; - height: 46px; - textTop: 13px; - downTextTop: 14px; + height: 36px; + textTop: 8px; + downTextTop: 9px; } botKbTinyButton: botKeyboardButton { margin: 4px; diff --git a/Telegram/SourceFiles/app.cpp b/Telegram/SourceFiles/app.cpp index b3a51b5ac1..935ba401a1 100644 --- a/Telegram/SourceFiles/app.cpp +++ b/Telegram/SourceFiles/app.cpp @@ -540,6 +540,8 @@ namespace App { } } if (!chat->participants.isEmpty()) { + History *h = App::historyLoaded(chat->id); + bool found = !h || !h->lastKeyboardFrom; int32 botStatus = -1; for (ChatData::Participants::iterator i = chat->participants.begin(), e = chat->participants.end(); i != e;) { if (i.value() < pversion) { @@ -549,10 +551,18 @@ namespace App { botStatus = (botStatus > 0/* || i.key()->botInfo->readsAllHistory*/) ? 2 : 1; if (requestBotInfos && !i.key()->botInfo->inited) App::api()->requestFullPeer(i.key()); } + if (!found && i.key()->id == h->lastKeyboardFrom) { + found = true; + } ++i; } } chat->botStatus = botStatus; + if (!found) { + h->lastKeyboardId = 0; + h->lastKeyboardFrom = 0; + if (App::main()) App::main()->updateBotKeyboard(); + } } if (App::main()) App::main()->peerUpdated(chat); } @@ -604,6 +614,13 @@ namespace App { if (i != chat->participants.end()) { chat->participants.erase(i); chat->count--; + + History *h = App::historyLoaded(chat->id); + if (h && h->lastKeyboardFrom == user->id) { + h->lastKeyboardId = 0; + h->lastKeyboardFrom = 0; + if (App::main()) App::main()->updateBotKeyboard(); + } } if (chat->botStatus > 0 && user->botInfo) { int32 botStatus = -1; diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index b90984726d..970c2ac11a 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 8027; -static const wchar_t *AppVersionStr = L"0.8.27"; +static const int32 AppVersion = 8028; +static const wchar_t *AppVersionStr = L"0.8.28"; static const bool DevChannel = true; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index 95a8ee05f1..b11e639b86 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -1670,7 +1670,7 @@ _travel(this , qsl("emoji_group"), dbietTravel , QString(), false, st::r _objects(this , qsl("emoji_group"), dbietObjects , QString(), false, st::rbEmojiObjects), _iconOver(-1), _iconSel(0), _iconDown(-1), _iconsDragging(false), _iconAnim(animFunc(this, &EmojiPan::iconAnim)), -_iconsLeft(0), _iconsTop(0), _iconsStartX(0), _iconsMax(0), _iconsX(0, 0), _iconsStartAnim(0), +_iconsLeft(0), _iconsTop(0), _iconsStartX(0), _iconsMax(0), _iconsX(0, 0), _iconSelX(0, 0), _iconsStartAnim(0), _stickersShown(false), _moveStart(0), e_scroll(this, st::emojiScroll), e_inner(), s_scroll(this, st::emojiScroll), s_inner(), _removingSetId(0) { setFocusPolicy(Qt::NoFocus); @@ -1765,16 +1765,21 @@ void EmojiPan::paintEvent(QPaintEvent *e) { if (_stickersShown) { p.fillRect(r.left(), _iconsTop, r.width(), st::rbEmoji.height, st::emojiPanCategories->b); if (!_icons.isEmpty()) { - int32 x = _iconsLeft, i = 0; + int32 x = _iconsLeft, i = 0, selxrel = _iconSelX.current(), selx = x + selxrel - _iconsX.current(); if (!_icons.at(i).sticker) { - if (_iconSel == i) { - p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconSel->b); - } else if (_iconHovers.at(i) > 0) { - p.setOpacity(_iconHovers.at(i)); - p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconHover->b); + if (selxrel > 0) { + if (_iconHovers.at(i) < 1) { + p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), st::rbEmojiRecent.imageRect); + } + if (_iconHovers.at(i) > 0) { + p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), st::rbEmojiRecent.overImageRect); + } + } + if (selxrel < st::rbEmoji.width) { + p.setOpacity(1 - (selxrel / st::rbEmoji.width)); + p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), st::rbEmojiRecent.chkImageRect); p.setOpacity(1); } - p.drawSpriteLeft(x + st::rbEmojiRecent.imagePos.x(), _iconsTop + st::rbEmojiRecent.imagePos.y(), width(), st::stickerIconRecent); x += st::rbEmoji.width; ++i; } @@ -1790,15 +1795,19 @@ void EmojiPan::paintEvent(QPaintEvent *e) { s.sticker->thumb->load(); QPixmap pix(s.sticker->thumb->pix(s.pixw, s.pixh)); if (_iconSel == i) { - p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconSel->b); - } else if (_iconHovers.at(i) > 0) { - p.setOpacity(_iconHovers.at(i)); - p.fillRect(rtl() ? (width() - x - st::rbEmoji.width) : x, _iconsTop, st::rbEmoji.width, st::rbEmoji.height, st::stickerIconHover->b); p.setOpacity(1); + } else { + p.setOpacity(1. * _iconHovers.at(i) + st::stickerIconOpacity * (1 - _iconHovers.at(i))); } p.drawPixmapLeft(x + (st::rbEmoji.width - s.pixw) / 2, _iconsTop + (st::rbEmoji.height - s.pixh) / 2, width(), pix); x += st::rbEmoji.width; + p.setOpacity(1); } + + if (rtl()) selx = width() - selx - st::rbEmoji.width; + p.setOpacity(_icons.at(0).sticker ? 1. : qMax(1., selx / st::rbEmoji.width)); + p.fillRect(selx, _iconsTop + st::rbEmoji.height - st::stickerIconPadding, st::rbEmoji.width, st::stickerIconSel, st::stickerIconSelColor->b); + float64 o_left = snap(float64(_iconsX.current()) / st::stickerIconLeft.pxWidth(), 0., 1.); if (o_left > 0) { p.setOpacity(o_left); @@ -1983,6 +1992,7 @@ void EmojiPan::onRefreshIcons() { _iconAnimations.clear(); s_inner.fillIcons(_icons); _iconsX = anim::ivalue(0, 0); + _iconSelX.finish(); _iconsStartAnim = 0; _iconAnim.stop(); if (_icons.isEmpty()) { @@ -2076,8 +2086,10 @@ bool EmojiPan::iconAnim(float64 ms) { if (dt >= 1) { _iconsStartAnim = 0; _iconsX.finish(); + _iconSelX.finish(); } else { _iconsX.update(dt, anim::linear); + _iconSelX.update(dt, anim::linear); } updateSelected(); } @@ -2161,6 +2173,7 @@ void EmojiPan::hideFinish() { _iconOver = _iconDown = -1; _iconSel = 0; _iconsX = anim::ivalue(0, 0); + _iconSelX = anim::ivalue(0, 0); _iconsStartAnim = 0; _iconAnim.stop(); _iconHovers = _icons.isEmpty() ? QVector() : QVector(_icons.size(), 0); @@ -2319,6 +2332,7 @@ void EmojiPan::onScroll() { } if (newSel != _iconSel) { _iconSel = newSel; + _iconSelX.start(newSel * st::rbEmoji.width); _iconsX.start(snap((2 * newSel - 7 - ((_icons.isEmpty() || _icons.at(0).sticker) ? 0 : 1)) * int(st::rbEmoji.width) / 2, 0, _iconsMax)); _iconsStartAnim = getms(); _iconAnim.start(); @@ -2426,7 +2440,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) { } p.setPen(st::black->p); if (!_rows->isEmpty()) { - UserData *user = _rows->at(last - i - 1); + UserData *user = _rows->at(i); QString first = (_parent->filter().size() < 2) ? QString() : ('@' + user->username.mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('@' + user->username) : user->username.mid(_parent->filter().size() - 1); int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second), unamewidth = firstwidth + secondwidth, namewidth = user->nameText.maxWidth(); if (availwidth < unamewidth + namewidth) { @@ -2455,7 +2469,8 @@ void MentionsInner::paintEvent(QPaintEvent *e) { p.drawText(2 * st::mentionPadding.left() + st::mentionPhotoSize + namewidth + st::mentionPadding.right() + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second); } } else if (!_hrows->isEmpty()) { - QString first = (_parent->filter().size() < 2) ? QString() : ('#' + _hrows->at(last - i - 1).mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('#' + _hrows->at(last - i - 1)) : _hrows->at(last - i - 1).mid(_parent->filter().size() - 1); + QString hrow = _hrows->at(i); + QString first = (_parent->filter().size() < 2) ? QString() : ('#' + hrow.mid(0, _parent->filter().size() - 1)), second = (_parent->filter().size() < 2) ? ('#' + hrow) : hrow.mid(_parent->filter().size() - 1); int32 firstwidth = st::mentionFont->m.width(first), secondwidth = st::mentionFont->m.width(second); if (htagwidth < firstwidth + secondwidth) { if (htagwidth < firstwidth + st::mentionFont->elidew) { @@ -2476,9 +2491,9 @@ void MentionsInner::paintEvent(QPaintEvent *e) { p.drawText(htagleft + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second); } } else { - UserData *user = _crows->at(last - i - 1).first; + UserData *user = _crows->at(i).first; - const BotCommand &command = _crows->at(last - i - 1).second; + const BotCommand &command = _crows->at(i).second; QString toHighlight = command.command; int32 botStatus = _parent->chat() ? _parent->chat()->botStatus : -1; if (hasUsername || botStatus == 0 || botStatus == 2) { @@ -2551,19 +2566,21 @@ void MentionsInner::mouseMoveEvent(QMouseEvent *e) { void MentionsInner::clearSel() { _mouseSel = _overDelete = false; - setSel(-1); + setSel((_rows->isEmpty() && _crows->isEmpty() && _hrows->isEmpty()) ? -1 : 0); } bool MentionsInner::moveSel(int direction) { _mouseSel = false; int32 maxSel = (_rows->isEmpty() ? (_hrows->isEmpty() ? _crows->size() : _hrows->size()) : _rows->size()); if (_sel >= maxSel || _sel < 0) { - if (direction < 0) setSel(maxSel - 1, true); + if (direction < 0) { + setSel(maxSel - 1, true); + } else { + setSel(0, true); + } return (_sel >= 0 && _sel < maxSel); } - if (_sel > 0 || direction > 0) { - setSel((_sel + direction >= maxSel) ? -1 : (_sel + direction), true); - } + setSel((_sel + direction >= maxSel) ? -1 : (_sel + direction), true); return true; } @@ -2572,12 +2589,12 @@ bool MentionsInner::select() { if (_sel >= 0 && _sel < maxSel) { QString result; if (!_rows->isEmpty()) { - result = '@' + _rows->at(_rows->size() - _sel - 1)->username; + result = '@' + _rows->at(_sel)->username; } else if (!_hrows->isEmpty()) { - result = '#' + _hrows->at(_hrows->size() - _sel - 1); + result = '#' + _hrows->at(_sel); } else { - UserData *user = _crows->at(_crows->size() - _sel - 1).first; - const BotCommand &command(_crows->at(_crows->size() - _sel - 1).second); + UserData *user = _crows->at(_sel).first; + const BotCommand &command(_crows->at(_sel).second); int32 botStatus = _parent->chat() ? _parent->chat()->botStatus : -1; if (botStatus == 0 || botStatus == 2 || _parent->filter().indexOf('@') > 1) { result = '/' + command.command + '@' + user->username; @@ -2599,7 +2616,7 @@ void MentionsInner::mousePressEvent(QMouseEvent *e) { if (_overDelete && _sel >= 0 && _sel < _hrows->size()) { _mousePos = mapToGlobal(e->pos()); - QString toRemove = _hrows->at(_hrows->size() - _sel - 1); + QString toRemove = _hrows->at(_sel); RecentHashtagPack recent(cRecentWriteHashtags()); for (RecentHashtagPack::iterator i = recent.begin(); i != recent.cend();) { if (i->first == toRemove) { @@ -2851,7 +2868,7 @@ void MentionsDropdown::recount(bool toDown) { _inner.resize(width(), h); } if (h > _boundings.height()) h = _boundings.height(); - if (h > 5 * st::mentionHeight) h = 5 * st::mentionHeight; + if (h > 4.5 * st::mentionHeight) h = 4.5 * st::mentionHeight; if (height() != h) { st += _scroll.height() - h; setGeometry(0, _boundings.height() - h, width(), h); @@ -2859,7 +2876,7 @@ void MentionsDropdown::recount(bool toDown) { } else if (y() != _boundings.height() - h) { move(0, _boundings.height() - h); } - if (toDown) st = _scroll.scrollTopMax(); + if (toDown) st = 0;// _scroll.scrollTopMax(); if (st != oldst) _scroll.scrollToY(st); if (toDown) _inner.clearSel(); } @@ -2953,7 +2970,7 @@ bool MentionsDropdown::eventFilter(QObject *obj, QEvent *e) { return true; } else if (ev->key() == Qt::Key_Down) { return _inner.moveSel(1); - } else if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return || ev->key() == Qt::Key_Space) { + } else if (ev->key() == Qt::Key_Enter || ev->key() == Qt::Key_Return) { return _inner.select(); } } diff --git a/Telegram/SourceFiles/dropdown.h b/Telegram/SourceFiles/dropdown.h index c54b191265..dff92377a5 100644 --- a/Telegram/SourceFiles/dropdown.h +++ b/Telegram/SourceFiles/dropdown.h @@ -447,7 +447,7 @@ private: QPoint _iconsMousePos, _iconsMouseDown; int32 _iconsLeft, _iconsTop; int32 _iconsStartX, _iconsMax; - anim::ivalue _iconsX; + anim::ivalue _iconsX, _iconSelX; uint64 _iconsStartAnim; bool _stickersShown; diff --git a/Telegram/SourceFiles/gui/text.cpp b/Telegram/SourceFiles/gui/text.cpp index c02ee3a702..1a6f889357 100644 --- a/Telegram/SourceFiles/gui/text.cpp +++ b/Telegram/SourceFiles/gui/text.cpp @@ -783,8 +783,8 @@ void HashtagLink::onClick(Qt::MouseButton button) const { void BotCommandLink::onClick(Qt::MouseButton button) const { if (button == Qt::LeftButton || button == Qt::MiddleButton) { - App::insertBotCommand(_cmd); -// App::sendBotCommand(_cmd); +// App::insertBotCommand(_cmd); + App::sendBotCommand(_cmd); } } diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 1a2027727d..7210d0664c 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -631,6 +631,11 @@ HistoryItem *History::createItem(HistoryBlock *block, const MTPmessage &msg, boo case mtpc_messageActionChatDeleteUser: { const MTPDmessageActionChatDeleteUser &d(action.c_messageActionChatDeleteUser()); + if (lastKeyboardFrom == App::peerFromUser(d.vuser_id)) { + lastKeyboardInited = true; + lastKeyboardId = 0; + lastKeyboardFrom = 0; + } // App::peer(App::peerFromUser(d.vuser_id)); left } break; @@ -825,6 +830,10 @@ HistoryItem *History::doAddToBack(HistoryBlock *to, bool newBlock, HistoryItem * lastKeyboardId = 0; lastKeyboardFrom = 0; } + } else if (peer->chat && (peer->asChat()->count < 1 || !peer->asChat()->participants.isEmpty()) && !peer->asChat()->participants.contains(adding->from())) { + lastKeyboardInited = true; + lastKeyboardId = 0; + lastKeyboardFrom = 0; } else { lastKeyboardInited = true; lastKeyboardId = adding->id; @@ -947,7 +956,7 @@ void History::addToFront(const QVector &slice) { if (!(App::replyMarkup(item->id).flags & MTPDreplyKeyboardMarkup_flag_ZERO)) { if (!lastKeyboardInited) { lastKeyboardInited = true; - if (wasKeyboardHide) { + if (wasKeyboardHide || ((peer->asChat()->count < 1 || !peer->asChat()->participants.isEmpty()) && !peer->asChat()->participants.contains(item->from()))) { lastKeyboardId = 0; lastKeyboardFrom = 0; } else { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index c33fb61bf5..407f1f9674 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2032,7 +2032,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent) , _field(this, st::taMsgField, lang(lng_message_ph)) , _recordAnim(animFunc(this, &HistoryWidget::recordStep)) , _recordingAnim(animFunc(this, &HistoryWidget::recordingStep)) -, _recording(false), _inRecord(false), _inField(false) +, _recording(false), _inRecord(false), _inField(false), _inReply(false) , a_recordingLevel(0, 0), _recordingSamples(0) , a_recordOver(0, 0), a_recordDown(0, 0), a_recordCancel(st::recordCancel->c, st::recordCancel->c) , _recordCancelWidth(st::recordFont->m.width(lang(lng_record_cancel))) @@ -2118,6 +2118,7 @@ HistoryWidget::HistoryWidget(QWidget *parent) : TWidget(parent) updateScrollColors(); _toHistoryEnd.hide(); + _toHistoryEnd.installEventFilter(this); _attachMention.hide(); connect(&_attachMention, SIGNAL(chosen(QString)), &_field, SLOT(onMentionHashtagOrBotCommandInsert(QString))); @@ -2632,7 +2633,7 @@ void HistoryWidget::showPeer(const PeerId &peer, MsgId msgId, bool force, bool l } if (_previewData && _previewData->pendingTill >= 0) { _previewData = 0; - if (!App::main()->hasForwardingItems()) _replyForwardPreviewCancel.hide(); + _replyForwardPreviewCancel.hide(); } _previewCache.clear(); _scroll.setWidget(0); @@ -2786,13 +2787,13 @@ void HistoryWidget::updateControlsVisibility() { _kbScroll.hide(); _send.hide(); _botStart.hide(); - _toHistoryEnd.hide(); _attachMention.hide(); _field.hide(); _replyForwardPreviewCancel.hide(); _attachDocument.hide(); _attachPhoto.hide(); _attachEmoji.hide(); + _toHistoryEnd.hide(); _kbShow.hide(); _kbHide.hide(); _attachType.hide(); @@ -2800,12 +2801,8 @@ void HistoryWidget::updateControlsVisibility() { return; } + updateToEndVisibility(); if (hist->readyForWork()) { - if (hist->loadedAtBottom() && !_replyReturn) { - _toHistoryEnd.hide(); - } else { - _toHistoryEnd.show(); - } if (!histPeer->chat || !histPeer->asChat()->forbidden) { checkMentionDropdown(); bool botStart = !histPeer->chat && histPeer->asUser()->botInfo && (!histPeer->asUser()->botInfo->startToken.isEmpty() || hist->isEmpty() && !hist->lastMsg); @@ -2873,7 +2870,7 @@ void HistoryWidget::updateControlsVisibility() { _attachPhoto.hide(); } } - if ((_replyToId || App::main()->hasForwardingItems() || (_previewData && _previewData->pendingTill >= 0))) { + if (_replyToId || App::main()->hasForwardingItems() || (_previewData && _previewData->pendingTill >= 0) || _kbReplyTo) { if (_replyForwardPreviewCancel.isHidden()) { _replyForwardPreviewCancel.show(); resizeEvent(0); @@ -2919,7 +2916,6 @@ void HistoryWidget::updateControlsVisibility() { _kbHide.hide(); _attachType.hide(); _emojiPan.hide(); - _toHistoryEnd.hide(); _replyForwardPreviewCancel.hide(); if (!_field.isHidden()) { _field.hide(); @@ -3205,6 +3201,8 @@ void HistoryWidget::onListScroll() { return; } + updateToEndVisibility(); + int st = _scroll.scrollTop(), stm = _scroll.scrollTopMax(), sh = _scroll.height(); if (hist->readyForWork() && (st + PreloadHeightsCount * sh > stm)) { loadMessagesDown(); @@ -3245,11 +3243,8 @@ QString HistoryWidget::prepareMessage(QString result) { void HistoryWidget::onHistoryToEnd() { if (_replyReturn) { showPeer(histPeer->id, _replyReturn->id); - } else { - _toHistoryEnd.hide(); - if (hist && !hist->loadedAtBottom()) { - showPeer(histPeer->id, 0); - } + } else if (hist) { + showPeer(histPeer->id, 0); } } @@ -3555,6 +3550,7 @@ void HistoryWidget::mouseMoveEvent(QMouseEvent *e) { QPoint pos(e ? e->pos() : mapFromGlobal(QCursor::pos())); bool inRecord = _send.geometry().contains(pos); bool inField = pos.y() >= (_scroll.y() + _scroll.height()) && pos.y() < height() && pos.x() >= 0 && pos.x() < width(); + bool inReply = QRect(st::replySkip, _field.y() - st::sendPadding - st::replyHeight, width() - st::replySkip - _replyForwardPreviewCancel.width(), st::replyHeight).contains(pos) && (_replyToId || _kbReplyTo); bool startAnim = false; if (inRecord != _inRecord) { _inRecord = inRecord; @@ -3570,6 +3566,10 @@ void HistoryWidget::mouseMoveEvent(QMouseEvent *e) { a_recordCancel.start(_inField ? st::recordCancel->c : st::recordCancelActive->c); startAnim = true; } + if (inReply != _inReply) { + _inReply = inReply; + setCursor(inReply ? style::cur_pointer : style::cur_default); + } if (startAnim) _recordAnim.start(); } @@ -3616,8 +3616,15 @@ void HistoryWidget::sendBotCommand(const QString &cmd, MsgId replyTo) { // reply App::main()->readServerHistory(hist, false); hist->loadAround(0); + QString toSend = cmd; + UserData *bot = histPeer->chat ? (App::hoveredLinkItem() ? (App::hoveredLinkItem()->toHistoryForwarded() ? App::hoveredLinkItem()->toHistoryForwarded()->fromForwarded() : App::hoveredLinkItem()->from()) : 0) : histPeer->asUser(); + QString username = (bot && bot->botInfo) ? bot->username : QString(); + if (!replyTo && toSend.indexOf('@') < 2 && histPeer->chat && !username.isEmpty() && (histPeer->asChat()->botStatus == 0 || histPeer->asChat()->botStatus == 2)) { + toSend += '@' + username; + } + int32 botStatus = histPeer->chat ? histPeer->asChat()->botStatus : -1; - App::main()->sendPreparedText(hist, cmd, replyTo ? ((histPeer->chat/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0); + App::main()->sendPreparedText(hist, toSend, replyTo ? ((histPeer->chat/* && (botStatus == 0 || botStatus == 2)*/) ? replyTo : -1) : 0); if (replyTo) { cancelReply(); if (_keyboard.hasMarkup() && _keyboard.singleUse() && _keyboard.forMsgId() == replyTo) { @@ -3633,7 +3640,7 @@ void HistoryWidget::insertBotCommand(const QString &cmd) { QString toInsert = cmd; UserData *bot = histPeer->chat ? (App::hoveredLinkItem() ? (App::hoveredLinkItem()->toHistoryForwarded() ? App::hoveredLinkItem()->toHistoryForwarded()->fromForwarded() : App::hoveredLinkItem()->from()) : 0) : histPeer->asUser(); QString username = (bot && bot->botInfo) ? bot->username : QString(); - if (cmd.indexOf('@') < 2 && histPeer->chat && !username.isEmpty() && (histPeer->asChat()->botStatus == 0 || histPeer->asChat()->botStatus == 2)) { + if (toInsert.indexOf('@') < 2 && histPeer->chat && !username.isEmpty() && (histPeer->asChat()->botStatus == 0 || histPeer->asChat()->botStatus == 2)) { toInsert += '@' + username; } toInsert += ' '; @@ -3652,6 +3659,13 @@ void HistoryWidget::insertBotCommand(const QString &cmd) { _field.setTextCursor(cur); } +bool HistoryWidget::eventFilter(QObject *obj, QEvent *e) { + if (obj == &_toHistoryEnd && e->type() == QEvent::Wheel) { + return _scroll.viewportEvent(e); + } + return TWidget::eventFilter(obj, e); +} + DragState HistoryWidget::getDragState(const QMimeData *d) { if (!d) return DragStateNone; @@ -3744,17 +3758,28 @@ void HistoryWidget::onKbToggle(bool manual) { _kbShow.show(); _kbScroll.hide(); _kbShown = false; + + _field.setMaxHeight(st::maxFieldHeight); + _kbReplyTo = 0; + if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) { + _replyForwardPreviewCancel.hide(); + } if (manual) _kbWasHidden = true; } else { _kbHide.show(); _kbShow.hide(); _kbScroll.show(); _kbShown = true; + + int32 maxh = qMin(_keyboard.height(), int(st::maxFieldHeight) - (int(st::maxFieldHeight) / 2)); + _field.setMaxHeight(st::maxFieldHeight - maxh); + _kbReplyTo = hist->peer->chat ? App::histItemById(_keyboard.forMsgId()) : 0; if (_kbReplyTo && !_replyToId) { updateReplyToName(); _replyToText.setText(st::msgFont, _kbReplyTo->inDialogsText(), _textDlgOptions); + _replyForwardPreviewCancel.show(); } if (manual) _kbWasHidden = false; } @@ -4502,6 +4527,7 @@ void HistoryWidget::updateBotKeyboard() { if (_kbReplyTo && !_replyToId) { updateReplyToName(); _replyToText.setText(st::msgFont, _kbReplyTo->inDialogsText(), _textDlgOptions); + _replyForwardPreviewCancel.show(); } } else { if (!_showAnim.animating()) { @@ -4513,6 +4539,9 @@ void HistoryWidget::updateBotKeyboard() { _field.setMaxHeight(st::maxFieldHeight); _kbShown = false; _kbReplyTo = 0; + if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) { + _replyForwardPreviewCancel.hide(); + } } } else { if (!_scroll.isHidden()) { @@ -4524,13 +4553,25 @@ void HistoryWidget::updateBotKeyboard() { _field.setMaxHeight(st::maxFieldHeight); _kbShown = false; _kbReplyTo = 0; + if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) { + _replyForwardPreviewCancel.hide(); + } } resizeEvent(0); update(); } +void HistoryWidget::updateToEndVisibility() { + bool toEndVisible = !_showAnim.animating() && hist && hist->readyForWork() && (!hist->loadedAtBottom() || _replyReturn || _scroll.scrollTop() + st::wndMinHeight < _scroll.scrollTopMax()); + if (toEndVisible && _toHistoryEnd.isHidden()) { + _toHistoryEnd.show(); + } else if (!toEndVisible && !_toHistoryEnd.isHidden()) { + _toHistoryEnd.hide(); + } +} + void HistoryWidget::mousePressEvent(QMouseEvent *e) { - _replyForwardPressed = QRect(0, _field.y() - st::replyHeight, st::replySkip, st::replyHeight).contains(e->pos()); + _replyForwardPressed = QRect(0, _field.y() - st::sendPadding - st::replyHeight, st::replySkip, st::replyHeight).contains(e->pos()); if (_replyForwardPressed && !_replyForwardPreviewCancel.isHidden()) { updateField(); } else if (_inRecord && cHasAudioCapture()) { @@ -4545,6 +4586,8 @@ void HistoryWidget::mousePressEvent(QMouseEvent *e) { a_recordDown.start(1); a_recordOver.restart(); _recordAnim.start(); + } else if (_inReply) { + App::main()->showPeer(histPeer->id, _replyToId ? _replyToId : _kbReplyTo->id); } } @@ -4628,6 +4671,8 @@ void HistoryWidget::onStickerSend(DocumentData *sticker) { App::main()->finishForwarding(hist); cancelReply(); + if (sticker->sticker) App::main()->incrementSticker(sticker); + App::historyRegRandom(randomId, newId); App::main()->historyToDown(hist); @@ -4683,8 +4728,9 @@ void HistoryWidget::cancelReply() { if (!_replyToId) return; _replyTo = 0; _replyToId = 0; - if (!App::main()->hasForwardingItems()) { - if (!_previewData || _previewData->pendingTill < 0) _replyForwardPreviewCancel.hide(); + mouseMoveEvent(0); + if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_kbReplyTo) { + _replyForwardPreviewCancel.hide(); } updateBotKeyboard(); @@ -4712,9 +4758,12 @@ void HistoryWidget::onReplyForwardPreviewCancel() { _saveDraftText = true; _saveDraftStart = getms(); onDraftSave(); - } else { + } else if (App::main()->hasForwardingItems()) { App::main()->cancelForwarding(); + } else if (_replyToId) { cancelReply(); + } else if (_kbReplyTo) { + onKbToggle(); } } @@ -4734,7 +4783,7 @@ void HistoryWidget::previewCancel() { _previewData = 0; _previewLinks.clear(); updatePreview(); - if (!_replyToId && !App::main()->hasForwardingItems()) _replyForwardPreviewCancel.hide(); + if (!_replyToId && !App::main()->hasForwardingItems() && !_kbReplyTo) _replyForwardPreviewCancel.hide(); } void HistoryWidget::onPreviewParse() { @@ -4828,7 +4877,7 @@ void HistoryWidget::updatePreview() { _previewTitle.setText(st::msgServiceNameFont, title, _textNameOptions); _previewDescription.setText(st::msgFont, desc, _textDlgOptions); } - } else if (!App::main()->hasForwardingItems() && !_replyToId) { + } else if (!App::main()->hasForwardingItems() && !_replyToId && !_kbReplyTo) { _replyForwardPreviewCancel.hide(); } resizeEvent(0); diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index b91e85c01a..9a5ec03b8e 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -452,6 +452,9 @@ public: void sendBotCommand(const QString &cmd, MsgId replyTo); void insertBotCommand(const QString &cmd); + bool eventFilter(QObject *obj, QEvent *e); + void updateBotKeyboard(); + ~HistoryWidget(); signals: @@ -572,7 +575,7 @@ private: void addMessagesToFront(const QVector &messages); void addMessagesToBack(const QVector &messages); - void updateBotKeyboard(); + void updateToEndVisibility(); void stickersGot(const MTPmessages_AllStickers &stickers); bool stickersFailed(const RPCError &error); @@ -611,7 +614,7 @@ private: IconedButton _attachDocument, _attachPhoto, _attachEmoji, _kbShow, _kbHide; MessageField _field; Animation _recordAnim, _recordingAnim; - bool _recording, _inRecord, _inField; + bool _recording, _inRecord, _inField, _inReply; anim::ivalue a_recordingLevel; int32 _recordingSamples; anim::fvalue a_recordOver, a_recordDown; diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 37310c5d6c..89e6bac4bd 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1718,6 +1718,10 @@ void MainWidget::updateReplyTo() { history.updateReplyTo(true); } +void MainWidget::updateBotKeyboard() { + history.updateBotKeyboard(); +} + void MainWidget::pushReplyReturn(HistoryItem *item) { history.pushReplyReturn(item); } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index e8de705765..da7281df78 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -333,6 +333,7 @@ public: ApiWrap *api(); void updateReplyTo(); + void updateBotKeyboard(); void pushReplyReturn(HistoryItem *item); diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index 189bad428b..d05afdb15f 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.8.27 + 0.8.28 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) CFBundleSignature diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index ac16269da1a891f6cdd0d12810d1adbf4ab8cd87..061f78a850c91b9922b0ab2540105cfb957a68fe 100644 GIT binary patch delta 53 zcmZ3Yy+nIM5ig^~ delta 53 zcmZ3Yy+nIM5ig_p6O diff --git a/Telegram/Telegram.xcodeproj/project.pbxproj b/Telegram/Telegram.xcodeproj/project.pbxproj index 23c17ac3c3..49c5567591 100644 --- a/Telegram/Telegram.xcodeproj/project.pbxproj +++ b/Telegram/Telegram.xcodeproj/project.pbxproj @@ -1701,7 +1701,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.8.27; + CURRENT_PROJECT_VERSION = 0.8.28; DEBUG_INFORMATION_FORMAT = dwarf; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; GCC_OPTIMIZATION_LEVEL = 0; @@ -1719,7 +1719,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COPY_PHASE_STRIP = YES; - CURRENT_PROJECT_VERSION = 0.8.27; + CURRENT_PROJECT_VERSION = 0.8.28; GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_OPTIMIZATION_LEVEL = fast; GCC_PREFIX_HEADER = ./SourceFiles/stdafx.h; @@ -1745,10 +1745,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.8.27; + CURRENT_PROJECT_VERSION = 0.8.28; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DYLIB_COMPATIBILITY_VERSION = 0.8; - DYLIB_CURRENT_VERSION = 0.8.27; + DYLIB_CURRENT_VERSION = 0.8.28; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; @@ -1888,10 +1888,10 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 0.8.27; + CURRENT_PROJECT_VERSION = 0.8.28; DEBUG_INFORMATION_FORMAT = dwarf; DYLIB_COMPATIBILITY_VERSION = 0.8; - DYLIB_CURRENT_VERSION = 0.8.27; + DYLIB_CURRENT_VERSION = 0.8.28; ENABLE_STRICT_OBJC_MSGSEND = YES; FRAMEWORK_SEARCH_PATHS = ""; GCC_GENERATE_DEBUGGING_SYMBOLS = YES; diff --git a/Telegram/Version.sh b/Telegram/Version.sh index b14d055cfb..b405bce4ca 100755 --- a/Telegram/Version.sh +++ b/Telegram/Version.sh @@ -1,2 +1,2 @@ -echo 8027 0.8.27 1 +echo 8028 0.8.28 1 # AppVersion AppVersionStr DevChannel