show color from feed list even on selected items if color is provided
This commit is contained in:
parent
9e89d6314b
commit
59bcdd5d35
1 changed files with 10 additions and 4 deletions
|
|
@ -10,13 +10,19 @@ StyledItemDelegateWithoutFocus::StyledItemDelegateWithoutFocus(const QString& ro
|
||||||
void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
void StyledItemDelegateWithoutFocus::paint(QPainter* painter,
|
||||||
const QStyleOptionViewItem& option,
|
const QStyleOptionViewItem& option,
|
||||||
const QModelIndex& index) const {
|
const QModelIndex& index) const {
|
||||||
QStyleOptionViewItem itemOption(option);
|
QStyleOptionViewItem item_option(option);
|
||||||
|
|
||||||
if ((itemOption.state & QStyle::StateFlag::State_HasFocus) == QStyle::StateFlag::State_HasFocus) {
|
if ((item_option.state & QStyle::StateFlag::State_HasFocus) == QStyle::StateFlag::State_HasFocus) {
|
||||||
itemOption.state = itemOption.state ^ QStyle::StateFlag::State_HasFocus;
|
item_option.state = item_option.state ^ QStyle::StateFlag::State_HasFocus;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyledItemDelegate::paint(painter, itemOption, index);
|
if ((item_option.state & QStyle::StateFlag::State_Selected) == QStyle::StateFlag::State_Selected &&
|
||||||
|
index.data(Qt::ItemDataRole::ForegroundRole).isValid()) {
|
||||||
|
item_option.palette.setColor(QPalette::ColorRole::HighlightedText,
|
||||||
|
index.data(Qt::ItemDataRole::ForegroundRole).value<QColor>());
|
||||||
|
}
|
||||||
|
|
||||||
|
QStyledItemDelegate::paint(painter, item_option, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize StyledItemDelegateWithoutFocus::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
QSize StyledItemDelegateWithoutFocus::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue