Skip to content

Commit

Permalink
gui: show play_count and tooltip for VideoCardListView (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven authored Jun 3, 2024
1 parent cb1501a commit b914e8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion feeluown/gui/pages/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def render(req: Request, **kwargs):
if isinstance(delegate, ImgCardListDelegate):
# FIXME: set fixed_row_count in better way.
table._fixed_row_count = 2 # type: ignore[attr-defined]
delegate.update_settings("card_min_width", 100)
delegate.update_settings("card_min_width", 140)
elif isinstance(table, SongsTableView):
table._fixed_row_count = 8
table._row_height = table.verticalHeader().defaultSectionSize()
Expand Down
14 changes: 12 additions & 2 deletions feeluown/gui/widgets/img_card_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)

from feeluown.utils import aio
from feeluown.library import AlbumModel, AlbumType, PlaylistModel
from feeluown.library import AlbumModel, AlbumType, PlaylistModel, VideoModel
from feeluown.utils.reader import wrap
from feeluown.utils.utils import int_to_human_readable
from feeluown.library import reverse
Expand Down Expand Up @@ -126,6 +126,8 @@ def data(self, index, role):
return item
elif role == Qt.WhatsThisRole:
return self.source_name_map.get(item.source, item.source)
elif role == Qt.ToolTipRole:
return item.name
return None


Expand Down Expand Up @@ -377,7 +379,15 @@ def data(self, index, role):
return None
video = self._items[offset]
if role == Qt.DisplayRole:
return video.title_display
return video.title
elif role == Qt.ToolTipRole:
return video.title
elif (
role == Qt.WhatsThisRole
and isinstance(video, VideoModel)
and video.play_count > 0
):
return f'► {int_to_human_readable(video.play_count)}'
return super().data(index, role)


Expand Down

0 comments on commit b914e8b

Please sign in to comment.