diff --git a/Telegram/SourceFiles/dialogswidget.cpp b/Telegram/SourceFiles/dialogswidget.cpp index 0e69cb5f51..89f8211eb5 100644 --- a/Telegram/SourceFiles/dialogswidget.cpp +++ b/Telegram/SourceFiles/dialogswidget.cpp @@ -151,12 +151,25 @@ void DialogsListWidget::peopleResultPaint(UserData *user, QPainter &p, int32 w, p.drawPixmap(QPoint(rectForName.left() + st::dlgChatImgLeft, rectForName.top() + st::dlgChatImgTop), App::sprite(), (act ? st::dlgActiveChatImg : st::dlgChatImg)); rectForName.setLeft(rectForName.left() + st::dlgChatImgSkip); } - - // draw unread + QRect tr(nameleft, st::dlgPaddingVer + st::dlgFont->height + st::dlgSep, namewidth, st::dlgFont->height); - p.setPen((act ? st::dlgActiveColor : st::dlgSystemColor)->p); p.setFont(st::dlgHistFont->f); - p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText('@' + user->username, Qt::ElideRight, tr.width())); + if (!act && user->username.toLower().startsWith(peopleQuery)) { + QString first = '@' + user->username.mid(0, peopleQuery.size()), second = user->username.mid(peopleQuery.size()); + int32 w = st::dlgHistFont->m.width(first); + if (w >= tr.width()) { + p.setPen(st::dlgSystemColor->p); + p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText(first, Qt::ElideRight, tr.width())); + } else { + p.setPen(st::dlgSystemColor->p); + p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, first); + p.setPen(st::dlgTextColor->p); + p.drawText(tr.left() + w, tr.top() + st::dlgHistFont->ascent, second); + } + } else { + p.setPen((act ? st::dlgActiveColor : st::dlgSystemColor)->p); + p.drawText(tr.left(), tr.top() + st::dlgHistFont->ascent, st::dlgHistFont->m.elidedText('@' + user->username, Qt::ElideRight, tr.width())); + } p.setPen((act ? st::dlgActiveColor : st::dlgNameColor)->p); history->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); @@ -587,7 +600,8 @@ void DialogsListWidget::searchReceived(const QVector &messages, bool refresh(); } -void DialogsListWidget::peopleReceived(const QVector &people) { +void DialogsListWidget::peopleReceived(const QString &query, const QVector &people) { + peopleQuery = query.toLower().trimmed(); peopleResults.clear(); peopleResults.reserve(people.size()); for (QVector::const_iterator i = people.cbegin(), e = people.cend(); i != e; ++i) { @@ -1435,10 +1449,12 @@ void DialogsWidget::searchReceived(bool fromStart, const MTPmessages_Messages &r } void DialogsWidget::peopleReceived(const MTPcontacts_Found &result, mtpRequestId req) { + QString q = _peopleQuery; if (list.state() == DialogsListWidget::FilteredState || list.state() == DialogsListWidget::SearchedState) { PeopleQueries::iterator i = _peopleQueries.find(req); if (i != _peopleQueries.cend()) { - _peopleCache[i.value()] = result; + q = i.value(); + _peopleCache[q] = result; _peopleQueries.erase(i); } } @@ -1447,7 +1463,7 @@ void DialogsWidget::peopleReceived(const MTPcontacts_Found &result, mtpRequestId switch (result.type()) { case mtpc_contacts_found: { App::feedUsers(result.c_contacts_found().vusers); - list.peopleReceived(result.c_contacts_found().vresults.c_vector().v); + list.peopleReceived(q, result.c_contacts_found().vresults.c_vector().v); } break; } diff --git a/Telegram/SourceFiles/dialogswidget.h b/Telegram/SourceFiles/dialogswidget.h index 587e8c77fc..bf7575a4a4 100644 --- a/Telegram/SourceFiles/dialogswidget.h +++ b/Telegram/SourceFiles/dialogswidget.h @@ -28,7 +28,7 @@ public: void dialogsReceived(const QVector &dialogs); void searchReceived(const QVector &messages, bool fromStart, int32 fullCount); - void peopleReceived(const QVector &people); + void peopleReceived(const QString &query, const QVector &people); void showMore(int32 pixels); void activate(); @@ -127,6 +127,7 @@ private: SearchResults searchResults; int32 searchedCount, searchedSel; + QString peopleQuery; PeopleResults peopleResults; int32 peopleSel; diff --git a/Telegram/SourceFiles/historywidget.cpp b/Telegram/SourceFiles/historywidget.cpp index 4190e3327b..801f87050e 100644 --- a/Telegram/SourceFiles/historywidget.cpp +++ b/Telegram/SourceFiles/historywidget.cpp @@ -2173,8 +2173,8 @@ QString HistoryWidget::prepareMessage(QString result) { result = result.replace(" --", QString::fromUtf8(" \xe2\x80\x94")); result = result.replace("-- ", QString::fromUtf8("\xe2\x80\x94 ")); - result = result.replace("<<", qsl("\xab")); - result = result.replace(">>", qsl("\xbb")); + result = result.replace("<<", QString::fromUtf8("\xc2\xab")); + result = result.replace(">>", QString::fromUtf8("\xc2\xbb")); return (cReplaceEmojis() ? replaceEmojis(result) : result).trimmed(); }