void ItemPinned::paintEvent(QPaintEvent *paintEvent) { const auto *parent = parentWidget(); auto color = parent->palette().color(QPalette::Background); const int lightThreshold = 100; const bool menuBackgrounIsLight = color.lightness() > lightThreshold; color.setHsl( color.hue(), color.saturation(), qMax(0, qMin(255, color.lightness() + (menuBackgrounIsLight ? -200 : 50))) ); QPainter painter(this); const int border = pointsToPixels(6); const QRect rect(width() - border, 0, width(), height()); painter.setOpacity(0.15); painter.fillRect(rect, color); QWidget::paintEvent(paintEvent); }
void tst_QColor::getHsl() { DEPENDS_ON(setHsl()); }
void tst_QColor::lightness() { DEPENDS_ON(setHsl()); }
void tst_QColor::saturationHsl() { DEPENDS_ON(setHsl()); }