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

This commit is contained in:
John Preston 2015-12-07 13:06:59 +03:00
parent e2da90e844
commit 6b565acbd6
6 changed files with 22 additions and 25 deletions

View File

@ -1826,7 +1826,7 @@ void MembersInner::paintEvent(QPaintEvent *e) {
paintDialog(p, _rows[from], data(from), sel, kickSel, kickDown); paintDialog(p, _rows[from], data(from), sel, kickSel, kickDown);
p.translate(0, _rowHeight); 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); p.setPen(st::stickersReorderFg);
_about.draw(p, st::contactsPadding.left(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center); _about.draw(p, st::contactsPadding.left(), st::stickersReorderPadding.top(), _aboutWidth, style::al_center);
} }
@ -2005,7 +2005,7 @@ void MembersInner::refresh() {
} else { } else {
_about.setText(st::boxTextFont, lng_channel_only_last_shown(lt_count, _rows.size())); _about.setText(st::boxTextFont, lng_channel_only_last_shown(lt_count, _rows.size()));
_aboutHeight = st::stickersReorderPadding.top() + _about.countHeight(_aboutWidth) + st::stickersReorderPadding.bottom(); _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; _aboutHeight = 0;
} }
resize(width(), st::membersPadding.top() + _newItemHeight + _rows.size() * _rowHeight + st::membersPadding.bottom() + _aboutHeight); resize(width(), st::membersPadding.top() + _newItemHeight + _rows.size() * _rowHeight + st::membersPadding.bottom() + _aboutHeight);
@ -2243,6 +2243,7 @@ void MembersInner::removeKicked() {
--_channel->adminsCount; --_channel->adminsCount;
if (App::main()) emit App::main()->peerUpdated(_channel); if (App::main()) emit App::main()->peerUpdated(_channel);
} }
refresh();
} }
_kickConfirm = 0; _kickConfirm = 0;
} }

View File

@ -874,6 +874,8 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
isUponSelected = hasSelected; isUponSelected = hasSelected;
} }
_menu = new PopupMenu();
_contextMenuLnk = textlnkOver(); _contextMenuLnk = textlnkOver();
HistoryItem *item = App::hoveredItem() ? App::hoveredItem() : App::hoveredLinkItem(); HistoryItem *item = App::hoveredItem() ? App::hoveredItem() : App::hoveredLinkItem();
PhotoLink *lnkPhoto = dynamic_cast<PhotoLink*>(_contextMenuLnk.data()); PhotoLink *lnkPhoto = dynamic_cast<PhotoLink*>(_contextMenuLnk.data());
@ -881,7 +883,6 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
AudioLink *lnkAudio = dynamic_cast<AudioLink*>(_contextMenuLnk.data()); AudioLink *lnkAudio = dynamic_cast<AudioLink*>(_contextMenuLnk.data());
DocumentLink *lnkDocument = dynamic_cast<DocumentLink*>(_contextMenuLnk.data()); DocumentLink *lnkDocument = dynamic_cast<DocumentLink*>(_contextMenuLnk.data());
if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument) { if (lnkPhoto || lnkVideo || lnkAudio || lnkDocument) {
_menu = new PopupMenu();
if (isUponSelected > 0) { if (isUponSelected > 0) {
_menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); _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<HistoryServiceMsg*>(item); HistoryServiceMsg *srv = dynamic_cast<HistoryServiceMsg*>(item);
if (isUponSelected > 0) { if (isUponSelected > 0) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_selected), this, SLOT(copySelectedText()))->setEnabled(true);
if (item && item->id > 0 && isUponSelected != 2 && canSendMessages) { if (item && item->id > 0 && isUponSelected != 2 && canSendMessages) {
_menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage())); _menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage()));
} }
} else { } else {
if (item && item->id > 0 && isUponSelected != -2 && canSendMessages) { if (item && item->id > 0 && isUponSelected != -2 && canSendMessages) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage())); _menu->addAction(lang(lng_context_reply_msg), _widget, SLOT(onReplyToMessage()));
} }
if (item && !isUponSelected && !_contextMenuLnk) { if (item && !isUponSelected && !_contextMenuLnk) {
if (HistorySticker *sticker = dynamic_cast<HistorySticker*>(msg ? msg->getMedia() : 0)) { if (HistorySticker *sticker = dynamic_cast<HistorySticker*>(msg ? msg->getMedia() : 0)) {
DocumentData *doc = sticker->document(); DocumentData *doc = sticker->document();
if (doc && doc->sticker() && doc->sticker()->set.type() != mtpc_inputStickerSetEmpty) { 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())); _menu->addAction(lang(doc->sticker()->setInstalled() ? lng_context_pack_info : lng_context_pack_add), _widget, SLOT(onStickerPackInfo()));
} }
} }
QString contextMenuText = item->selectedText(FullItemSel); QString contextMenuText = item->selectedText(FullItemSel);
if (!contextMenuText.isEmpty() && (!msg || !msg->getMedia() || msg->getMedia()->type() != MediaTypeSticker)) { 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); _menu->addAction(lang(lng_context_copy_text), this, SLOT(copyContextText()))->setEnabled(true);
} }
} }
} }
if (_contextMenuLnk && dynamic_cast<TextLink*>(_contextMenuLnk.data())) { if (_contextMenuLnk && dynamic_cast<TextLink*>(_contextMenuLnk.data())) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_open_link), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_open_link), this, SLOT(openContextUrl()))->setEnabled(true);
_menu->addAction(lang(lng_context_copy_link), this, SLOT(copyContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_link), this, SLOT(copyContextUrl()))->setEnabled(true);
} else if (_contextMenuLnk && dynamic_cast<EmailLink*>(_contextMenuLnk.data())) { } else if (_contextMenuLnk && dynamic_cast<EmailLink*>(_contextMenuLnk.data())) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_open_email), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_open_email), this, SLOT(openContextUrl()))->setEnabled(true);
_menu->addAction(lang(lng_context_copy_email), this, SLOT(copyContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_email), this, SLOT(copyContextUrl()))->setEnabled(true);
} else if (_contextMenuLnk && dynamic_cast<MentionLink*>(_contextMenuLnk.data())) { } else if (_contextMenuLnk && dynamic_cast<MentionLink*>(_contextMenuLnk.data())) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_open_mention), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_open_mention), this, SLOT(openContextUrl()))->setEnabled(true);
_menu->addAction(lang(lng_context_copy_mention), this, SLOT(copyContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_mention), this, SLOT(copyContextUrl()))->setEnabled(true);
} else if (_contextMenuLnk && dynamic_cast<HashtagLink*>(_contextMenuLnk.data())) { } else if (_contextMenuLnk && dynamic_cast<HashtagLink*>(_contextMenuLnk.data())) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_open_hashtag), this, SLOT(openContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_open_hashtag), this, SLOT(openContextUrl()))->setEnabled(true);
_menu->addAction(lang(lng_context_copy_hashtag), this, SLOT(copyContextUrl()))->setEnabled(true); _menu->addAction(lang(lng_context_copy_hashtag), this, SLOT(copyContextUrl()))->setEnabled(true);
} else { } else {
} }
if (isUponSelected > 1) { if (isUponSelected > 1) {
if (!_menu) _menu = new PopupMenu();
_menu->addAction(lang(lng_context_forward_selected), _widget, SLOT(onForwardSelected())); _menu->addAction(lang(lng_context_forward_selected), _widget, SLOT(onForwardSelected()));
if (selectedForDelete == selectedForForward) { if (selectedForDelete == selectedForForward) {
_menu->addAction(lang(lng_context_delete_selected), _widget, SLOT(onDeleteSelected())); _menu->addAction(lang(lng_context_delete_selected), _widget, SLOT(onDeleteSelected()));
} }
_menu->addAction(lang(lng_context_clear_selection), _widget, SLOT(onClearSelected())); _menu->addAction(lang(lng_context_clear_selection), _widget, SLOT(onClearSelected()));
} else if (item && ((isUponSelected != -2 && (canForward || canDelete)) || item->id > 0)) { } else if (item && ((isUponSelected != -2 && (canForward || canDelete)) || item->id > 0)) {
if (!_menu) _menu = new PopupMenu();
if (isUponSelected != -2) { if (isUponSelected != -2) {
if (canForward) { if (canForward) {
_menu->addAction(lang(lng_context_forward_msg), _widget, SLOT(forwardMessage()))->setEnabled(true); _menu->addAction(lang(lng_context_forward_msg), _widget, SLOT(forwardMessage()))->setEnabled(true);
@ -998,7 +989,6 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
} }
} else { } else {
if (App::mousedItem() && !App::mousedItem()->serviceMsg() && App::mousedItem()->id > 0) { 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); _menu->addAction(lang(lng_context_select_msg), _widget, SLOT(selectMessage()))->setEnabled(true);
item = App::mousedItem(); item = App::mousedItem();
} }
@ -1006,7 +996,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
App::contextItem(item); App::contextItem(item);
} }
if (_menu) { if (_menu->actions().isEmpty()) {
delete _menu;
_menu = 0;
} else {
connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroy(QObject*))); connect(_menu, SIGNAL(destroyed(QObject*)), this, SLOT(onMenuDestroy(QObject*)));
_menu->popup(e->globalPos()); _menu->popup(e->globalPos());
e->accept(); e->accept();

View File

@ -2346,7 +2346,9 @@ void MainWidget::showPeerHistory(quint64 peerId, qint32 showAtMsgId, bool back)
//} //}
if (!dialogs.isHidden()) { if (!dialogs.isHidden()) {
dialogs.scrollToPeer(peerId, showAtMsgId); if (!back) {
dialogs.scrollToPeer(peerId, showAtMsgId);
}
dialogs.update(); dialogs.update();
} }
App::wnd()->getTitle()->updateBackButton(); App::wnd()->getTitle()->updateBackButton();
@ -2517,6 +2519,7 @@ void MainWidget::showPeerProfile(PeerData *peer, bool back, int32 lastScrollTop)
if (back) clearBotStartToken(history.peer()); if (back) clearBotStartToken(history.peer());
history.showHistory(0, 0); history.showHistory(0, 0);
history.hide(); history.hide();
if (!cWideMode()) dialogs.hide();
orderWidgets(); orderWidgets();

View File

@ -203,11 +203,12 @@ SettingsInner::SettingsInner(SettingsWidget *parent) : QWidget(parent),
{ {
if (self()) { if (self()) {
connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update())); connect(App::wnd(), SIGNAL(imageLoaded()), this, SLOT(update()));
connect(App::api(), SIGNAL(fullPeerUpdated(PeerData*)), this, SLOT(onFullPeerUpdated(PeerData*)));
_nameText.setText(st::setNameFont, _nameCache, _textNameOptions); _nameText.setText(st::setNameFont, _nameCache, _textNameOptions);
PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0; PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0;
if (selfPhoto && selfPhoto->date) _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self())); 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(); onReloadPassword();
connect(App::main(), SIGNAL(peerPhotoChanged(PeerData *)), this, SLOT(peerUpdated(PeerData *))); 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())); _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self()));
} else { } else {
_photoLink = TextLinkPtr(); _photoLink = TextLinkPtr();
MTP::send(MTPusers_GetFullUser(self()->inputUser), rpcDone(&SettingsInner::gotFullSelf)); App::api()->requestFullPeer(self());
} }
} else { } else {
_photoLink = TextLinkPtr(); _photoLink = TextLinkPtr();
@ -897,10 +898,9 @@ void SettingsInner::updateBackgroundRect() {
update(_left, _tileBackground.y() - st::setLittleSkip - st::setBackgroundSize, st::setBackgroundSize, st::setBackgroundSize); update(_left, _tileBackground.y() - st::setLittleSkip - st::setBackgroundSize, st::setBackgroundSize, st::setBackgroundSize);
} }
void SettingsInner::gotFullSelf(const MTPUserFull &selfFull) { void SettingsInner::onFullPeerUpdated(PeerData *peer) {
if (!self()) return; if (!self() || self() != peer) return;
App::feedPhoto(selfFull.c_userFull().vprofile_photo);
App::feedUsers(MTP_vector<MTPUser>(1, selfFull.c_userFull().vuser));
PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0; PhotoData *selfPhoto = (self()->photoId && self()->photoId != UnknownPeerPhotoId) ? App::photo(self()->photoId) : 0;
if (selfPhoto && selfPhoto->date) { if (selfPhoto && selfPhoto->date) {
_photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self())); _photoLink = TextLinkPtr(new PhotoLink(selfPhoto, self()));

View File

@ -77,8 +77,6 @@ public:
void updateOnlineDisplay(); void updateOnlineDisplay();
void gotFullSelf(const MTPUserFull &self);
void showAll(); void showAll();
void chooseCustomLang(); void chooseCustomLang();
@ -107,6 +105,8 @@ public slots:
#endif #endif
void onRestartNow(); void onRestartNow();
void onFullPeerUpdated(PeerData *peer);
void onPasscode(); void onPasscode();
void onPasscodeOff(); void onPasscodeOff();
void onAutoLock(); void onAutoLock();