MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / paintItemBackground

Method paintItemBackground

src/plugins/builder/tasks/taskdelegate.cpp:136–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134}
135
136void TaskDelegate::paintItemBackground(QPainter *painter, const QStyleOptionViewItem &option,
137 const QModelIndex &index) const
138{
139 painter->save();
140
141 if (option.widget) {
142#ifdef DTKWIDGET_CLASS_DPaletteHelper
143 DPalette pl(DPaletteHelper::instance()->palette(option.widget));
144#else
145 DPalette pl = DGuiApplicationHelper::instance()->applicationPalette();
146#endif
147 QColor baseColor = pl.color(DPalette::ColorGroup::Active, DPalette::ColorType::ItemBackground);
148 QColor adjustColor = baseColor;
149
150 bool isSelected = (option.state & QStyle::State_Selected) && option.showDecorationSelected;
151
152 if (isSelected) {
153 adjustColor = option.palette.color(DPalette::ColorGroup::Active, QPalette::Highlight);
154 } else if (option.state & QStyle::StateFlag::State_MouseOver) {
155 // hover color
156 adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +10);
157 } else {
158 // alternately background color
159 painter->setOpacity(0);
160 if (index.row() % 2 == 0) {
161 adjustColor = DGuiApplicationHelper::adjustColor(baseColor, 0, 0, 0, 0, 0, 0, +5);
162 painter->setOpacity(1);
163 }
164 }
165
166 // set paint path
167 QPainterPath path;
168 path.addRoundedRect(option.rect, kRectRadius, kRectRadius);
169 painter->fillPath(path, adjustColor);
170 }
171
172 painter->restore();
173}
174
175void TaskDelegate::paintItemColumn(QPainter *painter, const QStyleOptionViewItem &option,
176 const QModelIndex &index, const QRect &iconRect) const

Callers

nothing calls this directly

Calls 5

rowMethod · 0.80
restoreMethod · 0.80
saveMethod · 0.45
colorMethod · 0.45
setOpacityMethod · 0.45

Tested by

no test coverage detected