From 3e3cbf0415a775de923bf59eba2f0ffe9372d024 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 6 May 2018 14:57:57 +0200 Subject: [PATCH] alternate message colors now work on replaced messages and when changing channels --- src/singletons/thememanager.cpp | 2 +- src/widgets/helper/channelview.cpp | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index 936ba8d1..348afd83 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -140,7 +140,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier) this->messages.textColors.system = QColor(140, 127, 127); 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 = blendColors(themeColor, this->messages.backgrounds.regular, 0.8); // this->messages.backgrounds.resub diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index be188c91..8a599a13 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -277,26 +277,26 @@ QString ChannelView::getSelectedText() messages::LimitedQueueSnapshot messagesSnapshot = this->getMessagesSnapshot(); - Selection selection = this->selection; + Selection _selection = this->selection; - if (selection.isEmpty()) { + if (_selection.isEmpty()) { return result; } - qDebug() << "xd >>>>"; - for (int msg = selection.selectionMin.messageIndex; msg <= selection.selectionMax.messageIndex; - msg++) { + qDebug() << "xd >"; + for (int msg = _selection.selectionMin.messageIndex; + msg <= _selection.selectionMax.messageIndex; msg++) { MessageLayoutPtr layout = messagesSnapshot[msg]; int from = - msg == selection.selectionMin.messageIndex ? selection.selectionMin.charIndex : 0; - int to = msg == selection.selectionMax.messageIndex ? selection.selectionMax.charIndex - : layout->getLastCharacterIndex() + 1; + msg == _selection.selectionMin.messageIndex ? _selection.selectionMin.charIndex : 0; + int to = msg == _selection.selectionMax.messageIndex ? _selection.selectionMax.charIndex + : layout->getLastCharacterIndex() + 1; qDebug() << "from:" << from << ", to:" << to; layout->addSelectionText(result, from, to); } - qDebug() << "xd <<<<"; + qDebug() << "xd <"; return result; } @@ -430,6 +430,9 @@ void ChannelView::setChannel(ChannelPtr newChannel) this->messageReplacedConnection = newChannel->messageReplaced.connect([this](size_t index, MessagePtr replacement) { MessageLayoutPtr newItem(new MessageLayout(replacement)); + if (this->messages.getSnapshot()[index]->flags & MessageLayout::AlternateBackground) { + newItem->flags |= MessageLayout::AlternateBackground; + } this->scrollBar.replaceHighlight(index, replacement->getScrollBarHighlight()); @@ -444,6 +447,11 @@ void ChannelView::setChannel(ChannelPtr newChannel) auto messageRef = new MessageLayout(snapshot[i]); + if (this->lastMessageHasAlternateBackground) { + messageRef->flags |= MessageLayout::AlternateBackground; + } + this->lastMessageHasAlternateBackground = !this->lastMessageHasAlternateBackground; + this->messages.pushBack(MessageLayoutPtr(messageRef), deleted); }