From 6b565acbd6985a7d94f2b5c7e3b5f5012bd11a3d Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 7 Dec 2015 13:06:59 +0300 Subject: [PATCH] fixed show profile from chats list in single-column layout, requestFullPeer() used in Settings, empty popup menu not shown in HistoryInner, no chat list jump when returning to history, channel admins box layout fixed --- Telegram/SourceFiles/boxes/contactsbox.cpp | 5 +++-- Telegram/SourceFiles/historywidget.cpp | 19 ++++++------------- Telegram/SourceFiles/mainwidget.cpp | 5 ++++- Telegram/SourceFiles/mainwidget.h | 2 +- Telegram/SourceFiles/settingswidget.cpp | 12 ++++++------ Telegram/SourceFiles/settingswidget.h | 4 ++-- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/Telegram/SourceFiles/boxes/contactsbox.cpp b/Telegram/SourceFiles/boxes/contactsbox.cpp index 4e6056ed3..a7827d193 100644 --- a/Telegram/SourceFiles/boxes/contactsbox.cpp +++ b/Telegram/SourceFiles/boxes/contactsbox.cpp @@ -1826,7 +1826,7 @@ void MembersInner::paintEvent(QPaintEvent *e) { paintDialog(p, _rows[from], data(from), sel, kickSel, kickDown); p.translate(0, _rowHeight); } - if (to == _rows.size() && (_rows.size() < _channel->count || _rows.size() >= cMaxGroupCount())) { + if (to == _rows.size() && _filter == MembersFilterRecent && (_rows.size() < _channel->count || _rows.size() >= cMaxGroupCount())) { p.setPen(st::stickersReorderFg); _about.draw(p, st::contactsPadding.left(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center); } @@ -2005,7 +2005,7 @@ void MembersInner::refresh() { } else { _about.setText(st::boxTextFont, lng_channel_only_last_shown(lt_count, _rows.size())); _aboutHeight = st::stickersReorderPadding.top() + _about.countHeight(_aboutWidth) + st::stickersReorderPadding.bottom(); - if (_rows.size() >= _channel->count && _rows.size() < cMaxGroupCount()) { + if (_filter != MembersFilterRecent || (_rows.size() >= _channel->count && _rows.size() < cMaxGroupCount())) { _aboutHeight = 0; } resize(width(), st::membersPadding.top() + _newItemHeight + _rows.size() * _rowHeight + st::membersPadding.bottom() + _aboutHeight); @@ -2243,6 +2243,7 @@ void MembersInner::removeKicked() { --_channel->adminsCount; if (App::main()) emit App::main()->peerUpdated(_channel); } + refresh(); } _kickConfirm = 0; } diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 405ab685b..dddec35fd 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -874,6 +874,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { isUponSelected = hasSelected; } + _menu = new PopupMenu(); + _contextMenuLnk = textlnkOver(); HistoryItem *item = App::hoveredItem() ? App::hoveredItem() : App::hoveredLinkItem(); PhotoLink *lnkPhoto = dynamic_cast(_contextMenuLnk.data()); @@ -881,7 +883,6 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { AudioLink *lnkAudio = dynamic_cast(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast(_contextMenuLnk.data()); if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument) { - _menu = new PopupMenu(); if (isUponSelected > 0) { _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); } @@ -931,59 +932,49 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { HistoryServiceMsg *srv = dynamic_cast(item); if (isUponSelected > 0) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); if (item && item->id > 0 && isUponSelected != 2 && canSendMessages) { _menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage())); } } else { if (item && item->id > 0 && isUponSelected != -2 && canSendMessages) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage())); } if (item && !isUponSelected && !_contextMenuLnk) { if (HistorySticker *sticker = dynamic_cast(msg ? msg->getMedia() : 0)) { DocumentData *doc = sticker->document(); if (doc && doc->sticker() && doc->sticker()->set.type() != mtpc_inputStickerSetEmpty) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(doc->sticker()->setInstalled() ? lng_context_pack_info : lng_context_pack_add), _widget, SLOT(onStickerPackInfo())); } } QString contextMenuText = item->selectedText(FullItemSel); if (!contextMenuText.isEmpty() && (!msg || !msg->getMedia() || msg->getMedia()->type() != MediaTypeSticker)) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_copy_text), this, SLOT(copyContextText()))->setEnabled(true); } } } if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_link), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_link), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_email), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_email), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_mention), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_mention), this, SLOT(copyContextUrl()))->setEnabled(true); } else if (_contextMenuLnk && dynamic_cast(_contextMenuLnk.data())) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_open_hashtag), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_hashtag), this, SLOT(copyContextUrl()))->setEnabled(true); } else { } if (isUponSelected > 1) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_forward_selected), _widget, SLOT(onForwardSelected())); if (selectedForDelete == selectedForForward) { _menu->addAction(lang(lng_context_delete_selected), _widget, SLOT(onDeleteSelected())); } _menu->addAction(lang(lng_context_clear_selection), _widget, SLOT(onClearSelected())); } else if (item && ((isUponSelected != -2 && (canForward || canDelete)) || item->id > 0)) { - if (!_menu) _menu = new PopupMenu(); if (isUponSelected != -2) { if (canForward) { _menu->addAction(lang(lng_context_forward_msg), _widget, SLOT(forwardMessage()))->setEnabled(true); @@ -998,7 +989,6 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { } } else { if (App::mousedItem() && !App::mousedItem()->serviceMsg() && App::mousedItem()->id > 0) { - if (!_menu) _menu = new PopupMenu(); _menu->addAction(lang(lng_context_select_msg), _widget, SLOT(selectMessage()))->setEnabled(true); item = App::mousedItem(); } @@ -1006,7 +996,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { App::contextItem(item); } - if (_menu) { + if (_menu->actions().isEmpty()) { + delete _menu; + _menu = 0; + } else { connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroy(QObject*))); _menu->popup(e->globalPos()); e->accept(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 7c5e1a057..b1bf35e83 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2346,7 +2346,9 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back) //} if (!dialogs.isHidden()) { - dialogs.scrollToPeer(peerId, showAtMsgId); + if (!back) { + dialogs.scrollToPeer(peerId, showAtMsgId); + } dialogs.update(); } App::wnd()->getTitle()->updateBackButton(); @@ -2517,6 +2519,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop) if (back) clearBotStartToken(history.peer()); history.showHistory(0, 0); history.hide(); + if (!cWideMode()) dialogs.hide(); orderWidgets(); diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index 8393d67a9..033196af8 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -564,7 +564,7 @@ private: StackItems _stack; PeerData *_peerInStack; MsgId _msgIdInStack; - + int32 _playerHeight; int32 _contentScrollAddToY; diff --git a/Telegram/SourceFiles/settingswidget.cpp b/Telegram/SourceFiles/settingswidget.cpp index dcf8e4ec7..3cd1c4945 100644 --- a/Telegram/SourceFiles/settingswidget.cpp +++ b/Telegram/SourceFiles/settingswidget.cpp @@ -203,11 +203,12 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent), { if (self()) { connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update())); + connect(App::api(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*))); _nameText.setText(st::setNameFont, _nameCache, _textNameOptions); PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0; if (selfPhoto && selfPhoto->date) _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self())); - MTP::send(MTPusers_GetFullUser(self()->inputUser), rpcDone(&SettingsInner::gotFullSelf), RPCFailHandlerPtr(), 0, 10); + App::api()->requestFullPeer(self()); onReloadPassword(); connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *))); @@ -346,7 +347,7 @@ void SettingsInner::peerUpdated(PeerData *data) { _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self())); } else { _photoLink = TextLinkPtr(); - MTP::send(MTPusers_GetFullUser(self()->inputUser), rpcDone(&SettingsInner::gotFullSelf)); + App::api()->requestFullPeer(self()); } } else { _photoLink = TextLinkPtr(); @@ -897,10 +898,9 @@ void SettingsInner::updateBackgroundRect() { update(_left, _tileBackground.y() - st::setLittleSkip - st::setBackgroundSize, st::setBackgroundSize, st::setBackgroundSize); } -void SettingsInner::gotFullSelf(const MTPUserFull &selfFull) { - if (!self()) return; - App::feedPhoto(selfFull.c_userFull().vprofile_photo); - App::feedUsers(MTP_vector(1, selfFull.c_userFull().vuser)); +void SettingsInner::onFullPeerUpdated(PeerData *peer) { + if (!self() || self() != peer) return; + PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0; if (selfPhoto && selfPhoto->date) { _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self())); diff --git a/Telegram/SourceFiles/settingswidget.h b/Telegram/SourceFiles/settingswidget.h index 08092e1e0..1a8dcdfac 100644 --- a/Telegram/SourceFiles/settingswidget.h +++ b/Telegram/SourceFiles/settingswidget.h @@ -77,8 +77,6 @@ public: void updateOnlineDisplay(); - void gotFullSelf(const MTPUserFull &self); - void showAll(); void chooseCustomLang(); @@ -107,6 +105,8 @@ public slots: #endif void onRestartNow(); + void onFullPeerUpdated(PeerData *peer); + void onPasscode(); void onPasscodeOff(); void onAutoLock();