alternate message colors now work on replaced messages and when

changing channels
This commit is contained in:
fourtf
2018-05-06 14:57:57 +02:00
parent 34a58021bc
commit 3e3cbf0415
2 changed files with 18 additions and 10 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
this->messages.textColors.system = QColor(140, 127, 127); this->messages.textColors.system = QColor(140, 127, 127);
this->messages.backgrounds.regular = splits.background; this->messages.backgrounds.regular = splits.background;
this->messages.backgrounds.alternate = getColor(0, sat, 0.96); this->messages.backgrounds.alternate = getColor(0, sat, 0.93);
this->messages.backgrounds.highlighted = this->messages.backgrounds.highlighted =
blendColors(themeColor, this->messages.backgrounds.regular, 0.8); blendColors(themeColor, this->messages.backgrounds.regular, 0.8);
// this->messages.backgrounds.resub // this->messages.backgrounds.resub
+17 -9
View File
@@ -277,26 +277,26 @@ QString ChannelView::getSelectedText()
messages::LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot = this->getMessagesSnapshot(); messages::LimitedQueueSnapshot<MessageLayoutPtr> messagesSnapshot = this->getMessagesSnapshot();
Selection selection = this->selection; Selection _selection = this->selection;
if (selection.isEmpty()) { if (_selection.isEmpty()) {
return result; return result;
} }
qDebug() << "xd >>>>"; qDebug() << "xd >";
for (int msg = selection.selectionMin.messageIndex; msg <= selection.selectionMax.messageIndex; for (int msg = _selection.selectionMin.messageIndex;
msg++) { msg <= _selection.selectionMax.messageIndex; msg++) {
MessageLayoutPtr layout = messagesSnapshot[msg]; MessageLayoutPtr layout = messagesSnapshot[msg];
int from = int from =
msg == selection.selectionMin.messageIndex ? selection.selectionMin.charIndex : 0; msg == _selection.selectionMin.messageIndex ? _selection.selectionMin.charIndex : 0;
int to = msg == selection.selectionMax.messageIndex ? selection.selectionMax.charIndex int to = msg == _selection.selectionMax.messageIndex ? _selection.selectionMax.charIndex
: layout->getLastCharacterIndex() + 1; : layout->getLastCharacterIndex() + 1;
qDebug() << "from:" << from << ", to:" << to; qDebug() << "from:" << from << ", to:" << to;
layout->addSelectionText(result, from, to); layout->addSelectionText(result, from, to);
} }
qDebug() << "xd <<<<"; qDebug() << "xd <";
return result; return result;
} }
@@ -430,6 +430,9 @@ void ChannelView::setChannel(ChannelPtr newChannel)
this->messageReplacedConnection = this->messageReplacedConnection =
newChannel->messageReplaced.connect([this](size_t index, MessagePtr replacement) { newChannel->messageReplaced.connect([this](size_t index, MessagePtr replacement) {
MessageLayoutPtr newItem(new MessageLayout(replacement)); MessageLayoutPtr newItem(new MessageLayout(replacement));
if (this->messages.getSnapshot()[index]->flags & MessageLayout::AlternateBackground) {
newItem->flags |= MessageLayout::AlternateBackground;
}
this->scrollBar.replaceHighlight(index, replacement->getScrollBarHighlight()); this->scrollBar.replaceHighlight(index, replacement->getScrollBarHighlight());
@@ -444,6 +447,11 @@ void ChannelView::setChannel(ChannelPtr newChannel)
auto messageRef = new MessageLayout(snapshot[i]); auto messageRef = new MessageLayout(snapshot[i]);
if (this->lastMessageHasAlternateBackground) {
messageRef->flags |= MessageLayout::AlternateBackground;
}
this->lastMessageHasAlternateBackground = !this->lastMessageHasAlternateBackground;
this->messages.pushBack(MessageLayoutPtr(messageRef), deleted); this->messages.pushBack(MessageLayoutPtr(messageRef), deleted);
} }