| 98 | } |
| 99 | |
| 100 | void ToolItemDelegate::drawBackground(QPainter *painter, const QStyleOptionViewItem &option) const |
| 101 | { |
| 102 | painter->save(); |
| 103 | if (option.state.testFlag(QStyle::State_Selected)) { |
| 104 | QColor bgColor = option.palette.color(QPalette::Normal, QPalette::Highlight); |
| 105 | painter->setBrush(bgColor); |
| 106 | painter->setPen(Qt::NoPen); |
| 107 | painter->drawRoundedRect(option.rect, 6, 6); |
| 108 | } else if (option.state.testFlag(QStyle::State_MouseOver)) { |
| 109 | #ifdef DTKWIDGET_CLASS_DPaletteHelper |
| 110 | DPalette palette = DPaletteHelper::instance()->palette(option.widget); |
| 111 | #else |
| 112 | DPalette palette = DGuiApplicationHelper::instance()->applicationPalette(); |
| 113 | #endif |
| 114 | painter->setBrush(palette.brush(DPalette::ItemBackground)); |
| 115 | painter->setPen(Qt::NoPen); |
| 116 | painter->drawRoundedRect(option.rect, 6, 6); |
| 117 | } |
| 118 | painter->restore(); |
| 119 | } |
| 120 | |
| 121 | void ToolItemDelegate::drawToolItem(QPainter *painter, |
| 122 | const QStyleOptionViewItem &option, |