From b914e8b96dc9572dfaaaa1a8b826655c1fdc7638 Mon Sep 17 00:00:00 2001 From: Shaowen Yin Date: Mon, 3 Jun 2024 21:16:49 +0800 Subject: [PATCH] gui: show play_count and tooltip for VideoCardListView (#838) --- feeluown/gui/pages/search.py | 2 +- feeluown/gui/widgets/img_card_list.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/feeluown/gui/pages/search.py b/feeluown/gui/pages/search.py index 2444ab2e5..10373f3cb 100644 --- a/feeluown/gui/pages/search.py +++ b/feeluown/gui/pages/search.py @@ -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() diff --git a/feeluown/gui/widgets/img_card_list.py b/feeluown/gui/widgets/img_card_list.py index 1a7e845fe..5a8c13d39 100644 --- a/feeluown/gui/widgets/img_card_list.py +++ b/feeluown/gui/widgets/img_card_list.py @@ -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 @@ -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 @@ -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)