diff --git a/src/plugins/debugger/console/consoleitemdelegate.cpp b/src/plugins/debugger/console/consoleitemdelegate.cpp index 2196d7a260a..ef3cd9435d1 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.cpp +++ b/src/plugins/debugger/console/consoleitemdelegate.cpp @@ -67,19 +67,14 @@ void ConsoleItemDelegate::emitSizeHintChanged(const QModelIndex &index) } QColor ConsoleItemDelegate::drawBackground(QPainter *painter, const QRect &rect, - const QModelIndex &index, - bool selected) const + const QModelIndex &index, + const QStyleOptionViewItem &opt) const { - const Utils::Theme *theme = Utils::creatorTheme(); - painter->save(); - QColor backgroundColor = theme->color(selected - ? Utils::Theme::BackgroundColorSelected - : Utils::Theme::BackgroundColorNormal); - if (!(index.flags() & Qt::ItemIsEditable)) - painter->setBrush(backgroundColor); - painter->setPen(Qt::NoPen); - painter->drawRect(rect); - painter->restore(); + const bool selected = opt.state & QStyle::State_Selected; + const bool editing = index.flags() & Qt::ItemIsEditable; + const QPalette::ColorRole cr = (selected && !editing) ? QPalette::Highlight : QPalette::Base; + const QColor backgroundColor = opt.palette.color(cr); + painter->fillRect(rect, backgroundColor); return backgroundColor; } @@ -119,8 +114,7 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o } // Paint background - QColor backgroundColor = drawBackground(painter, opt.rect, index, - bool(opt.state & QStyle::State_Selected)); + const QColor backgroundColor = drawBackground(painter, opt.rect, index, opt); // Calculate positions const auto view = qobject_cast(opt.widget); @@ -144,7 +138,8 @@ void ConsoleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o positions.typeIconHeight())); // Set Text Color - painter->setPen(textColor); + painter->setPen(opt.state & QStyle::State_Selected + ? opt.palette.color(QPalette::HighlightedText) : textColor); // Paint TextArea: // Layout the description QString str = index.data(Qt::DisplayRole).toString(); diff --git a/src/plugins/debugger/console/consoleitemdelegate.h b/src/plugins/debugger/console/consoleitemdelegate.h index 3b40666743d..480c588bc27 100644 --- a/src/plugins/debugger/console/consoleitemdelegate.h +++ b/src/plugins/debugger/console/consoleitemdelegate.h @@ -43,7 +43,7 @@ public: void emitSizeHintChanged(const QModelIndex &index); QColor drawBackground(QPainter *painter, const QRect &rect, const QModelIndex &index, - bool selected) const; + const QStyleOptionViewItem &opt) const; void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); protected: diff --git a/src/plugins/debugger/console/consoleview.cpp b/src/plugins/debugger/console/consoleview.cpp index 5d3fa6f6912..ebedc9ff955 100644 --- a/src/plugins/debugger/console/consoleview.cpp +++ b/src/plugins/debugger/console/consoleview.cpp @@ -135,8 +135,7 @@ void ConsoleView::resizeEvent(QResizeEvent *e) void ConsoleView::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const { - static_cast(itemDelegate())->drawBackground(painter, rect, index, - false); + static_cast(itemDelegate())->drawBackground(painter, rect, index, {}); Utils::TreeView::drawBranches(painter, rect, index); }