Scroll following the inline bot keyboard when message is edited.

This commit is contained in:
John Preston 2016-04-08 13:20:10 +04:00
parent 9af094e278
commit 35d5089f48
12 changed files with 232 additions and 177 deletions

View File

@ -1614,7 +1614,7 @@ namespace {
return i.value(); return i.value();
} }
WebPageData *webPageSet(const WebPageId &webPage, WebPageData *convert, const QString &type, const QString &url, const QString &displayUrl, const QString &siteName, const QString &title, const QString &description, PhotoData *photo, DocumentData *doc, int32 duration, const QString &author, int32 pendingTill) { WebPageData *webPageSet(const WebPageId &webPage, WebPageData *convert, const QString &type, const QString &url, const QString &displayUrl, const QString &siteName, const QString &title, const QString &description, PhotoData *photo, DocumentData *document, int32 duration, const QString &author, int32 pendingTill) {
if (convert) { if (convert) {
if (convert->id != webPage) { if (convert->id != webPage) {
WebPagesData::iterator i = webPagesData.find(convert->id); WebPagesData::iterator i = webPagesData.find(convert->id);
@ -1631,7 +1631,7 @@ namespace {
convert->title = title; convert->title = title;
convert->description = description; convert->description = description;
convert->photo = photo; convert->photo = photo;
convert->doc = doc; convert->document = document;
convert->duration = duration; convert->duration = duration;
convert->author = author; convert->author = author;
if (convert->pendingTill > 0 && pendingTill <= 0 && api()) api()->clearWebPageRequest(convert); if (convert->pendingTill > 0 && pendingTill <= 0 && api()) api()->clearWebPageRequest(convert);
@ -1645,7 +1645,7 @@ namespace {
if (convert) { if (convert) {
result = convert; result = convert;
} else { } else {
result = new WebPageData(webPage, toWebPageType(type), url, displayUrl, siteName, title, description, photo, doc, duration, author, (pendingTill >= -1) ? pendingTill : -1); result = new WebPageData(webPage, toWebPageType(type), url, displayUrl, siteName, title, description, document, photo, duration, author, (pendingTill >= -1) ? pendingTill : -1);
if (pendingTill > 0 && api()) { if (pendingTill > 0 && api()) {
api()->requestWebPageDelayed(result); api()->requestWebPageDelayed(result);
} }
@ -1662,7 +1662,7 @@ namespace {
result->title = title; result->title = title;
result->description = description; result->description = description;
result->photo = photo; result->photo = photo;
result->doc = doc; result->document = document;
result->duration = duration; result->duration = duration;
result->author = author; result->author = author;
if (result->pendingTill > 0 && pendingTill <= 0 && api()) api()->clearWebPageRequest(result); if (result->pendingTill > 0 && pendingTill <= 0 && api()) api()->clearWebPageRequest(result);

View File

@ -260,6 +260,12 @@ namespace Notify {
} }
} }
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) {
if (MainWidget *m = App::main()) {
m->notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
}
}
void migrateUpdated(PeerData *peer) { void migrateUpdated(PeerData *peer) {
if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer); if (MainWidget *m = App::main()) m->notify_migrateUpdated(peer);
} }

View File

@ -102,6 +102,7 @@ namespace Notify {
void inlineBotRequesting(bool requesting); void inlineBotRequesting(bool requesting);
void replyMarkupUpdated(const HistoryItem *item); void replyMarkupUpdated(const HistoryItem *item);
void inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
void migrateUpdated(PeerData *peer); void migrateUpdated(PeerData *peer);

View File

@ -2373,7 +2373,7 @@ MsgId History::msgIdForRead() const {
} }
int History::resizeGetHeight(int newWidth) { int History::resizeGetHeight(int newWidth) {
bool resizeAllItems = (_flags | Flag::f_pending_resize) || (width != newWidth); bool resizeAllItems = (_flags & Flag::f_pending_resize) || (width != newWidth);
if (!resizeAllItems && !hasPendingResizedItems()) { if (!resizeAllItems && !hasPendingResizedItems()) {
return height; return height;
@ -2758,7 +2758,7 @@ public:
// Note: it is possible that we will point to the different button // Note: it is possible that we will point to the different button
// than the one was used when constructing the handler, but not a big deal. // than the one was used when constructing the handler, but not a big deal.
const HistoryMessageReplyMarkup::Button *getButton() const { const HistoryMessageReplyMarkup::Button *getButton() const {
if (auto *markup = _item->Get<HistoryMessageReplyMarkup>()) { if (auto markup = _item->Get<HistoryMessageReplyMarkup>()) {
if (_row < markup->rows.size()) { if (_row < markup->rows.size()) {
const HistoryMessageReplyMarkup::ButtonRow &row(markup->rows.at(_row)); const HistoryMessageReplyMarkup::ButtonRow &row(markup->rows.at(_row));
if (_col < row.size()) { if (_col < row.size()) {
@ -2793,7 +2793,7 @@ ReplyKeyboard::ReplyKeyboard(const HistoryItem *item, StylePtr &&s)
: _item(item) : _item(item)
, _a_selected(animation(this, &ReplyKeyboard::step_selected)) , _a_selected(animation(this, &ReplyKeyboard::step_selected))
, _st(std_::forward<StylePtr>(s)) { , _st(std_::forward<StylePtr>(s)) {
if (auto *markup = item->Get<HistoryMessageReplyMarkup>()) { if (auto markup = item->Get<HistoryMessageReplyMarkup>()) {
_rows.reserve(markup->rows.size()); _rows.reserve(markup->rows.size());
for (int i = 0, l = markup->rows.size(); i != l; ++i) { for (int i = 0, l = markup->rows.size(); i != l; ++i) {
const HistoryMessageReplyMarkup::ButtonRow &row(markup->rows.at(i)); const HistoryMessageReplyMarkup::ButtonRow &row(markup->rows.at(i));
@ -2815,7 +2815,7 @@ ReplyKeyboard::ReplyKeyboard(const HistoryItem *item, StylePtr &&s)
void ReplyKeyboard::resize(int width, int height) { void ReplyKeyboard::resize(int width, int height) {
_width = width; _width = width;
auto *markup = _item->Get<HistoryMessageReplyMarkup>(); auto markup = _item->Get<HistoryMessageReplyMarkup>();
float64 y = 0, buttonHeight = _rows.isEmpty() ? _st->buttonHeight() : (float64(height + _st->buttonSkip()) / _rows.size()); float64 y = 0, buttonHeight = _rows.isEmpty() ? _st->buttonHeight() : (float64(height + _st->buttonSkip()) / _rows.size());
for (ButtonRow &row : _rows) { for (ButtonRow &row : _rows) {
int s = row.size(); int s = row.size();
@ -2868,7 +2868,7 @@ void ReplyKeyboard::setStyle(StylePtr &&st) {
int ReplyKeyboard::naturalWidth() const { int ReplyKeyboard::naturalWidth() const {
int result = 0; int result = 0;
auto *markup = _item->Get<HistoryMessageReplyMarkup>(); auto markup = _item->Get<HistoryMessageReplyMarkup>();
for_const (const ButtonRow &row, _rows) { for_const (const ButtonRow &row, _rows) {
int rowSize = row.size(); int rowSize = row.size();
int rowWidth = (rowSize - 1) * _st->buttonSkip() + rowSize * 2 * _st->buttonPadding(); int rowWidth = (rowSize - 1) * _st->buttonSkip() + rowSize * 2 * _st->buttonPadding();
@ -3177,7 +3177,7 @@ void HistoryItem::finishCreate() {
} }
void HistoryItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) { void HistoryItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool active) {
if (auto *markup = Get<HistoryMessageReplyMarkup>()) { if (auto markup = Get<HistoryMessageReplyMarkup>()) {
if (markup->inlineKeyboard) { if (markup->inlineKeyboard) {
markup->inlineKeyboard->clickHandlerActiveChanged(p, active); markup->inlineKeyboard->clickHandlerActiveChanged(p, active);
} }
@ -3187,7 +3187,7 @@ void HistoryItem::clickHandlerActiveChanged(const ClickHandlerPtr &p, bool activ
} }
void HistoryItem::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) { void HistoryItem::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed) {
if (auto *markup = Get<HistoryMessageReplyMarkup>()) { if (auto markup = Get<HistoryMessageReplyMarkup>()) {
if (markup->inlineKeyboard) { if (markup->inlineKeyboard) {
markup->inlineKeyboard->clickHandlerPressedChanged(p, pressed); markup->inlineKeyboard->clickHandlerPressedChanged(p, pressed);
} }
@ -3337,7 +3337,7 @@ void HistoryItem::setUnreadBarCount(int count) {
} }
void HistoryItem::setUnreadBarFreezed() { void HistoryItem::setUnreadBarFreezed() {
if (auto *bar = Get<HistoryMessageUnreadBar>()) { if (auto bar = Get<HistoryMessageUnreadBar>()) {
bar->_freezed = true; bar->_freezed = true;
} }
} }
@ -4204,7 +4204,7 @@ HistoryDocument::HistoryDocument(DocumentData *document, const QString &caption,
, _parent(nullptr) , _parent(nullptr)
, _data(document) { , _data(document) {
createComponents(!caption.isEmpty()); createComponents(!caption.isEmpty());
if (auto *named = Get<HistoryDocumentNamed>()) { if (auto named = Get<HistoryDocumentNamed>()) {
named->_name = documentName(_data); named->_name = documentName(_data);
named->_namew = st::semiboldFont->width(named->_name); named->_namew = st::semiboldFont->width(named->_name);
} }
@ -4213,7 +4213,7 @@ HistoryDocument::HistoryDocument(DocumentData *document, const QString &caption,
setStatusSize(FileStatusSizeReady); setStatusSize(FileStatusSizeReady);
if (auto *captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
captioned->_caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent)); captioned->_caption.setText(st::msgFont, caption + parent->skipBlock(), itemTextNoMonoOptions(parent));
} }
} }
@ -4222,10 +4222,10 @@ HistoryDocument::HistoryDocument(const HistoryDocument &other) : HistoryFileMedi
, Composer() , Composer()
, _parent(nullptr) , _parent(nullptr)
, _data(other._data) { , _data(other._data) {
auto *captioned = other.Get<HistoryDocumentCaptioned>(); auto captioned = other.Get<HistoryDocumentCaptioned>();
createComponents(captioned != 0); createComponents(captioned != 0);
if (auto *named = Get<HistoryDocumentNamed>()) { if (auto named = Get<HistoryDocumentNamed>()) {
if (auto *othernamed = other.Get<HistoryDocumentNamed>()) { if (auto othernamed = other.Get<HistoryDocumentNamed>()) {
named->_name = othernamed->_name; named->_name = othernamed->_name;
named->_namew = othernamed->_namew; named->_namew = othernamed->_namew;
} else { } else {
@ -4257,7 +4257,7 @@ void HistoryDocument::createComponents(bool caption) {
mask |= HistoryDocumentCaptioned::Bit(); mask |= HistoryDocumentCaptioned::Bit();
} }
UpdateComponents(mask); UpdateComponents(mask);
if (auto *thumbed = Get<HistoryDocumentThumbed>()) { if (auto thumbed = Get<HistoryDocumentThumbed>()) {
thumbed->_linksavel.reset(new DocumentSaveClickHandler(_data)); thumbed->_linksavel.reset(new DocumentSaveClickHandler(_data));
thumbed->_linkcancell.reset(new DocumentCancelClickHandler(_data)); thumbed->_linkcancell.reset(new DocumentCancelClickHandler(_data));
} }
@ -4266,12 +4266,12 @@ void HistoryDocument::createComponents(bool caption) {
void HistoryDocument::initDimensions(const HistoryItem *parent) { void HistoryDocument::initDimensions(const HistoryItem *parent) {
_parent = parent; _parent = parent;
auto *captioned = Get<HistoryDocumentCaptioned>(); auto captioned = Get<HistoryDocumentCaptioned>();
if (captioned && captioned->_caption.hasSkipBlock()) { if (captioned && captioned->_caption.hasSkipBlock()) {
captioned->_caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight()); captioned->_caption.setSkipBlock(parent->skipBlockWidth(), parent->skipBlockHeight());
} }
auto *thumbed = Get<HistoryDocumentThumbed>(); auto thumbed = Get<HistoryDocumentThumbed>();
if (thumbed) { if (thumbed) {
_data->thumb->load(); _data->thumb->load();
int32 tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height()); int32 tw = convertScale(_data->thumb->width()), th = convertScale(_data->thumb->height());
@ -4296,7 +4296,7 @@ void HistoryDocument::initDimensions(const HistoryItem *parent) {
_maxw = qMax(_maxw, tleft + documentMaxStatusWidth(_data) + unread + parent->skipBlockWidth() + st::msgPadding.right()); _maxw = qMax(_maxw, tleft + documentMaxStatusWidth(_data) + unread + parent->skipBlockWidth() + st::msgPadding.right());
} }
if (auto *named = Get<HistoryDocumentNamed>()) { if (auto named = Get<HistoryDocumentNamed>()) {
_maxw = qMax(tleft + named->_namew + tright, _maxw); _maxw = qMax(tleft + named->_namew + tright, _maxw);
_maxw = qMin(_maxw, int(st::msgMaxWidth)); _maxw = qMin(_maxw, int(st::msgMaxWidth));
} }
@ -4318,7 +4318,7 @@ void HistoryDocument::initDimensions(const HistoryItem *parent) {
} }
int HistoryDocument::resizeGetHeight(int width, const HistoryItem *parent) { int HistoryDocument::resizeGetHeight(int width, const HistoryItem *parent) {
auto *captioned = Get<HistoryDocumentCaptioned>(); auto captioned = Get<HistoryDocumentCaptioned>();
if (!captioned) { if (!captioned) {
return HistoryFileMedia::resizeGetHeight(width, parent); return HistoryFileMedia::resizeGetHeight(width, parent);
} }
@ -4354,7 +4354,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r
bool radial = isRadialAnimation(ms); bool radial = isRadialAnimation(ms);
int nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0; int nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0;
if (auto *thumbed = Get<HistoryDocumentThumbed>()) { if (auto thumbed = Get<HistoryDocumentThumbed>()) {
nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right();
nametop = st::msgFileThumbNameTop; nametop = st::msgFileThumbNameTop;
nameright = st::msgFileThumbPadding.left(); nameright = st::msgFileThumbPadding.left();
@ -4462,7 +4462,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r
} }
int32 namewidth = _width - nameleft - nameright; int32 namewidth = _width - nameleft - nameright;
if (auto *voice = Get<HistoryDocumentVoice>()) { if (auto voice = Get<HistoryDocumentVoice>()) {
const VoiceWaveform *wf = 0; const VoiceWaveform *wf = 0;
uchar norm_value = 0; uchar norm_value = 0;
if (_data->voice()) { if (_data->voice()) {
@ -4521,7 +4521,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r
sum_i += bar_count; sum_i += bar_count;
} }
} }
} else if (auto *named = Get<HistoryDocumentNamed>()) { } else if (auto named = Get<HistoryDocumentNamed>()) {
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(st::black); p.setPen(st::black);
if (namewidth < named->_namew) { if (namewidth < named->_namew) {
@ -4548,7 +4548,7 @@ void HistoryDocument::draw(Painter &p, const HistoryItem *parent, const QRect &r
} }
} }
if (auto *captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
p.setPen(st::black); p.setPen(st::black);
captioned->_caption.draw(p, st::msgPadding.left(), bottom, captionw); captioned->_caption.draw(p, st::msgPadding.left(), bottom, captionw);
} }
@ -4563,7 +4563,7 @@ void HistoryDocument::getState(ClickHandlerPtr &lnk, HistoryCursorState &state,
bool showPause = updateStatusText(parent); bool showPause = updateStatusText(parent);
int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0; int32 nameleft = 0, nametop = 0, nameright = 0, statustop = 0, linktop = 0, bottom = 0;
if (auto *thumbed = Get<HistoryDocumentThumbed>()) { if (auto thumbed = Get<HistoryDocumentThumbed>()) {
nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right(); nameleft = st::msgFileThumbPadding.left() + st::msgFileThumbSize + st::msgFileThumbPadding.right();
linktop = st::msgFileThumbLinkTop; linktop = st::msgFileThumbLinkTop;
bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom(); bottom = st::msgFileThumbPadding.top() + st::msgFileThumbSize + st::msgFileThumbPadding.bottom();
@ -4592,7 +4592,7 @@ void HistoryDocument::getState(ClickHandlerPtr &lnk, HistoryCursorState &state,
} }
int32 height = _height; int32 height = _height;
if (auto *captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
if (y >= bottom) { if (y >= bottom) {
bool inText = false; bool inText = false;
captioned->_caption.getState(lnk, inText, x - st::msgPadding.left(), y - bottom, _width - st::msgPadding.left() - st::msgPadding.right()); captioned->_caption.getState(lnk, inText, x - st::msgPadding.left(), y - bottom, _width - st::msgPadding.left() - st::msgPadding.right());
@ -4614,10 +4614,10 @@ const QString HistoryDocument::inDialogsText() const {
} else if (_data->song()) { } else if (_data->song()) {
result = lang(lng_in_dlg_audio_file); result = lang(lng_in_dlg_audio_file);
} else { } else {
auto *named = Get<HistoryDocumentNamed>(); auto named = Get<HistoryDocumentNamed>();
result = (!named || named->_name.isEmpty()) ? lang(lng_in_dlg_file) : named->_name; result = (!named || named->_name.isEmpty()) ? lang(lng_in_dlg_file) : named->_name;
} }
if (auto *captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
if (!captioned->_caption.isEmpty()) { if (!captioned->_caption.isEmpty()) {
result.append(' ').append(captioned->_caption.original(0, 0xFFFF, Text::ExpandLinksNone)); result.append(' ').append(captioned->_caption.original(0, 0xFFFF, Text::ExpandLinksNone));
} }
@ -4634,12 +4634,12 @@ const QString HistoryDocument::inHistoryText() const {
} else { } else {
result = lang(lng_in_dlg_file); result = lang(lng_in_dlg_file);
} }
if (auto *named = Get<HistoryDocumentNamed>()) { if (auto named = Get<HistoryDocumentNamed>()) {
if (!named->_name.isEmpty()) { if (!named->_name.isEmpty()) {
result.append(qsl(" : ")).append(named->_name); result.append(qsl(" : ")).append(named->_name);
} }
} }
if (auto *captioned = Get<HistoryDocumentCaptioned>()) { if (auto captioned = Get<HistoryDocumentCaptioned>()) {
if (!captioned->_caption.isEmpty()) { if (!captioned->_caption.isEmpty()) {
result.append(qsl(", ")).append(captioned->_caption.original(0, 0xFFFF, Text::ExpandLinksAll)); result.append(qsl(", ")).append(captioned->_caption.original(0, 0xFFFF, Text::ExpandLinksAll));
} }
@ -4650,7 +4650,7 @@ const QString HistoryDocument::inHistoryText() const {
void HistoryDocument::setStatusSize(int32 newSize, qint64 realDuration) const { void HistoryDocument::setStatusSize(int32 newSize, qint64 realDuration) const {
int32 duration = _data->song() ? _data->song()->duration : (_data->voice() ? _data->voice()->duration : -1); int32 duration = _data->song() ? _data->song()->duration : (_data->voice() ? _data->voice()->duration : -1);
HistoryFileMedia::setStatusSize(newSize, _data->size, duration, realDuration); HistoryFileMedia::setStatusSize(newSize, _data->size, duration, realDuration);
if (auto *thumbed = Get<HistoryDocumentThumbed>()) { if (auto thumbed = Get<HistoryDocumentThumbed>()) {
if (_statusSize == FileStatusSizeReady) { if (_statusSize == FileStatusSizeReady) {
thumbed->_link = lang(lng_media_download).toUpper(); thumbed->_link = lang(lng_media_download).toUpper();
} else if (_statusSize == FileStatusSizeLoaded) { } else if (_statusSize == FileStatusSizeLoaded) {
@ -4686,7 +4686,7 @@ bool HistoryDocument::updateStatusText(const HistoryItem *parent) const {
} }
if (playing.msgId == parent->fullId() && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) { if (playing.msgId == parent->fullId() && !(playingState & AudioPlayerStoppedMask) && playingState != AudioPlayerFinishing) {
if (auto *voice = Get<HistoryDocumentVoice>()) { if (auto voice = Get<HistoryDocumentVoice>()) {
bool was = voice->_playback; bool was = voice->_playback;
voice->ensurePlayback(this); voice->ensurePlayback(this);
if (!was || playingPosition != voice->_playback->_position) { if (!was || playingPosition != voice->_playback->_position) {
@ -4706,7 +4706,7 @@ bool HistoryDocument::updateStatusText(const HistoryItem *parent) const {
showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting); showPause = (playingState == AudioPlayerPlaying || playingState == AudioPlayerResuming || playingState == AudioPlayerStarting);
} else { } else {
statusSize = FileStatusSizeLoaded; statusSize = FileStatusSizeLoaded;
if (auto *voice = Get<HistoryDocumentVoice>()) { if (auto voice = Get<HistoryDocumentVoice>()) {
voice->checkPlaybackFinished(); voice->checkPlaybackFinished();
} }
} }
@ -4742,7 +4742,7 @@ bool HistoryDocument::updateStatusText(const HistoryItem *parent) const {
} }
void HistoryDocument::step_voiceProgress(float64 ms, bool timer) { void HistoryDocument::step_voiceProgress(float64 ms, bool timer) {
if (auto *voice = Get<HistoryDocumentVoice>()) { if (auto voice = Get<HistoryDocumentVoice>()) {
if (voice->_playback) { if (voice->_playback) {
float64 dt = ms / (2 * AudioVoiceMsgUpdateView); float64 dt = ms / (2 * AudioVoiceMsgUpdateView);
if (dt >= 1) { if (dt >= 1) {
@ -5232,8 +5232,8 @@ void HistorySticker::initDimensions(const HistoryItem *parent) {
int HistorySticker::resizeGetHeight(int width, const HistoryItem *parent) { // return new height int HistorySticker::resizeGetHeight(int width, const HistoryItem *parent) { // return new height
_width = qMin(width, _maxw); _width = qMin(width, _maxw);
if (parent->getMedia() == this) { if (parent->getMedia() == this) {
auto *via = parent->Get<HistoryMessageVia>(); auto via = parent->Get<HistoryMessageVia>();
auto *reply = parent->Get<HistoryMessageReply>(); auto reply = parent->Get<HistoryMessageReply>();
if (via || reply) { if (via || reply) {
int usew = _maxw - additionalWidth(via, reply); int usew = _maxw - additionalWidth(via, reply);
int availw = _width - usew - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left(); int availw = _width - usew - st::msgReplyPadding.left() - st::msgReplyPadding.left() - st::msgReplyPadding.left();
@ -5257,8 +5257,8 @@ void HistorySticker::draw(Painter &p, const HistoryItem *parent, const QRect &r,
bool out = parent->out(), isPost = parent->isPost(), childmedia = (parent->getMedia() != this); bool out = parent->out(), isPost = parent->isPost(), childmedia = (parent->getMedia() != this);
int usew = _maxw, usex = 0; int usew = _maxw, usex = 0;
auto *via = childmedia ? nullptr : parent->Get<HistoryMessageVia>(); auto via = childmedia ? nullptr : parent->Get<HistoryMessageVia>();
auto *reply = childmedia ? nullptr : parent->Get<HistoryMessageReply>(); auto reply = childmedia ? nullptr : parent->Get<HistoryMessageReply>();
if (via || reply) { if (via || reply) {
usew -= additionalWidth(via, reply); usew -= additionalWidth(via, reply);
if (isPost) { if (isPost) {
@ -5326,8 +5326,8 @@ void HistorySticker::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i
bool out = parent->out(), isPost = parent->isPost(), childmedia = (parent->getMedia() != this); bool out = parent->out(), isPost = parent->isPost(), childmedia = (parent->getMedia() != this);
int usew = _maxw, usex = 0; int usew = _maxw, usex = 0;
auto *via = childmedia ? nullptr : parent->Get<HistoryMessageVia>(); auto via = childmedia ? nullptr : parent->Get<HistoryMessageVia>();
auto *reply = childmedia ? nullptr : parent->Get<HistoryMessageReply>(); auto reply = childmedia ? nullptr : parent->Get<HistoryMessageReply>();
if (via || reply) { if (via || reply) {
usew -= additionalWidth(via, reply); usew -= additionalWidth(via, reply);
if (isPost) { if (isPost) {
@ -5657,7 +5657,7 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
if (!_data->description.isEmpty() && title.isEmpty() && _data->siteName.isEmpty() && !_data->url.isEmpty()) { if (!_data->description.isEmpty() && title.isEmpty() && _data->siteName.isEmpty() && !_data->url.isEmpty()) {
_data->siteName = siteNameFromUrl(_data->url); _data->siteName = siteNameFromUrl(_data->url);
} }
if (!_data->doc && _data->photo && _data->type != WebPagePhoto && _data->type != WebPageVideo) { if (!_data->document && _data->photo && _data->type != WebPagePhoto && _data->type != WebPageVideo) {
if (_data->type == WebPageProfile) { if (_data->type == WebPageProfile) {
_asArticle = true; _asArticle = true;
} else if (_data->siteName == qstr("Twitter") || _data->siteName == qstr("Facebook")) { } else if (_data->siteName == qstr("Twitter") || _data->siteName == qstr("Facebook")) {
@ -5674,15 +5674,15 @@ void HistoryWebPage::initDimensions(const HistoryItem *parent) {
// init attach // init attach
if (!_asArticle && !_attach) { if (!_asArticle && !_attach) {
if (_data->doc) { if (_data->document) {
if (_data->doc->sticker()) { if (_data->document->sticker()) {
_attach = new HistorySticker(_data->doc); _attach = new HistorySticker(_data->document);
} else if (_data->doc->isAnimation()) { } else if (_data->document->isAnimation()) {
_attach = new HistoryGif(_data->doc, QString(), parent); _attach = new HistoryGif(_data->document, QString(), parent);
} else if (_data->doc->isVideo()) { } else if (_data->document->isVideo()) {
_attach = new HistoryVideo(_data->doc, QString(), parent); _attach = new HistoryVideo(_data->document, QString(), parent);
} else { } else {
_attach = new HistoryDocument(_data->doc, QString(), parent); _attach = new HistoryDocument(_data->document, QString(), parent);
} }
} else if (_data->photo) { } else if (_data->photo) {
_attach = new HistoryPhoto(_data->photo, QString(), parent); _attach = new HistoryPhoto(_data->photo, QString(), parent);
@ -6012,7 +6012,7 @@ void HistoryWebPage::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i
int32 attachLeft = lshift - bubble.left(), attachTop = tshift - bubble.top(); int32 attachLeft = lshift - bubble.left(), attachTop = tshift - bubble.top();
if (rtl()) attachLeft = _width - attachLeft - _attach->currentWidth(); if (rtl()) attachLeft = _width - attachLeft - _attach->currentWidth();
_attach->getState(lnk, state, x - attachLeft, y - attachTop, parent); _attach->getState(lnk, state, x - attachLeft, y - attachTop, parent);
if (lnk && !_data->doc && _data->photo) { if (lnk && !_data->document && _data->photo) {
if (_data->type == WebPageProfile || _data->type == WebPageVideo) { if (_data->type == WebPageProfile || _data->type == WebPageVideo) {
lnk = _openl; lnk = _openl;
} else if (_data->type == WebPagePhoto || _data->siteName == qstr("Twitter") || _data->siteName == qstr("Facebook")) { } else if (_data->type == WebPagePhoto || _data->siteName == qstr("Twitter") || _data->siteName == qstr("Facebook")) {
@ -6833,27 +6833,27 @@ void HistoryMessage::createComponents(const CreateConfig &config) {
} }
} }
UpdateComponents(mask); UpdateComponents(mask);
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
reply->replyToMsgId = config.replyTo; reply->replyToMsgId = config.replyTo;
if (!reply->updateData(this) && App::api()) { if (!reply->updateData(this) && App::api()) {
App::api()->requestMessageData(history()->peer->asChannel(), reply->replyToMsgId, new HistoryDependentItemCallback(fullId())); App::api()->requestMessageData(history()->peer->asChannel(), reply->replyToMsgId, new HistoryDependentItemCallback(fullId()));
} }
} }
if (auto *via = Get<HistoryMessageVia>()) { if (auto via = Get<HistoryMessageVia>()) {
via->create(config.viaBotId); via->create(config.viaBotId);
} }
if (auto *views = Get<HistoryMessageViews>()) { if (auto views = Get<HistoryMessageViews>()) {
views->_views = config.viewsCount; views->_views = config.viewsCount;
} }
if (auto *msgsigned = Get<HistoryMessageSigned>()) { if (auto msgsigned = Get<HistoryMessageSigned>()) {
msgsigned->create(_from->asUser(), date); msgsigned->create(_from->asUser(), date);
} }
if (auto *fwd = Get<HistoryMessageForwarded>()) { if (auto fwd = Get<HistoryMessageForwarded>()) {
fwd->_authorOriginal = App::peer(config.authorIdOriginal); fwd->_authorOriginal = App::peer(config.authorIdOriginal);
fwd->_fromOriginal = App::peer(config.fromIdOriginal); fwd->_fromOriginal = App::peer(config.fromIdOriginal);
fwd->_originalId = config.originalId; fwd->_originalId = config.originalId;
} }
if (auto *markup = Get<HistoryMessageReplyMarkup>()) { if (auto markup = Get<HistoryMessageReplyMarkup>()) {
markup->create(*config.markup); markup->create(*config.markup);
} }
initTime(); initTime();
@ -6879,13 +6879,13 @@ QString formatViewsCount(int32 views) {
} }
void HistoryMessage::initTime() { void HistoryMessage::initTime() {
if (auto *msgsigned = Get<HistoryMessageSigned>()) { if (auto msgsigned = Get<HistoryMessageSigned>()) {
_timeWidth = msgsigned->maxWidth(); _timeWidth = msgsigned->maxWidth();
} else { } else {
_timeText = date.toString(cTimeFormat()); _timeText = date.toString(cTimeFormat());
_timeWidth = st::msgDateFont->width(_timeText); _timeWidth = st::msgDateFont->width(_timeText);
} }
if (auto *views = Get<HistoryMessageViews>()) { if (auto views = Get<HistoryMessageViews>()) {
views->_viewsText = (views->_views >= 0) ? formatViewsCount(views->_views) : QString(); views->_viewsText = (views->_views >= 0) ? formatViewsCount(views->_views) : QString();
views->_viewsWidth = views->_viewsText.isEmpty() ? 0 : st::msgDateFont->width(views->_viewsText); views->_viewsWidth = views->_viewsText.isEmpty() ? 0 : st::msgDateFont->width(views->_viewsText);
} }
@ -7011,7 +7011,7 @@ void HistoryMessage::initDimensions() {
_maxw = _media->maxWidth(); _maxw = _media->maxWidth();
_minh = _media->minHeight(); _minh = _media->minHeight();
} }
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
reply->updateName(); reply->updateName();
if (!_text.isEmpty()) { if (!_text.isEmpty()) {
int replyw = st::msgPadding.left() + reply->_maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right(); int replyw = st::msgPadding.left() + reply->_maxReplyWidth - st::msgReplyPadding.left() - st::msgReplyPadding.right() + st::msgPadding.right();
@ -7059,13 +7059,21 @@ void HistoryMessage::countPositionAndSize(int32 &left, int32 &width) const {
void HistoryMessage::fromNameUpdated(int32 width) const { void HistoryMessage::fromNameUpdated(int32 width) const {
_authorNameVersion = author()->nameVersion; _authorNameVersion = author()->nameVersion;
if (!Has<HistoryMessageForwarded>()) { if (!Has<HistoryMessageForwarded>()) {
if (auto *via = Get<HistoryMessageVia>()) { if (auto via = Get<HistoryMessageVia>()) {
via->resize(width - st::msgPadding.left() - st::msgPadding.right() - author()->nameText.maxWidth() - st::msgServiceFont->spacew); via->resize(width - st::msgPadding.left() - st::msgPadding.right() - author()->nameText.maxWidth() - st::msgServiceFont->spacew);
} }
} }
} }
void HistoryMessage::applyEdition(const MTPDmessage &message) { void HistoryMessage::applyEdition(const MTPDmessage &message) {
int keyboardTop = -1;
if (!pendingResize()) {
if (auto keyboard = inlineReplyKeyboard()) {
int h = st::msgBotKbButton.margin + keyboard->naturalHeight();
keyboardTop = _height - h + st::msgBotKbButton.margin - marginBottom();
}
}
EntitiesInText entities; EntitiesInText entities;
if (message.has_entities()) { if (message.has_entities()) {
entities = entitiesFromMTP(message.ventities.c_vector().v); entities = entitiesFromMTP(message.ventities.c_vector().v);
@ -7084,6 +7092,12 @@ void HistoryMessage::applyEdition(const MTPDmessage &message) {
if (history()->textCachedFor == this) { if (history()->textCachedFor == this) {
history()->textCachedFor = nullptr; history()->textCachedFor = nullptr;
} }
if (keyboardTop >= 0) {
if (auto keyboard = Get<HistoryMessageReplyMarkup>()) {
keyboard->oldTop = keyboardTop;
}
}
} }
void HistoryMessage::updateMedia(const MTPMessageMedia *media) { void HistoryMessage::updateMedia(const MTPMessageMedia *media) {
@ -7141,7 +7155,7 @@ QString HistoryMessage::selectedText(uint32 selection) const {
uint16 selectedTo = (selection == FullSelection) ? 0xFFFF : (selection & 0xFFFF); uint16 selectedTo = (selection == FullSelection) ? 0xFFFF : (selection & 0xFFFF);
result = _text.original(selectedFrom, selectedTo, Text::ExpandLinksAll); result = _text.original(selectedFrom, selectedTo, Text::ExpandLinksAll);
} }
if (auto *fwd = Get<HistoryMessageForwarded>()) { if (auto fwd = Get<HistoryMessageForwarded>()) {
if (selection == FullSelection) { if (selection == FullSelection) {
QString fwdinfo = fwd->_text.original(0, 0xFFFF, Text::ExpandLinksAll), wrapped; QString fwdinfo = fwd->_text.original(0, 0xFFFF, Text::ExpandLinksAll), wrapped;
wrapped.reserve(fwdinfo.size() + 4 + result.size()); wrapped.reserve(fwdinfo.size() + 4 + result.size());
@ -7149,7 +7163,7 @@ QString HistoryMessage::selectedText(uint32 selection) const {
result = wrapped; result = wrapped;
} }
} }
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
if (selection == FullSelection && reply->replyToMsg) { if (selection == FullSelection && reply->replyToMsg) {
QString wrapped; QString wrapped;
wrapped.reserve(lang(lng_in_reply_to).size() + reply->replyToMsg->author()->name.size() + 4 + result.size()); wrapped.reserve(lang(lng_in_reply_to).size() + reply->replyToMsg->author()->name.size() + 4 + result.size());
@ -7281,7 +7295,7 @@ void HistoryMessage::drawInfo(Painter &p, int32 right, int32 bottom, int32 width
} }
dateX += HistoryMessage::timeLeft(); dateX += HistoryMessage::timeLeft();
if (auto *msgsigned = Get<HistoryMessageSigned>()) { if (auto msgsigned = Get<HistoryMessageSigned>()) {
msgsigned->_signature.drawElided(p, dateX, dateY, _timeWidth); msgsigned->_signature.drawElided(p, dateX, dateY, _timeWidth);
} else { } else {
p.drawText(dateX, dateY + st::msgDateFont->ascent, _timeText); p.drawText(dateX, dateY + st::msgDateFont->ascent, _timeText);
@ -7289,7 +7303,7 @@ void HistoryMessage::drawInfo(Painter &p, int32 right, int32 bottom, int32 width
QPoint iconPos; QPoint iconPos;
const QRect *iconRect = 0; const QRect *iconRect = 0;
if (auto *views = Get<HistoryMessageViews>()) { if (auto views = Get<HistoryMessageViews>()) {
iconPos = QPoint(infoRight - infoW + st::msgViewsPos.x(), infoBottom - st::msgViewsImg.pxHeight() + st::msgViewsPos.y()); iconPos = QPoint(infoRight - infoW + st::msgViewsPos.x(), infoBottom - st::msgViewsImg.pxHeight() + st::msgViewsPos.y());
if (id > 0) { if (id > 0) {
if (outbg) { if (outbg) {
@ -7328,7 +7342,7 @@ void HistoryMessage::drawInfo(Painter &p, int32 right, int32 bottom, int32 width
} }
void HistoryMessage::setViewsCount(int32 count) { void HistoryMessage::setViewsCount(int32 count) {
auto *views = Get<HistoryMessageViews>(); auto views = Get<HistoryMessageViews>();
if (!views || views->_views == count || (count >= 0 && views->_views > count)) return; if (!views || views->_views == count || (count >= 0 && views->_views > count)) return;
int32 was = views->_viewsWidth; int32 was = views->_viewsWidth;
@ -7370,11 +7384,11 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
if (width < 1) return; if (width < 1) return;
int dateh = 0, unreadbarh = 0; int dateh = 0, unreadbarh = 0;
if (auto *date = Get<HistoryMessageDate>()) { if (auto date = Get<HistoryMessageDate>()) {
dateh = date->height(); dateh = date->height();
date->paint(p, 0, _history->width); date->paint(p, 0, _history->width);
} }
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
unreadbarh = unreadbar->height(); unreadbarh = unreadbar->height();
p.translate(0, dateh); p.translate(0, dateh);
unreadbar->paint(p, 0, _history->width); unreadbar->paint(p, 0, _history->width);
@ -7408,14 +7422,14 @@ void HistoryMessage::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
p.translate(-left, -top); p.translate(-left, -top);
} }
auto *reply = Get<HistoryMessageReply>(); auto reply = Get<HistoryMessageReply>();
if (reply) { if (reply) {
reply->checkNameUpdate(); reply->checkNameUpdate();
} }
if (bubble) { if (bubble) {
auto *fwd = Get<HistoryMessageForwarded>(); auto fwd = Get<HistoryMessageForwarded>();
auto *via = Get<HistoryMessageVia>(); auto via = Get<HistoryMessageVia>();
if (displayFromName() && author()->nameVersion > _authorNameVersion) { if (displayFromName() && author()->nameVersion > _authorNameVersion) {
fromNameUpdated(width); fromNameUpdated(width);
} }
@ -7483,7 +7497,7 @@ void HistoryMessage::paintForwardedInfo(Painter &p, QRect &trect, bool selected)
p.setPen(selected ? (hasOutLayout() ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (hasOutLayout() ? st::msgOutServiceFg : st::msgInServiceFg)); p.setPen(selected ? (hasOutLayout() ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (hasOutLayout() ? st::msgOutServiceFg : st::msgInServiceFg));
p.setFont(serviceFont); p.setFont(serviceFont);
auto *fwd = Get<HistoryMessageForwarded>(); auto fwd = Get<HistoryMessageForwarded>();
bool breakEverywhere = (fwd->_text.countHeight(trect.width()) > 2 * serviceFont->height); bool breakEverywhere = (fwd->_text.countHeight(trect.width()) > 2 * serviceFont->height);
textstyleSet(&(selected ? (hasOutLayout() ? st::outFwdTextStyleSelected : st::inFwdTextStyleSelected) : (hasOutLayout() ? st::outFwdTextStyle : st::inFwdTextStyle))); textstyleSet(&(selected ? (hasOutLayout() ? st::outFwdTextStyleSelected : st::inFwdTextStyleSelected) : (hasOutLayout() ? st::outFwdTextStyle : st::inFwdTextStyle)));
fwd->_text.drawElided(p, trect.x(), trect.y(), trect.width(), 2, style::al_left, 0, -1, 0, breakEverywhere); fwd->_text.drawElided(p, trect.x(), trect.y(), trect.width(), 2, style::al_left, 0, -1, 0, breakEverywhere);
@ -7494,7 +7508,7 @@ void HistoryMessage::paintForwardedInfo(Painter &p, QRect &trect, bool selected)
} }
void HistoryMessage::paintReplyInfo(Painter &p, QRect &trect, bool selected) const { void HistoryMessage::paintReplyInfo(Painter &p, QRect &trect, bool selected) const {
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
int32 h = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom(); int32 h = st::msgReplyPadding.top() + st::msgReplyBarSize.height() + st::msgReplyPadding.bottom();
HistoryMessageReply::PaintFlags flags = HistoryMessageReply::PaintInBubble; HistoryMessageReply::PaintFlags flags = HistoryMessageReply::PaintInBubble;
@ -7509,7 +7523,7 @@ void HistoryMessage::paintReplyInfo(Painter &p, QRect &trect, bool selected) con
void HistoryMessage::paintViaBotIdInfo(Painter &p, QRect &trect, bool selected) const { void HistoryMessage::paintViaBotIdInfo(Painter &p, QRect &trect, bool selected) const {
if (!displayFromName() && !Has<HistoryMessageForwarded>()) { if (!displayFromName() && !Has<HistoryMessageForwarded>()) {
if (auto *via = Get<HistoryMessageVia>()) { if (auto via = Get<HistoryMessageVia>()) {
p.setFont(st::msgServiceNameFont); p.setFont(st::msgServiceNameFont);
p.setPen(selected ? (hasOutLayout() ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (hasOutLayout() ? st::msgOutServiceFg : st::msgInServiceFg)); p.setPen(selected ? (hasOutLayout() ? st::msgOutServiceFgSelected : st::msgInServiceFgSelected) : (hasOutLayout() ? st::msgOutServiceFg : st::msgInServiceFg));
p.drawTextLeft(trect.left(), trect.top(), _history->width, via->_text); p.drawTextLeft(trect.left(), trect.top(), _history->width, via->_text);
@ -7519,7 +7533,7 @@ void HistoryMessage::paintViaBotIdInfo(Painter &p, QRect &trect, bool selected)
} }
void HistoryMessage::dependencyItemRemoved(HistoryItem *dependency) { void HistoryMessage::dependencyItemRemoved(HistoryItem *dependency) {
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
reply->itemRemoved(this, dependency); reply->itemRemoved(this, dependency);
} }
} }
@ -7530,6 +7544,27 @@ void HistoryMessage::destroy() {
} }
int HistoryMessage::resizeGetHeight_(int width) { int HistoryMessage::resizeGetHeight_(int width) {
int result = performResizeGetHeight(width);
auto keyboard = inlineReplyKeyboard();
if (auto markup = Get<HistoryMessageReplyMarkup>()) {
int oldTop = markup->oldTop;
if (oldTop >= 0) {
markup->oldTop = -1;
if (keyboard) {
int h = st::msgBotKbButton.margin + keyboard->naturalHeight();
int keyboardTop = _height - h + st::msgBotKbButton.margin - marginBottom();
if (keyboardTop != oldTop) {
Notify::inlineKeyboardMoved(this, oldTop, keyboardTop);
}
}
}
}
return result;
}
int HistoryMessage::performResizeGetHeight(int width) {
if (width < st::msgMinWidth) return _height; if (width < st::msgMinWidth) return _height;
width -= st::msgMargin.left() + st::msgMargin.right(); width -= st::msgMargin.left() + st::msgMargin.right();
@ -7539,9 +7574,9 @@ int HistoryMessage::resizeGetHeight_(int width) {
width = st::msgMaxWidth; width = st::msgMaxWidth;
} }
if (drawBubble()) { if (drawBubble()) {
auto *fwd = Get<HistoryMessageForwarded>(); auto fwd = Get<HistoryMessageForwarded>();
auto *reply = Get<HistoryMessageReply>(); auto reply = Get<HistoryMessageReply>();
auto *via = Get<HistoryMessageVia>(); auto via = Get<HistoryMessageVia>();
bool media = (_media && _media->isDisplayed()); bool media = (_media && _media->isDisplayed());
if (width >= _maxw) { if (width >= _maxw) {
@ -7606,7 +7641,7 @@ int HistoryMessage::resizeGetHeight_(int width) {
} else { } else {
_height = _media->resizeGetHeight(width, this); _height = _media->resizeGetHeight(width, this);
} }
if (ReplyKeyboard *keyboard = inlineReplyKeyboard()) { if (auto keyboard = inlineReplyKeyboard()) {
int32 l = 0, w = 0; int32 l = 0, w = 0;
countPositionAndSize(l, w); countPositionAndSize(l, w);
@ -7669,9 +7704,9 @@ void HistoryMessage::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i
} }
if (drawBubble()) { if (drawBubble()) {
auto *fwd = Get<HistoryMessageForwarded>(); auto fwd = Get<HistoryMessageForwarded>();
auto *via = Get<HistoryMessageVia>(); auto via = Get<HistoryMessageVia>();
auto *reply = Get<HistoryMessageReply>(); auto reply = Get<HistoryMessageReply>();
int top = marginTop(); int top = marginTop();
QRect r(left, top, width, height - top - marginBottom()); QRect r(left, top, width, height - top - marginBottom());
@ -7765,9 +7800,9 @@ void HistoryMessage::getSymbol(uint16 &symbol, bool &after, bool &upon, int32 x,
countPositionAndSize(left, width); countPositionAndSize(left, width);
if (width < 1) return; if (width < 1) return;
auto *fwd = Get<HistoryMessageForwarded>(); auto fwd = Get<HistoryMessageForwarded>();
auto *via = Get<HistoryMessageVia>(); auto via = Get<HistoryMessageVia>();
auto *reply = Get<HistoryMessageReply>(); auto reply = Get<HistoryMessageReply>();
int top = marginTop(); int top = marginTop();
QRect r(left, top, width, height - top - marginBottom()); QRect r(left, top, width, height - top - marginBottom());
@ -7837,7 +7872,7 @@ bool HistoryMessage::hasFromPhoto() const {
HistoryMessage::~HistoryMessage() { HistoryMessage::~HistoryMessage() {
_media.clear(this); _media.clear(this);
if (auto *reply = Get<HistoryMessageReply>()) { if (auto reply = Get<HistoryMessageReply>()) {
reply->clearData(this); reply->clearData(this);
} }
} }
@ -7968,7 +8003,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
case mtpc_messageActionPinMessage: { case mtpc_messageActionPinMessage: {
if (updatePinnedText(&from, &text)) { if (updatePinnedText(&from, &text)) {
auto *pinned = Get<HistoryServicePinned>(); auto pinned = Get<HistoryServicePinned>();
t_assert(pinned != nullptr); t_assert(pinned != nullptr);
links.push_back(pinned->lnk); links.push_back(pinned->lnk);
@ -7990,7 +8025,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
} }
bool HistoryService::updatePinned(bool force) { bool HistoryService::updatePinned(bool force) {
auto *pinned = Get<HistoryServicePinned>(); auto pinned = Get<HistoryServicePinned>();
t_assert(pinned != nullptr); t_assert(pinned != nullptr);
if (!force) { if (!force) {
@ -8038,7 +8073,7 @@ bool HistoryService::updatePinnedText(const QString *pfrom, QString *ptext) {
} }
ClickHandlerPtr second; ClickHandlerPtr second;
auto *pinned = Get<HistoryServicePinned>(); auto pinned = Get<HistoryServicePinned>();
if (pinned && pinned->msg) { if (pinned && pinned->msg) {
HistoryMedia *media = pinned->msg->getMedia(); HistoryMedia *media = pinned->msg->getMedia();
QString mediaText; QString mediaText;
@ -8160,13 +8195,13 @@ void HistoryService::draw(Painter &p, const QRect &r, uint32 selection, uint64 m
if (width < 1) return; if (width < 1) return;
int dateh = 0, unreadbarh = 0; int dateh = 0, unreadbarh = 0;
if (auto *date = Get<HistoryMessageDate>()) { if (auto date = Get<HistoryMessageDate>()) {
dateh = date->height(); dateh = date->height();
date->paint(p, 0, _history->width); date->paint(p, 0, _history->width);
p.translate(0, dateh); p.translate(0, dateh);
height -= dateh; height -= dateh;
} }
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
unreadbarh = unreadbar->height(); unreadbarh = unreadbar->height();
unreadbar->paint(p, 0, _history->width); unreadbar->paint(p, 0, _history->width);
p.translate(0, unreadbarh); p.translate(0, unreadbarh);
@ -8248,7 +8283,7 @@ int32 HistoryService::resizeGetHeight_(int32 width) {
_height += st::msgServiceMargin.top() + _media->resizeGetHeight(_media->currentWidth(), this); _height += st::msgServiceMargin.top() + _media->resizeGetHeight(_media->currentWidth(), this);
} }
_height += displayedDateHeight(); _height += displayedDateHeight();
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
_height += unreadbar->height(); _height += unreadbar->height();
} }
return _height; return _height;
@ -8263,7 +8298,7 @@ bool HistoryService::hasPoint(int32 x, int32 y) const {
y -= dateh; y -= dateh;
height -= dateh; height -= dateh;
} }
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
int unreadbarh = unreadbar->height(); int unreadbarh = unreadbar->height();
y -= unreadbarh; y -= unreadbarh;
height -= unreadbarh; height -= unreadbarh;
@ -8287,7 +8322,7 @@ void HistoryService::getState(ClickHandlerPtr &lnk, HistoryCursorState &state, i
y -= dateh; y -= dateh;
height -= dateh; height -= dateh;
} }
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
int unreadbarh = unreadbar->height(); int unreadbarh = unreadbar->height();
y -= unreadbarh; y -= unreadbarh;
height -= unreadbarh; height -= unreadbarh;
@ -8321,7 +8356,7 @@ void HistoryService::getSymbol(uint16 &symbol, bool &after, bool &upon, int32 x,
y -= dateh; y -= dateh;
height -= dateh; height -= dateh;
} }
if (auto *unreadbar = Get<HistoryMessageUnreadBar>()) { if (auto unreadbar = Get<HistoryMessageUnreadBar>()) {
int unreadbarh = unreadbar->height(); int unreadbarh = unreadbar->height();
y -= unreadbarh; y -= unreadbarh;
height -= unreadbarh; height -= unreadbarh;

View File

@ -1118,6 +1118,9 @@ struct HistoryMessageReplyMarkup : public BaseComponent<HistoryMessageReplyMarku
UniquePointer<ReplyKeyboard> inlineKeyboard; UniquePointer<ReplyKeyboard> inlineKeyboard;
// If >= 0 it holds the y coord of the inlineKeyboard before the last edition.
int oldTop = -1;
private: private:
void createFromButtonRows(const QVector<MTPKeyboardButtonRow> &v); void createFromButtonRows(const QVector<MTPKeyboardButtonRow> &v);
@ -2586,7 +2589,7 @@ public:
void detachFromItem(HistoryItem *item) override; void detachFromItem(HistoryItem *item) override;
bool hasReplyPreview() const override { bool hasReplyPreview() const override {
return (_data->photo && !_data->photo->thumb->isNull()) || (_data->doc && !_data->doc->thumb->isNull()); return (_data->photo && !_data->photo->thumb->isNull()) || (_data->document && !_data->document->thumb->isNull());
} }
ImagePtr replyPreview() override; ImagePtr replyPreview() override;
@ -2883,6 +2886,7 @@ private:
void initDimensions() override; void initDimensions() override;
int resizeGetHeight_(int width) override; int resizeGetHeight_(int width) override;
int performResizeGetHeight(int width);
bool displayForwardedFrom() const { bool displayForwardedFrom() const {
if (const HistoryMessageForwarded *fwd = Get<HistoryMessageForwarded>()) { if (const HistoryMessageForwarded *fwd = Get<HistoryMessageForwarded>()) {

View File

@ -1908,6 +1908,16 @@ void HistoryInner::notifyMigrateUpdated() {
_migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0; _migrated = _peer->migrateFrom() ? App::history(_peer->migrateFrom()->id) : 0;
} }
int HistoryInner::moveScrollFollowingInlineKeyboard(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) {
if (item == App::mousedItem()) {
int top = itemTop(item);
if (top >= oldKeyboardTop) {
return newKeyboardTop - oldKeyboardTop;
}
}
return 0;
}
void HistoryInner::applyDragSelection() { void HistoryInner::applyDragSelection() {
applyDragSelection(&_selected); applyDragSelection(&_selected);
} }
@ -3183,6 +3193,14 @@ void HistoryWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
} }
} }
void HistoryWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) {
if (_history == item->history() || _migrated == item->history()) {
if (int move = _list->moveScrollFollowingInlineKeyboard(item, oldKeyboardTop, newKeyboardTop)) {
_addToScroll = move;
}
}
}
void HistoryWidget::notify_userIsBotChanged(UserData *user) { void HistoryWidget::notify_userIsBotChanged(UserData *user) {
if (_peer && _peer == user) { if (_peer && _peer == user) {
_list->notifyIsBotChanged(); _list->notifyIsBotChanged();
@ -3577,6 +3595,7 @@ void HistoryWidget::showHistory(const PeerId &peerId, MsgId showAtMsgId, bool re
updateBotKeyboard(); updateBotKeyboard();
} }
_addToScroll = 0;
_editMsgId = 0; _editMsgId = 0;
_saveEditMsgRequestId = 0; _saveEditMsgRequestId = 0;
_replyToId = 0; _replyToId = 0;
@ -6418,6 +6437,9 @@ void HistoryWidget::updateListSize(bool initial, bool loadedDown, const ScrollCh
toY += change.value; toY += change.value;
} else if (change.type == ScrollChangeNoJumpToBottom) { } else if (change.type == ScrollChangeNoJumpToBottom) {
toY = wasScrollTop; toY = wasScrollTop;
} else if (_addToScroll) {
toY += _addToScroll;
_addToScroll = 0;
} }
if (toY > _scroll.scrollTopMax()) { if (toY > _scroll.scrollTopMax()) {
toY = _scroll.scrollTopMax(); toY = _scroll.scrollTopMax();
@ -7425,24 +7447,24 @@ void HistoryWidget::updatePreview() {
if (_previewData->title.isEmpty()) { if (_previewData->title.isEmpty()) {
if (_previewData->description.isEmpty()) { if (_previewData->description.isEmpty()) {
title = _previewData->author; title = _previewData->author;
desc = ((_previewData->doc && !_previewData->doc->name.isEmpty()) ? _previewData->doc->name : _previewData->url); desc = ((_previewData->document && !_previewData->document->name.isEmpty()) ? _previewData->document->name : _previewData->url);
} else { } else {
title = _previewData->description; title = _previewData->description;
desc = _previewData->author.isEmpty() ? ((_previewData->doc && !_previewData->doc->name.isEmpty()) ? _previewData->doc->name : _previewData->url) : _previewData->author; desc = _previewData->author.isEmpty() ? ((_previewData->document && !_previewData->document->name.isEmpty()) ? _previewData->document->name : _previewData->url) : _previewData->author;
} }
} else { } else {
title = _previewData->title; title = _previewData->title;
desc = _previewData->description.isEmpty() ? (_previewData->author.isEmpty() ? ((_previewData->doc && !_previewData->doc->name.isEmpty()) ? _previewData->doc->name : _previewData->url) : _previewData->author) : _previewData->description; desc = _previewData->description.isEmpty() ? (_previewData->author.isEmpty() ? ((_previewData->document && !_previewData->document->name.isEmpty()) ? _previewData->document->name : _previewData->url) : _previewData->author) : _previewData->description;
} }
} else { } else {
title = _previewData->siteName; title = _previewData->siteName;
desc = _previewData->title.isEmpty() ? (_previewData->description.isEmpty() ? (_previewData->author.isEmpty() ? ((_previewData->doc && !_previewData->doc->name.isEmpty()) ? _previewData->doc->name : _previewData->url) : _previewData->author) : _previewData->description) : _previewData->title; desc = _previewData->title.isEmpty() ? (_previewData->description.isEmpty() ? (_previewData->author.isEmpty() ? ((_previewData->document && !_previewData->document->name.isEmpty()) ? _previewData->document->name : _previewData->url) : _previewData->author) : _previewData->description) : _previewData->title;
} }
if (title.isEmpty()) { if (title.isEmpty()) {
if (_previewData->photo) { if (_previewData->document) {
title = lang(lng_attach_photo);
} else if (_previewData->doc) {
title = lang(lng_attach_file); title = lang(lng_attach_file);
} else if (_previewData->photo) {
title = lang(lng_attach_photo);
} }
} }
_previewTitle.setText(st::msgServiceNameFont, title, _textNameOptions); _previewTitle.setText(st::msgServiceNameFont, title, _textNameOptions);
@ -7802,8 +7824,8 @@ void HistoryWidget::drawField(Painter &p) {
if (drawPreview) { if (drawPreview) {
int32 previewLeft = st::replySkip + st::webPageLeft; int32 previewLeft = st::replySkip + st::webPageLeft;
p.fillRect(st::replySkip, backy + st::msgReplyPadding.top(), st::webPageBar, st::msgReplyBarSize.height(), st::msgInReplyBarColor->b); p.fillRect(st::replySkip, backy + st::msgReplyPadding.top(), st::webPageBar, st::msgReplyBarSize.height(), st::msgInReplyBarColor->b);
if ((_previewData->photo && !_previewData->photo->thumb->isNull()) || (_previewData->doc && !_previewData->doc->thumb->isNull())) { if ((_previewData->photo && !_previewData->photo->thumb->isNull()) || (_previewData->document && !_previewData->document->thumb->isNull())) {
ImagePtr replyPreview = _previewData->photo ? _previewData->photo->makeReplyPreview() : _previewData->doc->makeReplyPreview(); ImagePtr replyPreview = _previewData->photo ? _previewData->photo->makeReplyPreview() : _previewData->document->makeReplyPreview();
if (!replyPreview->isNull()) { if (!replyPreview->isNull()) {
QRect to(previewLeft, backy + st::msgReplyPadding.top(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height()); QRect to(previewLeft, backy + st::msgReplyPadding.top(), st::msgReplyBarSize.height(), st::msgReplyBarSize.height());
if (replyPreview->width() == replyPreview->height()) { if (replyPreview->width() == replyPreview->height()) {

View File

@ -101,6 +101,10 @@ public:
void notifyIsBotChanged(); void notifyIsBotChanged();
void notifyMigrateUpdated(); void notifyMigrateUpdated();
// When inline keyboard has moved because of the edition of its item we want
// to move scroll position so that mouse points to the same button row.
int moveScrollFollowingInlineKeyboard(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
// AbstractTooltipShower interface // AbstractTooltipShower interface
QString tooltipText() const override; QString tooltipText() const override;
QPoint tooltipPos() const override; QPoint tooltipPos() const override;
@ -680,6 +684,7 @@ public:
void notify_botCommandsChanged(UserData *user); void notify_botCommandsChanged(UserData *user);
void notify_inlineBotRequesting(bool requesting); void notify_inlineBotRequesting(bool requesting);
void notify_replyMarkupUpdated(const HistoryItem *item); void notify_replyMarkupUpdated(const HistoryItem *item);
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
void notify_userIsBotChanged(UserData *user); void notify_userIsBotChanged(UserData *user);
void notify_migrateUpdated(PeerData *peer); void notify_migrateUpdated(PeerData *peer);
void notify_clipStopperHidden(ClipStopperType type); void notify_clipStopperHidden(ClipStopperType type);
@ -977,10 +982,11 @@ private:
History *_migrated = nullptr; History *_migrated = nullptr;
History *_history = nullptr; History *_history = nullptr;
bool _histInited = false; // initial updateListSize() called bool _histInited = false; // initial updateListSize() called
int _addToScroll = 0;
int32 _lastScroll = 0; int _lastScroll = 0;// gifs optimization
uint64 _lastScrolled = 0; uint64 _lastScrolled = 0;
QTimer _updateHistoryItems; // gifs optimization QTimer _updateHistoryItems;
IconedButton _toHistoryEnd; IconedButton _toHistoryEnd;
CollapseButton _collapseComments; CollapseButton _collapseComments;

View File

@ -1105,8 +1105,8 @@ LayoutOverviewLink::LayoutOverviewLink(HistoryMedia *media, HistoryItem *parent)
_page = (media && media->type() == MediaTypeWebPage) ? static_cast<HistoryWebPage*>(media)->webpage() : 0; _page = (media && media->type() == MediaTypeWebPage) ? static_cast<HistoryWebPage*>(media)->webpage() : 0;
if (_page) { if (_page) {
if (_page->doc) { if (_page->document) {
_photol.reset(new DocumentOpenClickHandler(_page->doc)); _photol.reset(new DocumentOpenClickHandler(_page->document));
} else if (_page->photo) { } else if (_page->photo) {
if (_page->type == WebPageProfile || _page->type == WebPageVideo) { if (_page->type == WebPageProfile || _page->type == WebPageVideo) {
_photol = MakeShared<UrlClickHandler>(_page->url); _photol = MakeShared<UrlClickHandler>(_page->url);
@ -1136,11 +1136,11 @@ LayoutOverviewLink::LayoutOverviewLink(HistoryMedia *media, HistoryItem *parent)
tw = convertScale(_page->photo->thumb->width()); tw = convertScale(_page->photo->thumb->width());
th = convertScale(_page->photo->thumb->height()); th = convertScale(_page->photo->thumb->height());
} else if (_page && _page->doc) { } else if (_page && _page->document) {
if (!_page->doc->thumb->loaded()) _page->doc->thumb->load(false, false); if (!_page->document->thumb->loaded()) _page->document->thumb->load(false, false);
tw = convertScale(_page->doc->thumb->width()); tw = convertScale(_page->document->thumb->width());
th = convertScale(_page->doc->thumb->height()); th = convertScale(_page->document->thumb->height());
} }
if (tw > st::dlgPhotoSize) { if (tw > st::dlgPhotoSize) {
if (th > tw) { if (th > tw) {
@ -1214,16 +1214,16 @@ void LayoutOverviewLink::paint(Painter &p, const QRect &clip, uint32 selection,
if (clip.intersects(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width))) { if (clip.intersects(rtlrect(0, top, st::dlgPhotoSize, st::dlgPhotoSize, _width))) {
if (_page && _page->photo) { if (_page && _page->photo) {
QPixmap pix; QPixmap pix;
if (_page->photo->loaded()) { if (_page->photo->medium->loaded()) {
pix = _page->photo->full->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize);
} else if (_page->photo->medium->loaded()) {
pix = _page->photo->medium->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); pix = _page->photo->medium->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize);
} else if (_page->photo->loaded()) {
pix = _page->photo->full->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize);
} else { } else {
pix = _page->photo->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize); pix = _page->photo->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize);
} }
p.drawPixmapLeft(0, top, _width, pix); p.drawPixmapLeft(0, top, _width, pix);
} else if (_page && _page->doc && !_page->doc->thumb->isNull()) { } else if (_page && _page->document && !_page->document->thumb->isNull()) {
p.drawPixmapLeft(0, top, _width, _page->doc->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize)); p.drawPixmapLeft(0, top, _width, _page->document->thumb->pixSingle(_pixw, _pixh, st::dlgPhotoSize, st::dlgPhotoSize));
} else { } else {
int32 index = _letter.isEmpty() ? 0 : (_letter.at(0).unicode() % 4); int32 index = _letter.isEmpty() ? 0 : (_letter.at(0).unicode() % 4);
switch (index) { switch (index) {

View File

@ -399,40 +399,12 @@ MainWidget *TopBarWidget::main() {
} }
MainWidget::MainWidget(Window *window) : TWidget(window) MainWidget::MainWidget(Window *window) : TWidget(window)
, _started(0)
, failedObjId(0)
, _toForwardNameVersion(0)
, _a_show(animation(this, &MainWidget::step_show)) , _a_show(animation(this, &MainWidget::step_show))
, _dialogsWidth(st::dlgMinWidth)
, dialogs(this) , dialogs(this)
, history(this) , history(this)
, profile(0)
, overview(0)
, _player(this) , _player(this)
, _topBar(this) , _topBar(this)
, _forwardConfirm(0)
, _hider(0)
, _peerInStack(0)
, _msgIdInStack(0)
, _playerHeight(0)
, _contentScrollAddToY(0)
, _mediaType(this) , _mediaType(this)
, _mediaTypeMask(0)
, updDate(0)
, updQts(-1)
, updSeq(0)
, _getDifferenceTimeByPts(0)
, _getDifferenceTimeAfterFail(0)
, _onlineRequest(0)
, _lastWasOnline(false)
, _lastSetOnline(0)
, _isIdle(false)
, _failDifferenceTimeout(1)
, _lastUpdateTime(0)
, _handlingChannelDifference(false)
, _cachedX(0)
, _cachedY(0)
, _background(0)
, _api(new ApiWrap(this)) { , _api(new ApiWrap(this)) {
setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight)); setGeometry(QRect(0, st::titleHeight, App::wnd()->width(), App::wnd()->height() - st::titleHeight));
@ -776,6 +748,10 @@ void MainWidget::notify_replyMarkupUpdated(const HistoryItem *item) {
history.notify_replyMarkupUpdated(item); history.notify_replyMarkupUpdated(item);
} }
void MainWidget::notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop) {
history.notify_inlineKeyboardMoved(item, oldKeyboardTop, newKeyboardTop);
}
void MainWidget::notify_userIsBotChanged(UserData *bot) { void MainWidget::notify_userIsBotChanged(UserData *bot) {
history.notify_userIsBotChanged(bot); history.notify_userIsBotChanged(bot);
} }
@ -2890,7 +2866,7 @@ void MainWidget::resizeEvent(QResizeEvent *e) {
_contentScrollAddToY = 0; _contentScrollAddToY = 0;
} }
int32 MainWidget::contentScrollAddToY() const { int MainWidget::contentScrollAddToY() const {
return _contentScrollAddToY; return _contentScrollAddToY;
} }

View File

@ -223,7 +223,7 @@ public:
TopBarWidget *topBar(); TopBarWidget *topBar();
PlayerWidget *player(); PlayerWidget *player();
int32 contentScrollAddToY() const; int contentScrollAddToY() const;
void animShow(const QPixmap &bgAnimCache, bool back = false); void animShow(const QPixmap &bgAnimCache, bool back = false);
void step_show(float64 ms, bool timer); void step_show(float64 ms, bool timer);
@ -453,6 +453,7 @@ public:
void notify_botCommandsChanged(UserData *bot); void notify_botCommandsChanged(UserData *bot);
void notify_inlineBotRequesting(bool requesting); void notify_inlineBotRequesting(bool requesting);
void notify_replyMarkupUpdated(const HistoryItem *item); void notify_replyMarkupUpdated(const HistoryItem *item);
void notify_inlineKeyboardMoved(const HistoryItem *item, int oldKeyboardTop, int newKeyboardTop);
void notify_userIsBotChanged(UserData *bot); void notify_userIsBotChanged(UserData *bot);
void notify_userIsContactChanged(UserData *user, bool fromThisApp); void notify_userIsContactChanged(UserData *user, bool fromThisApp);
void notify_migrateUpdated(PeerData *peer); void notify_migrateUpdated(PeerData *peer);
@ -548,15 +549,15 @@ private:
void messagesAffected(PeerData *peer, const MTPmessages_AffectedMessages &result); void messagesAffected(PeerData *peer, const MTPmessages_AffectedMessages &result);
void overviewLoaded(History *history, const MTPmessages_Messages &result, mtpRequestId req); void overviewLoaded(History *history, const MTPmessages_Messages &result, mtpRequestId req);
bool _started; bool _started = false;
uint64 failedObjId; uint64 failedObjId = 0;
QString failedFileName; QString failedFileName;
void loadFailed(mtpFileLoader *loader, bool started, const char *retrySlot); void loadFailed(mtpFileLoader *loader, bool started, const char *retrySlot);
SelectedItemSet _toForward; SelectedItemSet _toForward;
Text _toForwardFrom, _toForwardText; Text _toForwardFrom, _toForwardText;
int32 _toForwardNameVersion; int32 _toForwardNameVersion = 0;
QMap<WebPageId, bool> _webPagesUpdated; QMap<WebPageId, bool> _webPagesUpdated;
QTimer _webPageUpdater; QTimer _webPageUpdater;
@ -611,27 +612,29 @@ private:
anim::ivalue a_coordUnder, a_coordOver; anim::ivalue a_coordUnder, a_coordOver;
anim::fvalue a_shadow; anim::fvalue a_shadow;
int32 _dialogsWidth; int _dialogsWidth = st::dlgMinWidth;
DialogsWidget dialogs; DialogsWidget dialogs;
HistoryWidget history; HistoryWidget history;
ProfileWidget *profile; ProfileWidget *profile = nullptr;
OverviewWidget *overview; OverviewWidget *overview = nullptr;
PlayerWidget _player; PlayerWidget _player;
TopBarWidget _topBar; TopBarWidget _topBar;
ConfirmBox *_forwardConfirm; // for narrow mode ConfirmBox *_forwardConfirm = nullptr; // for single column layout
HistoryHider *_hider; HistoryHider *_hider = nullptr;
StackItems _stack; StackItems _stack;
PeerData *_peerInStack; PeerData *_peerInStack = nullptr;
MsgId _msgIdInStack; MsgId _msgIdInStack = 0;
int32 _playerHeight; int _playerHeight = 0;
int32 _contentScrollAddToY; int _contentScrollAddToY = 0;
Dropdown _mediaType; Dropdown _mediaType;
int32 _mediaTypeMask; int32 _mediaTypeMask = 0;
int32 updDate, updQts, updSeq; int32 updDate = 0;
int32 updQts = -1;
int32 updSeq = 0;
SingleTimer noUpdatesTimer; SingleTimer noUpdatesTimer;
bool ptsUpdated(int32 pts, int32 ptsCount); bool ptsUpdated(int32 pts, int32 ptsCount);
@ -642,7 +645,8 @@ private:
typedef QMap<ChannelData*, uint64> ChannelGetDifferenceTime; typedef QMap<ChannelData*, uint64> ChannelGetDifferenceTime;
ChannelGetDifferenceTime _channelGetDifferenceTimeByPts, _channelGetDifferenceTimeAfterFail; ChannelGetDifferenceTime _channelGetDifferenceTimeByPts, _channelGetDifferenceTimeAfterFail;
uint64 _getDifferenceTimeByPts, _getDifferenceTimeAfterFail; uint64 _getDifferenceTimeByPts = 0;
uint64 _getDifferenceTimeAfterFail = 0;
bool getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, uint64 &curTime); bool getDifferenceTimeChanged(ChannelData *channel, int32 ms, ChannelGetDifferenceTime &channelCurTime, uint64 &curTime);
@ -653,11 +657,11 @@ private:
SingleTimer _byMinChannelTimer; SingleTimer _byMinChannelTimer;
mtpRequestId _onlineRequest; mtpRequestId _onlineRequest = 0;
SingleTimer _onlineTimer, _onlineUpdater, _idleFinishTimer; SingleTimer _onlineTimer, _onlineUpdater, _idleFinishTimer;
bool _lastWasOnline; bool _lastWasOnline = false;
uint64 _lastSetOnline; uint64 _lastSetOnline = 0;
bool _isIdle; bool _isIdle = false;
QSet<PeerData*> updateNotifySettingPeers; QSet<PeerData*> updateNotifySettingPeers;
SingleTimer updateNotifySettingTimer; SingleTimer updateNotifySettingTimer;
@ -670,17 +674,18 @@ private:
typedef QMap<PeerData*, mtpRequestId> OverviewsPreload; typedef QMap<PeerData*, mtpRequestId> OverviewsPreload;
OverviewsPreload _overviewPreload[OverviewCount], _overviewLoad[OverviewCount]; OverviewsPreload _overviewPreload[OverviewCount], _overviewLoad[OverviewCount];
int32 _failDifferenceTimeout; // growing timeout for getDifference calls, if it fails int32 _failDifferenceTimeout = 1; // growing timeout for getDifference calls, if it fails
typedef QMap<ChannelData*, int32> ChannelFailDifferenceTimeout; typedef QMap<ChannelData*, int32> ChannelFailDifferenceTimeout;
ChannelFailDifferenceTimeout _channelFailDifferenceTimeout; // growing timeout for getChannelDifference calls, if it fails ChannelFailDifferenceTimeout _channelFailDifferenceTimeout; // growing timeout for getChannelDifference calls, if it fails
SingleTimer _failDifferenceTimer; SingleTimer _failDifferenceTimer;
uint64 _lastUpdateTime; uint64 _lastUpdateTime = 0;
bool _handlingChannelDifference; bool _handlingChannelDifference = false;
QPixmap _cachedBackground; QPixmap _cachedBackground;
QRect _cachedFor, _willCacheFor; QRect _cachedFor, _willCacheFor;
int _cachedX, _cachedY; int _cachedX = 0;
int _cachedY = 0;
SingleTimer _cacheBackgroundTimer; SingleTimer _cacheBackgroundTimer;
typedef QMap<ChannelData*, bool> UpdatedChannels; typedef QMap<ChannelData*, bool> UpdatedChannels;
@ -697,7 +702,7 @@ private:
void viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req); void viewsIncrementDone(QVector<MTPint> ids, const MTPVector<MTPint> &result, mtpRequestId req);
bool viewsIncrementFail(const RPCError &error, mtpRequestId req); bool viewsIncrementFail(const RPCError &error, mtpRequestId req);
App::WallPaper *_background; App::WallPaper *_background = nullptr;
ApiWrap *_api; ApiWrap *_api;

View File

@ -1428,7 +1428,7 @@ DocumentData::~DocumentData() {
} }
} }
WebPageData::WebPageData(const WebPageId &id, WebPageType type, const QString &url, const QString &displayUrl, const QString &siteName, const QString &title, const QString &description, PhotoData *photo, DocumentData *doc, int32 duration, const QString &author, int32 pendingTill) : id(id) WebPageData::WebPageData(const WebPageId &id, WebPageType type, const QString &url, const QString &displayUrl, const QString &siteName, const QString &title, const QString &description, DocumentData *document, PhotoData *photo, int32 duration, const QString &author, int32 pendingTill) : id(id)
, type(type) , type(type)
, url(url) , url(url)
, displayUrl(displayUrl) , displayUrl(displayUrl)
@ -1438,7 +1438,7 @@ WebPageData::WebPageData(const WebPageId &id, WebPageType type, const QString &u
, duration(duration) , duration(duration)
, author(author) , author(author)
, photo(photo) , photo(photo)
, doc(doc) , document(document)
, pendingTill(pendingTill) { , pendingTill(pendingTill) {
} }

View File

@ -1228,7 +1228,7 @@ inline WebPageType toWebPageType(const QString &type) {
} }
struct WebPageData { struct WebPageData {
WebPageData(const WebPageId &id, WebPageType type = WebPageArticle, const QString &url = QString(), const QString &displayUrl = QString(), const QString &siteName = QString(), const QString &title = QString(), const QString &description = QString(), PhotoData *photo = 0, DocumentData *doc = 0, int32 duration = 0, const QString &author = QString(), int32 pendingTill = -1); WebPageData(const WebPageId &id, WebPageType type = WebPageArticle, const QString &url = QString(), const QString &displayUrl = QString(), const QString &siteName = QString(), const QString &title = QString(), const QString &description = QString(), DocumentData *doc = nullptr, PhotoData *photo = nullptr, int32 duration = 0, const QString &author = QString(), int32 pendingTill = -1);
void forget() { void forget() {
if (photo) photo->forget(); if (photo) photo->forget();
@ -1240,7 +1240,7 @@ struct WebPageData {
int32 duration; int32 duration;
QString author; QString author;
PhotoData *photo; PhotoData *photo;
DocumentData *doc; DocumentData *document;
int32 pendingTill; int32 pendingTill;
}; };