mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 22:54:01 +02:00
Inside message use original senders colors.
This commit is contained in:
parent
0b5f05c7d4
commit
ca9caa36da
13 changed files with 36 additions and 10 deletions
|
@ -1235,6 +1235,22 @@ uint8 HistoryItem::colorIndex() const {
|
||||||
Unexpected("No displayFrom and no displayHiddenSenderInfo.");
|
Unexpected("No displayFrom and no displayHiddenSenderInfo.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PeerData *HistoryItem::contentColorsFrom() const {
|
||||||
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
|
return forwarded->originalSender;
|
||||||
|
}
|
||||||
|
return displayFrom();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8 HistoryItem::contentColorIndex() const {
|
||||||
|
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
|
||||||
|
return forwarded->originalSender
|
||||||
|
? forwarded->originalSender->colorIndex()
|
||||||
|
: forwarded->originalHiddenSenderInfo->colorIndex;
|
||||||
|
}
|
||||||
|
return colorIndex();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<HistoryView::Element> HistoryItem::createView(
|
std::unique_ptr<HistoryView::Element> HistoryItem::createView(
|
||||||
not_null<HistoryView::ElementDelegate*> delegate,
|
not_null<HistoryView::ElementDelegate*> delegate,
|
||||||
HistoryView::Element *replacing) {
|
HistoryView::Element *replacing) {
|
||||||
|
|
|
@ -516,6 +516,11 @@ public:
|
||||||
[[nodiscard]] PeerData *displayFrom() const;
|
[[nodiscard]] PeerData *displayFrom() const;
|
||||||
[[nodiscard]] uint8 colorIndex() const;
|
[[nodiscard]] uint8 colorIndex() const;
|
||||||
|
|
||||||
|
// In forwards we show name in sender's color, but the message
|
||||||
|
// content uses the color of the original sender.
|
||||||
|
[[nodiscard]] PeerData *contentColorsFrom() const;
|
||||||
|
[[nodiscard]] uint8 contentColorIndex() const;
|
||||||
|
|
||||||
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
[[nodiscard]] std::unique_ptr<HistoryView::Element> createView(
|
||||||
not_null<HistoryView::ElementDelegate*> delegate,
|
not_null<HistoryView::ElementDelegate*> delegate,
|
||||||
HistoryView::Element *replacing = nullptr);
|
HistoryView::Element *replacing = nullptr);
|
||||||
|
|
|
@ -490,6 +490,10 @@ uint8 Element::colorIndex() const {
|
||||||
return data()->colorIndex();
|
return data()->colorIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8 Element::contentColorIndex() const {
|
||||||
|
return data()->contentColorIndex();
|
||||||
|
}
|
||||||
|
|
||||||
QDateTime Element::dateTime() const {
|
QDateTime Element::dateTime() const {
|
||||||
return _dateTime;
|
return _dateTime;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,6 +317,7 @@ public:
|
||||||
void refreshDataId();
|
void refreshDataId();
|
||||||
|
|
||||||
[[nodiscard]] uint8 colorIndex() const;
|
[[nodiscard]] uint8 colorIndex() const;
|
||||||
|
[[nodiscard]] uint8 contentColorIndex() const;
|
||||||
[[nodiscard]] QDateTime dateTime() const;
|
[[nodiscard]] QDateTime dateTime() const;
|
||||||
|
|
||||||
[[nodiscard]] int y() const;
|
[[nodiscard]] int y() const;
|
||||||
|
|
|
@ -1670,7 +1670,7 @@ void Message::paintText(
|
||||||
.availableWidth = trect.width(),
|
.availableWidth = trect.width(),
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(colorIndex()),
|
.blockquote = context.quoteCache(contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -201,7 +201,7 @@ void Reply::update(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_colorPeer = message
|
_colorPeer = message
|
||||||
? message->displayFrom()
|
? message->contentColorsFrom()
|
||||||
: story
|
: story
|
||||||
? story->peer().get()
|
? story->peer().get()
|
||||||
: _externalSender
|
: _externalSender
|
||||||
|
|
|
@ -888,7 +888,7 @@ void Document::draw(
|
||||||
.availableWidth = captionw,
|
.availableWidth = captionw,
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(parent()->colorIndex()),
|
.blockquote = context.quoteCache(parent()->contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -237,7 +237,7 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = captionw,
|
.availableWidth = captionw,
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(parent()->colorIndex()),
|
.blockquote = context.quoteCache(parent()->contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -219,7 +219,7 @@ void Game::draw(Painter &p, const PaintContext &context) const {
|
||||||
auto tshift = inner.top();
|
auto tshift = inner.top();
|
||||||
auto paintw = inner.width();
|
auto paintw = inner.width();
|
||||||
|
|
||||||
const auto colorIndex = parent()->colorIndex();
|
const auto colorIndex = parent()->contentColorIndex();
|
||||||
const auto selected = context.selected();
|
const auto selected = context.selected();
|
||||||
const auto cache = context.outbg
|
const auto cache = context.outbg
|
||||||
? stm->replyCache[st->colorPatternIndex(colorIndex)].get()
|
? stm->replyCache[st->colorPatternIndex(colorIndex)].get()
|
||||||
|
|
|
@ -724,7 +724,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = captionw,
|
.availableWidth = captionw,
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(parent()->colorIndex()),
|
.blockquote = context.quoteCache(parent()->contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -405,7 +405,7 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = captionw,
|
.availableWidth = captionw,
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(parent()->colorIndex()),
|
.blockquote = context.quoteCache(parent()->contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -433,7 +433,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const {
|
||||||
.availableWidth = captionw,
|
.availableWidth = captionw,
|
||||||
.palette = &stm->textPalette,
|
.palette = &stm->textPalette,
|
||||||
.pre = stm->preCache.get(),
|
.pre = stm->preCache.get(),
|
||||||
.blockquote = context.quoteCache(parent()->colorIndex()),
|
.blockquote = context.quoteCache(parent()->contentColorIndex()),
|
||||||
.colors = context.st->highlightColors(),
|
.colors = context.st->highlightColors(),
|
||||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||||
.now = context.now,
|
.now = context.now,
|
||||||
|
|
|
@ -584,11 +584,11 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
|
||||||
|
|
||||||
const auto selected = context.selected();
|
const auto selected = context.selected();
|
||||||
const auto view = parent();
|
const auto view = parent();
|
||||||
const auto colorIndex = view->colorIndex();
|
const auto from = view->data()->contentColorsFrom();
|
||||||
|
const auto colorIndex = from ? from->colorIndex() : view->colorIndex();
|
||||||
const auto cache = context.outbg
|
const auto cache = context.outbg
|
||||||
? stm->replyCache[st->colorPatternIndex(colorIndex)].get()
|
? stm->replyCache[st->colorPatternIndex(colorIndex)].get()
|
||||||
: st->coloredReplyCache(selected, colorIndex).get();
|
: st->coloredReplyCache(selected, colorIndex).get();
|
||||||
const auto from = view->data()->displayFrom();
|
|
||||||
const auto backgroundEmojiId = from
|
const auto backgroundEmojiId = from
|
||||||
? from->backgroundEmojiId()
|
? from->backgroundEmojiId()
|
||||||
: DocumentId();
|
: DocumentId();
|
||||||
|
|
Loading…
Add table
Reference in a new issue