From 51fbec0c5071a8199bdb1db4f9e1e637c129bbc6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 24 Sep 2015 19:05:06 +0300 Subject: [PATCH] 0.9.1 stable version with fixes --- Telegram/SourceFiles/config.h | 4 +- Telegram/SourceFiles/dialogswidget.cpp | 41 ++++++------- Telegram/SourceFiles/dialogswidget.h | 4 +- Telegram/SourceFiles/history.cpp | 61 ++++++++++---------- Telegram/SourceFiles/historywidget.cpp | 2 +- Telegram/SourceFiles/overviewwidget.cpp | 6 +- Telegram/SourceFiles/profilewidget.cpp | 10 ++-- Telegram/SourceFiles/pspecific_wnd.cpp | 11 ++-- Telegram/Telegram.plist | 2 +- Telegram/Telegram.rc | Bin 5532 -> 5532 bytes Telegram/Telegram.xcodeproj/project.pbxproj | 12 ++-- Telegram/Version | 6 +- 12 files changed, 76 insertions(+), 83 deletions(-) diff --git a/Telegram/SourceFiles/config.h b/Telegram/SourceFiles/config.h index bce3f56f7..8097de65d 100644 --- a/Telegram/SourceFiles/config.h +++ b/Telegram/SourceFiles/config.h @@ -17,8 +17,8 @@ Copyright (c) 2014 John Preston, https://desktop.telegram.org */ #pragma once -static const int32 AppVersion = 9000; -static const wchar_t *AppVersionStr = L"0.9"; +static const int32 AppVersion = 9001; +static const wchar_t *AppVersionStr = L"0.9.1"; static const bool DevVersion = false; static const wchar_t *AppNameOld = L"Telegram Win (Unofficial)"; diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 02a6eba22..b9510f08c 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -424,25 +424,22 @@ void DialogsListWidget::onDialogRowReplaced(DialogRow *oldRow, DialogRow *newRow } void DialogsListWidget::createDialog(History *history) { - if (history->dialogs.isEmpty()) { - History::DialogLinks links = dialogs.addToEnd(history); - int32 movedFrom = links[0]->pos * st::dlgHeight; - dialogs.adjustByPos(links); - history->dialogs = links; + bool creating = history->dialogs.isEmpty(); + if (creating) { + history->dialogs = dialogs.addToEnd(history); + contactsNoDialogs.del(history->peer, history->dialogs[0]); + } - contactsNoDialogs.del(history->peer, links[0]); + History::DialogLinks links = history->dialogs; + int32 movedFrom = links[0]->pos * st::dlgHeight; + dialogs.adjustByPos(links); + int32 movedTo = links[0]->pos * st::dlgHeight; - emit dialogToTopFrom(movedFrom); - emit App::main()->dialogsUpdated(); + emit dialogMoved(movedFrom, movedTo); + if (creating) { refresh(); } else { - int32 movedFrom = history->dialogs[0]->pos * st::dlgHeight; - dialogs.adjustByPos(history->dialogs); - - emit dialogToTopFrom(movedFrom); - emit App::main()->dialogsUpdated(); - parentWidget()->update(); } } @@ -476,8 +473,6 @@ void DialogsListWidget::removeContact(UserData *user) { contactsNoDialogs.del(user); contacts.del(user); - emit App::main()->dialogsUpdated(); - refresh(); } @@ -823,7 +818,6 @@ void DialogsListWidget::addSavedPeersAfter(const QDateTime &date) { while (!saved.isEmpty() && (date.isNull() || date < saved.lastKey())) { History *history = App::history(saved.last()->id); history->setPosInDialogsDate(saved.lastKey()); - history->dialogs = dialogs.addToEnd(history); contactsNoDialogs.del(history->peer); saved.remove(saved.lastKey(), saved.last()); } @@ -1499,8 +1493,8 @@ DialogsWidget::DialogsWidget(MainWidget *parent) : QWidget(parent) { scroll.setWidget(&list); scroll.setFocusPolicy(Qt::NoFocus); - connect(&list, SIGNAL(mustScrollTo(int, int)), &scroll, SLOT(scrollToY(int, int))); - connect(&list, SIGNAL(dialogToTopFrom(int)), this, SLOT(onDialogToTopFrom(int))); + connect(&list, SIGNAL(mustScrollTo(int,int)), &scroll, SLOT(scrollToY(int,int))); + connect(&list, SIGNAL(dialogMoved(int,int)), this, SLOT(onDialogMoved(int,int))); connect(&list, SIGNAL(searchMessages()), this, SLOT(onNeedSearchMessages())); connect(&list, SIGNAL(searchResultChosen()), this, SLOT(onCancel())); connect(&list, SIGNAL(completeHashtag(QString)), this, SLOT(onCompleteHashtag(QString))); @@ -2278,11 +2272,10 @@ void DialogsWidget::onCancelSearchInPeer() { } } -void DialogsWidget::onDialogToTopFrom(int movedFrom) { - if (scroll.scrollTop() > 0) { - if (movedFrom > scroll.scrollTop()) { - scroll.scrollToY(scroll.scrollTop() + st::dlgHeight); - } +void DialogsWidget::onDialogMoved(int movedFrom, int movedTo) { + int32 st = scroll.scrollTop(); + if (st > movedTo && st < movedFrom) { + scroll.scrollToY(st + st::dlgHeight); } } diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index a1bc5227b..7ceb5b00e 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -119,7 +119,7 @@ public slots: signals: void mustScrollTo(int scrollToTop, int scrollToBottom); - void dialogToTopFrom(int movedFrom); + void dialogMoved(int movedFrom, int movedTo); void searchMessages(); void searchResultChosen(); void cancelSearchInPeer(); @@ -241,7 +241,7 @@ public slots: void onFilterCursorMoved(int from = -1, int to = -1); void onCompleteHashtag(QString tag); - void onDialogToTopFrom(int movedFrom); + void onDialogMoved(int movedFrom, int movedTo); bool onSearchMessages(bool searchCache = false); void onNeedSearchMessages(); diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 1f1541afe..e85f4ba36 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -1956,54 +1956,51 @@ void History::addOlderSlice(const QVector &slice, const QVector &slice, const QVector *collapsed) { + bool wasEmpty = isEmpty(), wasLoadedAtBottom = loadedAtBottom(); + if (slice.isEmpty()) { newLoaded = true; if (!lastMsg) setLastMessage(lastImportantMessage()); - if (!collapsed || collapsed->isEmpty() || !isChannel()) { - if (isChannel()) asChannelHistory()->checkJoinedMessage(); - return; - } } - const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0; + if (!slice.isEmpty() || (isChannel() && collapsed && !collapsed->isEmpty())) { + const MTPMessageGroup *groupsBegin = (isChannel() && collapsed) ? collapsed->constData() : 0, *groupsIt = groupsBegin, *groupsEnd = (isChannel() && collapsed) ? (groupsBegin + collapsed->size()) : 0; - bool wasEmpty = isEmpty(); + HistoryItem *prev = blocks.isEmpty() ? 0 : blocks.back()->items.back(); - HistoryItem *prev = blocks.isEmpty() ? 0 : blocks.back()->items.back(); + HistoryBlock *block = new HistoryBlock(this); + block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0)); + for (QVector::const_iterator i = slice.cend(), e = slice.cbegin(); i != e;) { + --i; + HistoryItem *adding = createItem(block, *i, false); + if (!adding) continue; - HistoryBlock *block = new HistoryBlock(this); - block->items.reserve(slice.size() + (collapsed ? collapsed->size() : 0)); - for (QVector::const_iterator i = slice.cend(), e = slice.cbegin(); i != e;) { - --i; - HistoryItem *adding = createItem(block, *i, false); - if (!adding) continue; + for (; groupsIt != groupsEnd; ++groupsIt) { + if (groupsIt->type() != mtpc_messageGroup) continue; + const MTPDmessageGroup &group(groupsIt->c_messageGroup()); + if (group.vmin_id.v >= adding->id) break; + prev = addMessageGroupAfterPrevToBlock(group, prev, block); + } + + prev = addItemAfterPrevToBlock(adding, prev, block); + } for (; groupsIt != groupsEnd; ++groupsIt) { if (groupsIt->type() != mtpc_messageGroup) continue; const MTPDmessageGroup &group(groupsIt->c_messageGroup()); - if (group.vmin_id.v >= adding->id) break; prev = addMessageGroupAfterPrevToBlock(group, prev, block); } - prev = addItemAfterPrevToBlock(adding, prev, block); - } - for (; groupsIt != groupsEnd; ++groupsIt) { - if (groupsIt->type() != mtpc_messageGroup) continue; - const MTPDmessageGroup &group(groupsIt->c_messageGroup()); - - prev = addMessageGroupAfterPrevToBlock(group, prev, block); - } - - bool wasLoadedAtBottom = loadedAtBottom(); - if (block->items.size()) { - block->y = height; - blocks.push_back(block); - height += block->height; - } else { - newLoaded = true; - setLastMessage(lastImportantMessage()); - delete block; + if (block->items.size()) { + block->y = height; + blocks.push_back(block); + height += block->height; + } else { + newLoaded = true; + setLastMessage(lastImportantMessage()); + delete block; + } } if (!wasLoadedAtBottom && loadedAtBottom()) { // add all loaded photos to overview int32 mask = 0; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 888c53540..8b0bec7b1 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2926,9 +2926,9 @@ void HistoryWidget::showPeerHistory(const PeerId &peerId, MsgId showAtMsgId) { _replyForwardPreviewCancel.hide(); } _previewCache.clear(); - _scroll.takeWidget(); if (_list) _list->deleteLater(); _list = 0; + _scroll.takeWidget(); updateTopBarSelection(); _showAtMsgId = showAtMsgId; diff --git a/Telegram/SourceFiles/overviewwidget.cpp b/Telegram/SourceFiles/overviewwidget.cpp index f1043d340..04d33b7b8 100644 --- a/Telegram/SourceFiles/overviewwidget.cpp +++ b/Telegram/SourceFiles/overviewwidget.cpp @@ -423,7 +423,7 @@ bool OverviewInner::itemHasPoint(MsgId msgId, int32 index, int32 x, int32 y) con if (media) { int32 w = _width - st::msgMargin.left() - st::msgMargin.right(); bool out = item->out(), fromChannel = item->fromChannel(), outbg = out && !fromChannel; - int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.right()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? (w - mw) / 2 : (out ? w - mw : 0)) : 0); + int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.left()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? 0 : (out ? w - mw : 0)) : 0); if (item->displayFromPhoto()) { left += st::msgPhotoSkip; } @@ -1228,7 +1228,7 @@ void OverviewInner::paintEvent(QPaintEvent *e) { HistoryMedia *media = item ? item->getMedia(true) : 0; if (media) { bool out = item->out(), fromChannel = item->fromChannel(), outbg = out && !fromChannel; - int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.right()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? (w - mw) / 2 : (out ? w - mw : 0)) : 0); + int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.left()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? 0 : (out ? w - mw : 0)) : 0); if (item->displayFromPhoto()) { p.drawPixmap(left, media->countHeight(item, w) - st::msgPhotoSize, item->from()->photo->pixRounded(st::msgPhotoSize)); left += st::msgPhotoSkip; @@ -1435,7 +1435,7 @@ void OverviewInner::onUpdateSelected() { HistoryMedia *media = item->getMedia(true); if (media) { bool out = item->out(), fromChannel = item->fromChannel(), outbg = out && !fromChannel; - int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.right()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? (w - mw) / 2 : (out ? w - mw : 0)) : 0); + int32 mw = media->maxWidth(), left = (fromChannel ? (st::msgMargin.left() + st::msgMargin.left()) / 2 : (out ? st::msgMargin.right() : st::msgMargin.left())) + ((mw < w) ? (fromChannel ? 0 : (out ? w - mw : 0)) : 0); if (item->displayFromPhoto()) { if (QRect(left, y + st::msgMargin.top() + media->countHeight(item, w) - st::msgPhotoSize, st::msgPhotoSize, st::msgPhotoSize).contains(m)) { lnk = item->from()->lnk; diff --git a/Telegram/SourceFiles/profilewidget.cpp b/Telegram/SourceFiles/profilewidget.cpp index ca83c528f..320f54157 100644 --- a/Telegram/SourceFiles/profilewidget.cpp +++ b/Telegram/SourceFiles/profilewidget.cpp @@ -479,7 +479,7 @@ void ProfileInner::onFullPeerUpdated(PeerData *peer) { updateInvitationLink(); _members.setText(lng_channel_members_link(lt_count, (_peerChannel->count > 0) ? _peerChannel->count : 1)); _admins.setText(lng_channel_admins_link(lt_count, (_peerChannel->adminsCount > 0) ? _peerChannel->adminsCount : 1)); - _onlineText = lng_chat_status_members(lt_count, _peerChannel->count > 0 ? _peerChannel->count : 1); + _onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status); if (_peerChannel->about.isEmpty()) { _about = Text(st::wndMinWidth - st::profilePadding.left() - st::profilePadding.right()); } else { @@ -537,7 +537,7 @@ void ProfileInner::peerUpdated(PeerData *data) { } _members.setText(lng_channel_members_link(lt_count, (_peerChannel->count > 0) ? _peerChannel->count : 1)); _admins.setText(lng_channel_admins_link(lt_count, (_peerChannel->adminsCount > 0) ? _peerChannel->adminsCount : 1)); - _onlineText = lng_chat_status_members(lt_count, _peerChannel->count > 0 ? _peerChannel->count : 1); + _onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status); } _photoLink = (photo && photo->date) ? TextLinkPtr(new PhotoLink(photo, _peer)) : TextLinkPtr(); if (_peer->name != _nameCache) { @@ -620,7 +620,7 @@ void ProfileInner::reorderParticipants() { if (_peerUser) { _onlineText = App::onlineText(_peerUser, t, true); } else if (_peerChannel) { - _onlineText = lng_chat_status_members(lt_count, _peerChannel->count > 0 ? _peerChannel->count : 1); + _onlineText = (_peerChannel->count > 0) ? lng_chat_status_members(lt_count, _peerChannel->count) : lang(lng_channel_status); } else { _onlineText = lang(lng_chat_status_unaccessible); } @@ -1104,8 +1104,8 @@ void ProfileInner::resizeEvent(QResizeEvent *e) { addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent); } _members.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + addbyname + st::profileStatusTop); - addbyname = st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent); - _admins.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + 2 * addbyname + st::profileStatusTop); + addbyname += st::profileStatusTop + st::linkFont->ascent - (st::profileNameTop + st::profileNameFont->ascent); + _admins.move(_left + st::profilePhotoSize + st::profileStatusLeft, top + addbyname + st::profileStatusTop); if (_amCreator) { _cancelPhoto.move(_left + _width - _cancelPhoto.width(), top + st::profilePhotoSize - st::linkFont->height); } else { diff --git a/Telegram/SourceFiles/pspecific_wnd.cpp b/Telegram/SourceFiles/pspecific_wnd.cpp index dd53fdacb..e55996eec 100644 --- a/Telegram/SourceFiles/pspecific_wnd.cpp +++ b/Telegram/SourceFiles/pspecific_wnd.cpp @@ -2806,15 +2806,18 @@ bool CreateToast(PeerData *peer, int32 msgId, bool showpix, const QString &title if (!SUCCEEDED(hr)) return false; ToastNotifications::iterator i = toastNotifications.find(peer->id); - if (i == toastNotifications.cend()) { - i = toastNotifications.insert(peer->id, QMap()); - } else { + if (i != toastNotifications.cend()) { QMap::iterator j = i->find(msgId); if (j != i->cend()) { - toastNotifier->Hide(j->p.Get()); + ComPtr notify = j->p; i->erase(j); + toastNotifier->Hide(notify.Get()); + i = toastNotifications.find(peer->id); } } + if (i == toastNotifications.cend()) { + i = toastNotifications.insert(peer->id, QMap()); + } hr = toastNotifier->Show(toast.Get()); if (!SUCCEEDED(hr)) { if (i->isEmpty()) toastNotifications.erase(i); diff --git a/Telegram/Telegram.plist b/Telegram/Telegram.plist index e46ace21f..a0122ea01 100644 --- a/Telegram/Telegram.plist +++ b/Telegram/Telegram.plist @@ -11,7 +11,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.9 + 0.9.1 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) CFBundleSignature diff --git a/Telegram/Telegram.rc b/Telegram/Telegram.rc index 8d41f7716893682ad32236ba3fdfa17f1b9ef36b..026f398c4fc811bb09acf4549de4387b742d98b3 100644 GIT binary patch delta 50 zcmbQEJx6;(0WYKB