mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Display "{from}:" in global search results.
Regression was introduced in c09fbcfeb3
.
This commit is contained in:
parent
aec496d520
commit
4771ea7cd4
2 changed files with 126 additions and 21 deletions
|
@ -58,7 +58,21 @@ void paintRowDate(Painter &p, const QDateTime &date, QRect &rectForName, bool ac
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename PaintItemCallback, typename PaintCounterCallback>
|
template <typename PaintItemCallback, typename PaintCounterCallback>
|
||||||
void paintRow(Painter &p, const RippleRow *row, History *history, not_null<PeerData*> from, HistoryItem *item, Data::Draft *draft, QDateTime date, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms, PaintItemCallback paintItemCallback, PaintCounterCallback paintCounterCallback) {
|
void paintRow(
|
||||||
|
Painter &p,
|
||||||
|
const RippleRow *row,
|
||||||
|
History *history,
|
||||||
|
not_null<PeerData*> from,
|
||||||
|
HistoryItem *item,
|
||||||
|
Data::Draft *draft,
|
||||||
|
QDateTime date,
|
||||||
|
int fullWidth,
|
||||||
|
bool active,
|
||||||
|
bool selected,
|
||||||
|
bool onlyBackground,
|
||||||
|
TimeMs ms,
|
||||||
|
PaintItemCallback &&paintItemCallback,
|
||||||
|
PaintCounterCallback &&paintCounterCallback) {
|
||||||
QRect fullRect(0, 0, fullWidth, st::dialogsRowHeight);
|
QRect fullRect(0, 0, fullWidth, st::dialogsRowHeight);
|
||||||
p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg));
|
p.fillRect(fullRect, active ? st::dialogsBgActive : (selected ? st::dialogsBgOver : st::dialogsBg));
|
||||||
row->paintRipple(p, 0, 0, fullWidth, ms, &(active ? st::dialogsRippleBgActive : st::dialogsRippleBg)->c);
|
row->paintRipple(p, 0, 0, fullWidth, ms, &(active ? st::dialogsRippleBgActive : st::dialogsRippleBg)->c);
|
||||||
|
@ -122,7 +136,7 @@ void paintRow(Painter &p, const RippleRow *row, History *history, not_null<PeerD
|
||||||
} else if (!item->isEmpty()) {
|
} else if (!item->isEmpty()) {
|
||||||
paintRowDate(p, date, rectForName, active, selected);
|
paintRowDate(p, date, rectForName, active, selected);
|
||||||
|
|
||||||
paintItemCallback(nameleft, namewidth, item);
|
paintItemCallback(nameleft, namewidth);
|
||||||
} else if (history->isPinnedDialog()) {
|
} else if (history->isPinnedDialog()) {
|
||||||
auto availableWidth = namewidth;
|
auto availableWidth = namewidth;
|
||||||
auto &icon = (active ? st::dialogsPinnedIconActive : (selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon));
|
auto &icon = (active ? st::dialogsPinnedIconActive : (selected ? st::dialogsPinnedIconOver : st::dialogsPinnedIcon));
|
||||||
|
@ -281,7 +295,7 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
|
||||||
}
|
}
|
||||||
return cloudDraft ? cloudDraft->date : QDateTime();
|
return cloudDraft ? cloudDraft->date : QDateTime();
|
||||||
};
|
};
|
||||||
int unreadCount = history->unreadCount();
|
auto unreadCount = history->unreadCount();
|
||||||
if (history->peer->migrateFrom()) {
|
if (history->peer->migrateFrom()) {
|
||||||
if (auto migrated = App::historyLoaded(history->peer->migrateFrom()->id)) {
|
if (auto migrated = App::historyLoaded(history->peer->migrateFrom()->id)) {
|
||||||
unreadCount += migrated->unreadCount();
|
unreadCount += migrated->unreadCount();
|
||||||
|
@ -291,8 +305,10 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
|
||||||
if (item && cloudDraft && unreadCount > 0) {
|
if (item && cloudDraft && unreadCount > 0) {
|
||||||
cloudDraft = nullptr; // Draw item, if draft is older.
|
cloudDraft = nullptr; // Draw item, if draft is older.
|
||||||
}
|
}
|
||||||
auto from = (history->peer->migrateTo() ? history->peer->migrateTo() : history->peer);
|
auto from = history->peer->migrateTo()
|
||||||
paintRow(p, row, history, from, item, cloudDraft, displayDate(), fullWidth, active, selected, onlyBackground, ms, [&p, fullWidth, active, selected, ms, history, unreadCount](int nameleft, int namewidth, HistoryItem *item) {
|
? history->peer->migrateTo()
|
||||||
|
: history->peer;
|
||||||
|
auto paintItemCallback = [&](int nameleft, int namewidth) {
|
||||||
auto availableWidth = namewidth;
|
auto availableWidth = namewidth;
|
||||||
auto texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
|
auto texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
|
||||||
auto hadOneBadge = false;
|
auto hadOneBadge = false;
|
||||||
|
@ -341,18 +357,36 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
|
||||||
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
||||||
availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0);
|
availableWidth -= unreadWidth + st.padding + (hadOneBadge ? st::dialogsUnreadPadding : 0);
|
||||||
}
|
}
|
||||||
auto &color = active ? st::dialogsTextFgServiceActive : (selected ? st::dialogsTextFgServiceOver : st::dialogsTextFgService);
|
auto &color = active
|
||||||
if (!history->paintSendAction(p, nameleft, texttop, availableWidth, fullWidth, color, ms)) {
|
? st::dialogsTextFgServiceActive
|
||||||
|
: (selected
|
||||||
|
? st::dialogsTextFgServiceOver
|
||||||
|
: st::dialogsTextFgService);
|
||||||
|
auto actionWasPainted = history->paintSendAction(
|
||||||
|
p,
|
||||||
|
nameleft,
|
||||||
|
texttop,
|
||||||
|
availableWidth,
|
||||||
|
fullWidth,
|
||||||
|
color,
|
||||||
|
ms);
|
||||||
|
if (!actionWasPainted) {
|
||||||
|
auto itemRect = QRect(
|
||||||
|
nameleft,
|
||||||
|
texttop,
|
||||||
|
availableWidth,
|
||||||
|
st::dialogsTextFont->height);
|
||||||
item->drawInDialog(
|
item->drawInDialog(
|
||||||
p,
|
p,
|
||||||
QRect(nameleft, texttop, availableWidth, st::dialogsTextFont->height),
|
itemRect,
|
||||||
active,
|
active,
|
||||||
selected,
|
selected,
|
||||||
HistoryItem::DrawInDialog::Normal,
|
HistoryItem::DrawInDialog::Normal,
|
||||||
history->textCachedFor,
|
history->textCachedFor,
|
||||||
history->lastItemTextCache);
|
history->lastItemTextCache);
|
||||||
}
|
}
|
||||||
}, [&p, fullWidth, active, selected, ms, history, unreadCount] {
|
};
|
||||||
|
auto paintCounterCallback = [&] {
|
||||||
if (unreadCount) {
|
if (unreadCount) {
|
||||||
auto counter = QString::number(unreadCount);
|
auto counter = QString::number(unreadCount);
|
||||||
if (counter.size() > 4) {
|
if (counter.size() > 4) {
|
||||||
|
@ -368,7 +402,22 @@ void RowPainter::paint(Painter &p, const Row *row, int fullWidth, bool active, b
|
||||||
st.muted = history->mute();
|
st.muted = history->mute();
|
||||||
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
paintUnreadCount(p, counter, unreadRight, unreadTop, st, &unreadWidth);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
paintRow(
|
||||||
|
p,
|
||||||
|
row,
|
||||||
|
history,
|
||||||
|
from,
|
||||||
|
item,
|
||||||
|
cloudDraft,
|
||||||
|
displayDate(),
|
||||||
|
fullWidth,
|
||||||
|
active,
|
||||||
|
selected,
|
||||||
|
onlyBackground,
|
||||||
|
ms,
|
||||||
|
paintItemCallback,
|
||||||
|
paintCounterCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RowPainter::paint(Painter &p, const FakeRow *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms) {
|
void RowPainter::paint(Painter &p, const FakeRow *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms) {
|
||||||
|
@ -382,18 +431,42 @@ void RowPainter::paint(Painter &p, const FakeRow *row, int fullWidth, bool activ
|
||||||
}
|
}
|
||||||
return (history->peer->migrateTo() ? history->peer->migrateTo() : history->peer);
|
return (history->peer->migrateTo() ? history->peer->migrateTo() : history->peer);
|
||||||
}();
|
}();
|
||||||
paintRow(p, row, history, from, item, nullptr, item->date, fullWidth, active, selected, onlyBackground, ms, [&p, row, active, selected](int nameleft, int namewidth, HistoryItem *item) {
|
auto drawInDialogWay = [&] {
|
||||||
int lastWidth = namewidth, texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
|
if (auto searchPeer = row->searchInPeer()) {
|
||||||
|
if (!searchPeer->isChannel() || searchPeer->isMegagroup()) {
|
||||||
|
return HistoryItem::DrawInDialog::WithoutSender;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return HistoryItem::DrawInDialog::Normal;
|
||||||
|
}();
|
||||||
|
auto paintItemCallback = [&](int nameleft, int namewidth) {
|
||||||
|
auto lastWidth = namewidth;
|
||||||
|
auto texttop = st::dialogsPadding.y() + st::msgNameFont->height + st::dialogsSkip;
|
||||||
item->drawInDialog(
|
item->drawInDialog(
|
||||||
p,
|
p,
|
||||||
QRect(nameleft, texttop, lastWidth, st::dialogsTextFont->height),
|
QRect(nameleft, texttop, lastWidth, st::dialogsTextFont->height),
|
||||||
active,
|
active,
|
||||||
selected,
|
selected,
|
||||||
HistoryItem::DrawInDialog::WithoutSender,
|
drawInDialogWay,
|
||||||
row->_cacheFor,
|
row->_cacheFor,
|
||||||
row->_cache);
|
row->_cache);
|
||||||
}, [] {
|
};
|
||||||
});
|
auto paintCounterCallback = [] {};
|
||||||
|
paintRow(
|
||||||
|
p,
|
||||||
|
row,
|
||||||
|
history,
|
||||||
|
from,
|
||||||
|
item,
|
||||||
|
nullptr,
|
||||||
|
item->date,
|
||||||
|
fullWidth,
|
||||||
|
active,
|
||||||
|
selected,
|
||||||
|
onlyBackground,
|
||||||
|
ms,
|
||||||
|
paintItemCallback,
|
||||||
|
paintCounterCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect RowPainter::sendActionAnimationRect(int animationWidth, int animationHeight, int fullWidth, bool textUpdated) {
|
QRect RowPainter::sendActionAnimationRect(int animationWidth, int animationHeight, int fullWidth, bool textUpdated) {
|
||||||
|
|
|
@ -27,17 +27,43 @@ class FakeRow;
|
||||||
|
|
||||||
namespace Layout {
|
namespace Layout {
|
||||||
|
|
||||||
const style::icon *ChatTypeIcon(PeerData *peer, bool active, bool selected);
|
const style::icon *ChatTypeIcon(
|
||||||
|
PeerData *peer,
|
||||||
|
bool active,
|
||||||
|
bool selected);
|
||||||
|
|
||||||
class RowPainter {
|
class RowPainter {
|
||||||
public:
|
public:
|
||||||
static void paint(Painter &p, const Row *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms);
|
static void paint(
|
||||||
static void paint(Painter &p, const FakeRow *row, int fullWidth, bool active, bool selected, bool onlyBackground, TimeMs ms);
|
Painter &p,
|
||||||
static QRect sendActionAnimationRect(int animationWidth, int animationHeight, int fullWidth, bool textUpdated);
|
const Row *row,
|
||||||
|
int fullWidth,
|
||||||
|
bool active,
|
||||||
|
bool selected,
|
||||||
|
bool onlyBackground,
|
||||||
|
TimeMs ms);
|
||||||
|
static void paint(
|
||||||
|
Painter &p,
|
||||||
|
const FakeRow *row,
|
||||||
|
int fullWidth,
|
||||||
|
bool active,
|
||||||
|
bool selected,
|
||||||
|
bool onlyBackground,
|
||||||
|
TimeMs ms);
|
||||||
|
static QRect sendActionAnimationRect(
|
||||||
|
int animationWidth,
|
||||||
|
int animationHeight,
|
||||||
|
int fullWidth,
|
||||||
|
bool textUpdated);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void paintImportantSwitch(Painter &p, Mode current, int fullWidth, bool selected, bool onlyBackground);
|
void paintImportantSwitch(
|
||||||
|
Painter &p,
|
||||||
|
Mode current,
|
||||||
|
int fullWidth,
|
||||||
|
bool selected,
|
||||||
|
bool onlyBackground);
|
||||||
|
|
||||||
enum UnreadBadgeSize {
|
enum UnreadBadgeSize {
|
||||||
UnreadBadgeInDialogs = 0,
|
UnreadBadgeInDialogs = 0,
|
||||||
|
@ -60,7 +86,13 @@ struct UnreadBadgeStyle {
|
||||||
UnreadBadgeSize sizeId;
|
UnreadBadgeSize sizeId;
|
||||||
style::font font;
|
style::font font;
|
||||||
};
|
};
|
||||||
void paintUnreadCount(Painter &p, const QString &text, int x, int y, const UnreadBadgeStyle &st, int *outUnreadWidth = nullptr);
|
void paintUnreadCount(
|
||||||
|
Painter &p,
|
||||||
|
const QString &text,
|
||||||
|
int x,
|
||||||
|
int y,
|
||||||
|
const UnreadBadgeStyle &st,
|
||||||
|
int *outUnreadWidth = nullptr);
|
||||||
|
|
||||||
void clearUnreadBadgesCache();
|
void clearUnreadBadgesCache();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue