fixed text selection color

This commit is contained in:
fourtf 2018-01-16 00:34:32 +01:00
parent a190eda075
commit 385f9e44d0
2 changed files with 8 additions and 19 deletions

View file

@ -179,6 +179,9 @@ void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffse
void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
Selection &selection) Selection &selection)
{ {
singletons::ThemeManager &themeManager = singletons::ThemeManager::getInstance();
QColor selectionColor = themeManager.messages.selection;
// don't draw anything // don't draw anything
if (selection.min.messageIndex > messageIndex || selection.max.messageIndex < messageIndex) { if (selection.min.messageIndex > messageIndex || selection.max.messageIndex < messageIndex) {
return; return;
@ -194,7 +197,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
rect.setLeft(this->elements[line.startIndex]->getRect().left()); rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
painter.fillRect(rect, QColor(255, 255, 0, 127)); painter.fillRect(rect, selectionColor);
} }
return; return;
} }
@ -253,7 +256,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
rect.setLeft(this->elements[line.startIndex]->getRect().left()); rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
painter.fillRect(rect, QColor(255, 255, 0, 127)); painter.fillRect(rect, selectionColor);
} }
returnAfter = true; returnAfter = true;
} else { } else {
@ -273,7 +276,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
rect.setLeft(x); rect.setLeft(x);
rect.setRight(r); rect.setRight(r);
painter.fillRect(rect, QColor(255, 255, 0, 127)); painter.fillRect(rect, selectionColor);
if (returnAfter) { if (returnAfter) {
return; return;
@ -289,7 +292,6 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
for (; lineIndex < this->lines.size(); lineIndex++) { for (; lineIndex < this->lines.size(); lineIndex++) {
Line &line = this->lines[lineIndex]; Line &line = this->lines[lineIndex];
index = line.startCharIndex; index = line.startCharIndex;
bool breakAfter = false;
// just draw the garbage // just draw the garbage
if (line.endCharIndex < /*=*/selection.max.charIndex) { if (line.endCharIndex < /*=*/selection.max.charIndex) {
@ -300,7 +302,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
rect.setLeft(this->elements[line.startIndex]->getRect().left()); rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
painter.fillRect(rect, QColor(255, 255, 0, 127)); painter.fillRect(rect, selectionColor);
continue; continue;
} }
@ -324,23 +326,11 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex,
rect.setLeft(this->elements[line.startIndex]->getRect().left()); rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(r); rect.setRight(r);
painter.fillRect(rect, QColor(255, 255, 0, 127)); painter.fillRect(rect, selectionColor);
break; break;
} }
} }
void MessageLayoutContainer::_paintLine(QPainter &painter, Line &line, int x, int y)
{
QRect rect = line.rect;
rect.setTop(std::max(0, rect.top()));
rect.setBottom(std::min(this->height, rect.bottom()));
rect.setLeft(this->elements[line.startIndex]->getRect().left());
rect.setRight(this->elements[line.endIndex - 1]->getRect().right());
painter.fillRect(rect, QColor(255, 255, 0, 127));
}
// selection // selection
int MessageLayoutContainer::getSelectionIndex(QPoint point) int MessageLayoutContainer::getSelectionIndex(QPoint point)
{ {

View file

@ -83,7 +83,6 @@ private:
// helpers // helpers
void _addElement(MessageLayoutElement *element); void _addElement(MessageLayoutElement *element);
void _paintLine(QPainter &painter, Line &line, int x, int y);
// variables // variables
int line; int line;