-void PlaylistItemDelegate::paintActiveOverlay(QPainter *painter, const QRect &line) const {
- static QLinearGradient linearGradient;
- static bool initialized = false;
-
- if (!initialized) {
- QPalette palette;
- QColor highlightColor = palette.color(QPalette::Highlight);
- QColor backgroundColor = palette.color(QPalette::Base);
- const float animation = 0.4;
- const int gradientRange = 16;
-
- QColor color2 = QColor::fromHsv(
- highlightColor.hue(),
- (int) (backgroundColor.saturation() * (1.0f - animation) + highlightColor.saturation() * animation),
- (int) (backgroundColor.value() * (1.0f - animation) + highlightColor.value() * animation)
- );
- QColor color1 = QColor::fromHsv(
- color2.hue(),
- qMax(color2.saturation() - gradientRange, 0),
- qMin(color2.value() + gradientRange, 255)
- );
-
- linearGradient = QLinearGradient(0, 0, 0, THUMB_HEIGHT);
- linearGradient.setColorAt(0.0, color1);
- linearGradient.setColorAt(1.0, color2);
- initialized = true;
- }
-
- painter->fillRect(line, linearGradient);
+void PlaylistItemDelegate::paintActiveOverlay(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QRect &line) const {
+ painter->save();
+ painter->setOpacity(.2);
+ painter->fillRect(line, option.palette.highlight());
+ painter->restore();