alternate color for historic messages

This commit is contained in:
fourtf 2018-11-03 21:40:48 +01:00
parent 5453c65f0f
commit 6416bf3927
2 changed files with 19 additions and 13 deletions

View file

@ -620,26 +620,31 @@ void ChannelView::messageAddedAtStart(std::vector<MessagePtr> &messages)
{
std::vector<MessageLayoutPtr> messageRefs;
messageRefs.resize(messages.size());
/// Create message layouts
for (size_t i = 0; i < messages.size(); i++)
{
messageRefs.at(i) = MessageLayoutPtr(new MessageLayout(messages.at(i)));
auto layout = new MessageLayout(messages.at(i));
// alternate color
if (!this->lastMessageHasAlternateBackgroundReverse_)
layout->flags.set(MessageLayoutFlag::AlternateBackground);
this->lastMessageHasAlternateBackgroundReverse_ =
!this->lastMessageHasAlternateBackgroundReverse_;
messageRefs.at(i) = MessageLayoutPtr(layout);
}
// if (!this->isPaused())
{
/// Add the messages at the start
if (this->messages.pushFront(messageRefs).size() > 0)
{
if (this->scrollBar_->isAtBottom())
{
this->scrollBar_->scrollToBottom();
}
else
{
this->scrollBar_->offset(qreal(messages.size()));
}
}
}
/// Add highlights
std::vector<ScrollbarHighlight> highlights;
highlights.reserve(messages.size());
for (size_t i = 0; i < messages.size(); i++)

View file

@ -149,6 +149,7 @@ private:
bool updateQueued_ = false;
bool messageWasAdded_ = false;
bool lastMessageHasAlternateBackground_ = false;
bool lastMessageHasAlternateBackgroundReverse_ = true;
QTimer pauseTimer_;
std::unordered_map<PauseReason, boost::optional<SteadyClock::time_point>>