feat: fade installed resources in the download dialog

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97 2025-05-02 20:31:42 +03:00
parent 6eec17e846
commit 09dcfa4b65
No known key found for this signature in database
GPG key ID: 55EF5DA53DB36318

View file

@ -16,13 +16,20 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
QStyleOptionViewItem opt(option); QStyleOptionViewItem opt(option);
initStyleOption(&opt, index); initStyleOption(&opt, index);
auto isInstalled = index.data(UserDataTypes::INSTALLED).toBool();
auto isChecked = opt.checkState == Qt::Checked;
auto isSelected = option.state & QStyle::State_Selected;
if (!isSelected && !isChecked && isInstalled) {
painter->setOpacity(0.4); // Fade out the entire item
}
const QStyle* style = opt.widget == nullptr ? QApplication::style() : opt.widget->style(); const QStyle* style = opt.widget == nullptr ? QApplication::style() : opt.widget->style();
auto rect = opt.rect; auto rect = opt.rect;
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
if (option.state & QStyle::State_Selected && style->objectName() != "windowsvista") if (isSelected && style->objectName() != "windowsvista")
painter->setPen(opt.palette.highlightedText().color()); painter->setPen(opt.palette.highlightedText().color());
if (opt.features & QStyleOptionViewItem::HasCheckIndicator) { if (opt.features & QStyleOptionViewItem::HasCheckIndicator) {
@ -68,12 +75,16 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
{ // Title painting { // Title painting
auto title = index.data(UserDataTypes::TITLE).toString(); auto title = index.data(UserDataTypes::TITLE).toString();
if (index.data(UserDataTypes::INSTALLED).toBool())
title = tr("%1 [installed]").arg(title);
painter->save(); painter->save();
auto font = opt.font; auto font = opt.font;
if (isChecked) {
font.setBold(true);
}
if (isInstalled) {
title = tr("%1 [installed]").arg(title);
}
font.setPointSize(font.pointSize() + 2); font.setPointSize(font.pointSize() + 2);
painter->setFont(font); painter->setFont(font);