fix: show magnet name in compact mode (#5491)

This commit is contained in:
Charles Kerr 2023-05-04 15:24:19 -05:00 committed by GitHub
parent 2f1d5a225c
commit bd8b50ef7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 18 deletions

View File

@ -149,16 +149,14 @@ ItemLayout::ItemLayout(
QSize TorrentDelegateMin::sizeHint(QStyleOptionViewItem const& option, Torrent const& tor) const QSize TorrentDelegateMin::sizeHint(QStyleOptionViewItem const& option, Torrent const& tor) const
{ {
auto const is_magnet = !tor.hasMetadata();
auto const m = margin(*QApplication::style()); auto const m = margin(*QApplication::style());
auto const layout = ItemLayout( auto const layout = ItemLayout{ tor.name(),
is_magnet ? progressString(tor) : tor.name(),
shortStatusString(tor), shortStatusString(tor),
QIcon(), QIcon{},
option.font, option.font,
option.direction, option.direction,
QPoint(0, 0), QPoint{},
option.rect.width() - m.width() * 2); option.rect.width() - m.width() * 2 };
return layout.size() + m * 2; return layout.size() + m * 2;
} }
@ -167,7 +165,6 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
auto const* style = QApplication::style(); auto const* style = QApplication::style();
bool const is_paused(tor.isPaused()); bool const is_paused(tor.isPaused());
bool const is_magnet(!tor.hasMetadata());
bool const is_item_selected((option.state & QStyle::State_Selected) != 0); bool const is_item_selected((option.state & QStyle::State_Selected) != 0);
bool const is_item_enabled((option.state & QStyle::State_Enabled) != 0); bool const is_item_enabled((option.state & QStyle::State_Enabled) != 0);
@ -233,14 +230,13 @@ void TorrentDelegateMin::drawTorrent(QPainter* painter, QStyleOptionViewItem con
// layout // layout
QSize const m(margin(*style)); QSize const m(margin(*style));
QRect const content_rect(option.rect.adjusted(m.width(), m.height(), -m.width(), -m.height())); QRect const content_rect(option.rect.adjusted(m.width(), m.height(), -m.width(), -m.height()));
ItemLayout const layout( auto const layout = ItemLayout{ tor.name(), //
is_magnet ? progressString(tor) : tor.name(),
shortStatusString(tor), shortStatusString(tor),
emblem_icon, emblem_icon,
option.font, option.font,
option.direction, option.direction,
content_rect.topLeft(), content_rect.topLeft(),
content_rect.width()); content_rect.width() };
// render // render
if (tor.hasError() && !is_item_selected) if (tor.hasError() && !is_item_selected)