From 09dcfa4b65f3ecbb04f10987d35ad5ae20ed6405 Mon Sep 17 00:00:00 2001 From: Trial97 Date: Fri, 2 May 2025 20:31:42 +0300 Subject: [PATCH] feat: fade installed resources in the download dialog Signed-off-by: Trial97 --- launcher/ui/widgets/ProjectItem.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index 03fa659c9..91cf0956f 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -16,13 +16,20 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o QStyleOptionViewItem opt(option); 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(); auto rect = opt.rect; 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()); if (opt.features & QStyleOptionViewItem::HasCheckIndicator) { @@ -68,12 +75,16 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o { // Title painting auto title = index.data(UserDataTypes::TITLE).toString(); - if (index.data(UserDataTypes::INSTALLED).toBool()) - title = tr("%1 [installed]").arg(title); - painter->save(); auto font = opt.font; + if (isChecked) { + font.setBold(true); + } + if (isInstalled) { + title = tr("%1 [installed]").arg(title); + } + font.setPointSize(font.pointSize() + 2); painter->setFont(font);