Use semi-transparent color for inactive torrents (#6544)

This commit is contained in:
Mike Gelfand 2024-01-21 22:13:51 +00:00 committed by GitHub
parent 08b2fa7e35
commit 29a566664a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 36 deletions

View File

@ -526,21 +526,16 @@ void TorrentDelegate::drawTorrent(QPainter* painter, QStyleOptionViewItem const&
}
auto const icon_state = is_paused ? QIcon::Off : QIcon::On;
auto const color_group = is_item_active ? QPalette::Normal : QPalette::Inactive;
auto const color_role = is_item_selected ? QPalette::HighlightedText : QPalette::Text;
auto color_group = QPalette::Normal;
auto text_color = (tor.hasError() && !is_item_selected) ? QColor{ Qt::GlobalColor::red } :
option.palette.color(color_group, color_role);
if (is_paused || !is_item_enabled)
{
color_group = QPalette::Disabled;
text_color.setAlphaF(0.5);
}
if (color_group == QPalette::Normal && !is_item_active)
{
color_group = QPalette::Inactive;
}
auto const color_role = is_item_selected ? QPalette::HighlightedText : QPalette::Text;
QStyle::State progress_bar_state(option.state);
if (is_paused)
@ -560,14 +555,7 @@ void TorrentDelegate::drawTorrent(QPainter* painter, QStyleOptionViewItem const&
option.font, option.direction, content_rect.topLeft(), content_rect.width() };
// render
if (tor.hasError() && !is_item_selected)
{
painter->setPen(QColor{ "red" });
}
else
{
painter->setPen(option.palette.color(color_group, color_role));
}
painter->setPen(text_color);
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);

View File

@ -197,21 +197,16 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
}
auto const icon_state = is_paused ? QIcon::Off : QIcon::On;
auto const color_group = is_item_active ? QPalette::Normal : QPalette::Inactive;
auto const color_role = is_item_selected ? QPalette::HighlightedText : QPalette::Text;
QPalette::ColorGroup color_group = QPalette::Normal;
auto text_color = (tor.hasError() && !is_item_selected) ? QColor{ Qt::GlobalColor::red } :
option.palette.color(color_group, color_role);
if (is_paused || !is_item_enabled)
{
color_group = QPalette::Disabled;
text_color.setAlphaF(0.5);
}
if (color_group == QPalette::Normal && !is_item_active)
{
color_group = QPalette::Inactive;
}
auto const color_role = is_item_selected ? QPalette::HighlightedText : QPalette::Text;
QStyle::State progress_bar_state(option.state);
if (is_paused)
@ -236,14 +231,7 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
content_rect.width() };
// render
if (tor.hasError() && !is_item_selected)
{
painter->setPen(QColor{ "red" });
}
else
{
painter->setPen(option.palette.color(color_group, color_role));
}
painter->setPen(text_color);
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);