mirror of
https://github.com/transmission/transmission
synced 2025-01-02 21:16:04 +00:00
Use semi-transparent color for inactive torrents (#6544)
This commit is contained in:
parent
08b2fa7e35
commit
29a566664a
2 changed files with 12 additions and 36 deletions
|
@ -526,21 +526,16 @@ void TorrentDelegate::drawTorrent(QPainter* painter, QStyleOptionViewItem const&
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const icon_state = is_paused ? QIcon::Off : QIcon::On;
|
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)
|
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);
|
QStyle::State progress_bar_state(option.state);
|
||||||
|
|
||||||
if (is_paused)
|
if (is_paused)
|
||||||
|
@ -560,14 +555,7 @@ void TorrentDelegate::drawTorrent(QPainter* painter, QStyleOptionViewItem const&
|
||||||
option.font, option.direction, content_rect.topLeft(), content_rect.width() };
|
option.font, option.direction, content_rect.topLeft(), content_rect.width() };
|
||||||
|
|
||||||
// render
|
// render
|
||||||
if (tor.hasError() && !is_item_selected)
|
painter->setPen(text_color);
|
||||||
{
|
|
||||||
painter->setPen(QColor{ "red" });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painter->setPen(option.palette.color(color_group, color_role));
|
|
||||||
}
|
|
||||||
|
|
||||||
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);
|
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);
|
||||||
|
|
||||||
|
|
|
@ -197,21 +197,16 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
|
||||||
}
|
}
|
||||||
|
|
||||||
auto const icon_state = is_paused ? QIcon::Off : QIcon::On;
|
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)
|
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);
|
QStyle::State progress_bar_state(option.state);
|
||||||
|
|
||||||
if (is_paused)
|
if (is_paused)
|
||||||
|
@ -236,14 +231,7 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
|
||||||
content_rect.width() };
|
content_rect.width() };
|
||||||
|
|
||||||
// render
|
// render
|
||||||
if (tor.hasError() && !is_item_selected)
|
painter->setPen(text_color);
|
||||||
{
|
|
||||||
painter->setPen(QColor{ "red" });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
painter->setPen(option.palette.color(color_group, color_role));
|
|
||||||
}
|
|
||||||
|
|
||||||
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);
|
tor.getMimeTypeIcon().paint(painter, layout.icon_rect, Qt::AlignCenter, icon_mode, icon_state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue