diff --git a/Telegram/Resources/style.txt b/Telegram/Resources/style.txt index 865b853dd..4a67b66a0 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: 223px; +maxFieldHeight: 243px; newMsgSound: ':/gui/art/newmsg.wav'; @@ -1926,6 +1926,11 @@ mentionPadding: margins(8px, 5px, 8px, 5px); mentionTop: 11px; mentionFont: linkFont; mentionPhotoSize: msgPhotoSize; +mentionBgOver: #f5f5f5; +mentionFg: #777; +mentionFgOver: #707070; +mentionFgActive: #0080c0; +mentionFgOverActive: #0077b3; botCommandFont: font(fsize semibold); botDescFont: font(fsize italic); diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index ba2300413..ce1fc89b7 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -104,7 +104,7 @@ void DialogsListWidget::paintEvent(QPaintEvent *e) { for (; from < to; ++from) { bool selected = (from == hashtagSel); if (selected) { - p.fillRect(0, 0, w, st::mentionHeight, st::dlgHoverBG->b); + p.fillRect(0, 0, w, st::mentionHeight, st::mentionBgOver->b); int skip = (st::mentionHeight - st::notifyClose.icon.pxHeight()) / 2; p.drawPixmap(QPoint(w - st::notifyClose.icon.pxWidth() - skip, skip), App::sprite(), st::notifyClose.icon); } @@ -122,11 +122,11 @@ void DialogsListWidget::paintEvent(QPaintEvent *e) { p.setFont(st::mentionFont->f); if (!first.isEmpty()) { - p.setPen(st::profileOnlineColor->p); + p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p); p.drawText(st::dlgPaddingHor, st::mentionTop + st::mentionFont->ascent, first); } if (!second.isEmpty()) { - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); p.drawText(st::dlgPaddingHor + firstwidth, st::mentionTop + st::mentionFont->ascent, second); } p.translate(0, st::mentionHeight); diff --git a/Telegram/SourceFiles/dropdown.cpp b/Telegram/SourceFiles/dropdown.cpp index eb5cebc36..eb83e4957 100644 --- a/Telegram/SourceFiles/dropdown.cpp +++ b/Telegram/SourceFiles/dropdown.cpp @@ -2433,8 +2433,9 @@ void MentionsInner::paintEvent(QPaintEvent *e) { for (int32 i = from; i < to; ++i) { if (i >= last) break; - if (i == _sel) { - p.fillRect(0, i * st::mentionHeight, width(), st::mentionHeight, st::dlgHoverBG->b); + bool selected = (i == _sel); + if (selected) { + p.fillRect(0, i * st::mentionHeight, width(), st::mentionHeight, st::mentionBgOver->b); int skip = (st::mentionHeight - st::notifyClose.icon.pxHeight()) / 2; if (!_hrows->isEmpty()) p.drawPixmap(QPoint(width() - st::notifyClose.icon.pxWidth() - skip, i * st::mentionHeight + skip), App::sprite(), st::notifyClose.icon); } @@ -2462,10 +2463,10 @@ void MentionsInner::paintEvent(QPaintEvent *e) { user->nameText.drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth); p.setFont(st::mentionFont->f); - p.setPen(st::profileOnlineColor->p); + p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p); p.drawText(2 * st::mentionPadding.left() + st::mentionPhotoSize + namewidth + st::mentionPadding.right(), i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first); if (!second.isEmpty()) { - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); 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()) { @@ -2483,11 +2484,11 @@ void MentionsInner::paintEvent(QPaintEvent *e) { p.setFont(st::mentionFont->f); if (!first.isEmpty()) { - p.setPen(st::profileOnlineColor->p); + p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p); p.drawText(htagleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first); } if (!second.isEmpty()) { - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); p.drawText(htagleft + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second); } } else { @@ -2517,11 +2518,11 @@ void MentionsInner::paintEvent(QPaintEvent *e) { } p.setFont(st::botCommandFont->f); if (!first.isEmpty()) { - p.setPen(st::profileOnlineColor->p); + p.setPen((selected ? st::mentionFgOverActive : st::mentionFgActive)->p); p.drawText(htagleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, first); } if (!second.isEmpty()) { - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); p.drawText(htagleft + firstwidth, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, second); } addleft += firstwidth + secondwidth + st::mentionPadding.left(); @@ -2534,7 +2535,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) { if (widthleft < paramswidth) { params = st::mentionFont->m.elidedText(params, Qt::ElideRight, widthleft); } - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); p.drawText(htagleft + addleft, i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, params); addleft += paramswidth + st::mentionPadding.left(); @@ -2548,7 +2549,7 @@ void MentionsInner::paintEvent(QPaintEvent *e) { description = st::botDescFont->m.elidedText(description, Qt::ElideRight, widthleft); descwidth = st::botDescFont->m.width(description); } - p.setPen(st::profileOfflineColor->p); + p.setPen((selected ? st::mentionFgOver : st::mentionFg)->p); p.drawText(htagleft + addleft + (widthleft - descwidth), i * st::mentionHeight + st::mentionTop + st::mentionFont->ascent, description); } } diff --git a/Telegram/SourceFiles/gui/text.cpp b/Telegram/SourceFiles/gui/text.cpp index 1a6f88935..3ff93f7e5 100644 --- a/Telegram/SourceFiles/gui/text.cpp +++ b/Telegram/SourceFiles/gui/text.cpp @@ -744,7 +744,7 @@ namespace { void TextLink::onClick(Qt::MouseButton button) const { if (button == Qt::LeftButton || button == Qt::MiddleButton) { QString url = TextLink::encoded(); - QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); + QRegularExpressionMatch telegramMeUser = QRegularExpression(qsl("^https?://telegram\\.me/([a-zA-Z0-9\\.\\_]+)/?(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); QRegularExpressionMatch telegramMeGroup = QRegularExpression(qsl("^https?://telegram\\.me/joinchat/([a-zA-Z0-9\\.\\_\\-]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); QRegularExpressionMatch telegramMeStickers = QRegularExpression(qsl("^https?://telegram\\.me/addstickers/([a-zA-Z0-9\\.\\_]+)(\\?|$)"), QRegularExpression::CaseInsensitiveOption).match(url); if (telegramMeUser.hasMatch()) { diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index ada2cbe54..c0515d56a 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2557,6 +2557,30 @@ void HistoryWidget::calcNextReplyReturn() { if (!_replyReturn) updateControlsVisibility(); } +bool HistoryWidget::kbWasHidden() { + return _kbWasHidden; +} + +void HistoryWidget::setKbWasHidden() { + if (_kbWasHidden || !_keyboard.hasMarkup()) return; + + _kbWasHidden = true; + if (!_showAnim.animating()) { + _kbScroll.hide(); + _attachEmoji.show(); + _kbHide.hide(); + _kbShow.show(); + } + _field.setMaxHeight(st::maxFieldHeight); + _kbShown = false; + _kbReplyTo = 0; + if (!App::main()->hasForwardingItems() && (!_previewData || _previewData->pendingTill < 0) && !_replyToId) { + _replyForwardPreviewCancel.hide(); + } + resizeEvent(0); + update(); +} + void HistoryWidget::showPeer(const PeerId &peer, MsgId msgId, bool force, bool leaveActive) { if (App::main()->selectingPeer() && !force) { hiderOffered = true; @@ -2810,6 +2834,7 @@ void HistoryWidget::updateControlsVisibility() { if (_botStart.isHidden()) { _botStart.clearState(); _botStart.show(); + _kbShown = false; } _send.hide(); _field.hide(); @@ -3291,6 +3316,12 @@ void HistoryWidget::onBotStart() { MTP::send(MTPmessages_StartBot(histPeer->asUser()->inputUser, MTP_int(0), MTP_long(randomId), MTP_string(token)), App::main()->rpcDone(&MainWidget::sentUpdatesReceived), App::main()->rpcFail(&MainWidget::addParticipantFail, histPeer->asUser())); histPeer->asUser()->botInfo->startToken = QString(); + if (_keyboard.hasMarkup()) { + if (_keyboard.singleUse() && _keyboard.forMsgId() == hist->lastKeyboardId && hist->lastKeyboardUsed) _kbWasHidden = true; + if (!_kbWasHidden) _kbShown = true; + } + updateControlsVisibility(); + resizeEvent(0); } } @@ -4325,7 +4356,7 @@ void HistoryWidget::resizeEvent(QResizeEvent *e) { _replyForwardPreviewCancel.move(width() - _replyForwardPreviewCancel.width(), _field.y() - st::sendPadding - _replyForwardPreviewCancel.height()); updateListSize(); - _field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - (_kbShow.isHidden() ? 0 : _kbShow.width()), _field.height()); + _field.resize(width() - _send.width() - _attachDocument.width() - _attachEmoji.width() - ((_kbShown || !_keyboard.hasMarkup()) ? 0 : _kbShow.width()), _field.height()); _toHistoryEnd.move((width() - _toHistoryEnd.width()) / 2, _scroll.y() + _scroll.height() - _toHistoryEnd.height() - st::historyToEndSkip); diff --git a/Telegram/SourceFiles/historywidget.h b/Telegram/SourceFiles/historywidget.h index 9a5ec03b8..12a8d16ec 100644 --- a/Telegram/SourceFiles/historywidget.h +++ b/Telegram/SourceFiles/historywidget.h @@ -440,6 +440,9 @@ public: void setReplyReturns(PeerId peer, const QList &replyReturns); void calcNextReplyReturn(); + bool kbWasHidden(); + void setKbWasHidden(); + void updatePreview(); void previewCancel(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 89e6bac4b..c891aff76 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1902,7 +1902,7 @@ void MainWidget::showMediaOverview(PeerData *peer, MediaOverviewType type, bool } else if (profile) { _stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop(), profile->allMediaShown())); } else { - _stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns())); + _stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns(), history.kbWasHidden())); } } if (overview) { @@ -1949,7 +1949,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop, } else if (profile) { _stack.push_back(new StackItemProfile(profile->peer(), profile->lastScrollTop(), profile->allMediaShown())); } else { - _stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns())); + _stack.push_back(new StackItemHistory(history.peer(), history.lastWidth(), history.lastScrollTop(), history.replyReturns(), history.kbWasHidden())); } } if (overview) { @@ -1987,6 +1987,7 @@ void MainWidget::showBackFromStack() { StackItemHistory *histItem = static_cast(item); showPeer(histItem->peer->id, App::main()->activeMsgId(), true); history.setReplyReturns(histItem->peer->id, histItem->replyReturns); + if (histItem->kbWasHidden) history.setKbWasHidden(); } else if (item->type() == ProfileStackItem) { StackItemProfile *profItem = static_cast(item); showPeerProfile(profItem->peer, true, profItem->lastScrollTop, profItem->allMediaShown); @@ -2581,7 +2582,13 @@ void MainWidget::openUserByName(const QString &username, bool toProfile, const Q showPeerProfile(user); } } else { - if (user->botInfo) user->botInfo->startToken = startToken; + if (user->botInfo) { + user->botInfo->startToken = startToken; + if (user == history.peer()) { + history.updateControlsVisibility(); + history.resizeEvent(0); + } + } emit showPeerAsync(user->id, 0, false, true); } } else { @@ -2617,7 +2624,13 @@ void MainWidget::usernameResolveDone(QPair toProfileStartToken, c showPeerProfile(user); } } else { - if (user->botInfo) user->botInfo->startToken = toProfileStartToken.second; + if (user->botInfo) { + user->botInfo->startToken = toProfileStartToken.second; + if (user == history.peer()) { + history.updateControlsVisibility(); + history.resizeEvent(0); + } + } showPeer(user->id, 0, false, true); } } diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index da7281df7..2289a597a 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -110,13 +110,14 @@ public: class StackItemHistory : public StackItem { public: - StackItemHistory(PeerData *peer, int32 lastWidth, int32 lastScrollTop, QList replyReturns) : StackItem(peer), replyReturns(replyReturns), lastWidth(lastWidth), lastScrollTop(lastScrollTop) { + StackItemHistory(PeerData *peer, int32 lastWidth, int32 lastScrollTop, QList replyReturns, bool kbWasHidden) : StackItem(peer), replyReturns(replyReturns), lastWidth(lastWidth), lastScrollTop(lastScrollTop), kbWasHidden(kbWasHidden) { } StackItemType type() const { return HistoryStackItem; } QList replyReturns; int32 lastWidth, lastScrollTop; + bool kbWasHidden; }; class StackItemProfile : public StackItem {