async def render(self): playlist = self.playlist # show playlist title self.meta_widget.show() self.meta_widget.title = playlist.name # show playlist song list songs = songs_g = None with suppress(ProviderIOError): if playlist.meta.allow_create_songs_g: songs_g = GeneratorProxy.wrap(playlist.create_songs_g()) else: songs = await async_run(lambda: playlist.songs) self.show_songs(songs=songs, songs_g=songs_g, show_count=True) # show playlist cover if playlist.cover: aio.create_task( self.show_cover(playlist.cover, reverse(playlist, '/cover'))) def remove_song(song): playlist.remove(song.identifier) self.songs_table.remove_song_func = remove_song self.tabbar.show_desc_needed.connect( lambda: aio.create_task(self._show_desc()))
async def render(self): playlist = self.playlist loop = asyncio.get_event_loop() songs = songs_g = None if playlist.meta.allow_create_songs_g: songs_g = GeneratorProxy.wrap(playlist.create_songs_g()) else: songs = await async_run(lambda: playlist.songs, loop=loop) self.show_songs(songs=songs, songs_g=songs_g, show_count=True) self.meta_widget.title = playlist.name desc = await async_run(lambda: playlist.desc) self.meta_widget.desc = desc if playlist.cover: loop.create_task(self.show_cover(playlist.cover)) def remove_song(song): model = self.songs_table.model() row = model.songs.index(song) msg = 'remove {} from {}'.format(song, playlist) with self._app.create_action(msg) as action: rv = playlist.remove(song.identifier) if rv: model.removeRow(row) else: action.failed() self.songs_table.song_deleted.connect(lambda song: remove_song(song))
def __init__(self, albums_g, fetch_image, parent=None): """ :param albums_g: :class:`fuocore.models.GeneratorProxy: """ super().__init__(parent) self.albums_g = GeneratorProxy.wrap(albums_g) self.fetch_image = fetch_image # false: no more, true: maybe more self._maybe_has_more = True self.albums = [] self.colors = [] self.pixmaps = {} # {uri: QPixmap}
async def render(self): playlist = self.playlist # show playlist title self.meta_widget.title = playlist.name # show playlist song list loop = asyncio.get_event_loop() songs = songs_g = None try: if playlist.meta.allow_create_songs_g: songs_g = GeneratorProxy.wrap(playlist.create_songs_g()) else: songs = await async_run(lambda: playlist.songs, loop=loop) except ProviderIOError as e: self._app.show_msg('read playlist/songs failed:{}'.format(str(e))) logger.exception('read playlist/songs failed') else: self.show_songs(songs=songs, songs_g=songs_g, show_count=True) # show playlist description try: desc = await async_run(lambda: playlist.desc) except ProviderIOError as e: self._app.show_msg('read playlist/desc failed:{}'.format(str(e))) else: self.meta_widget.desc = desc # show playlist cover if playlist.cover: loop.create_task( self.show_cover(playlist.cover, reverse(playlist, '/cover'))) def remove_song(song): model = self.songs_table.model() row = model.songs.index(song) msg = 'remove {} from {}'.format(song, playlist) with self._app.create_action(msg) as action: rv = playlist.remove(song.identifier) if rv: model.removeRow(row) else: action.failed() self.songs_table.song_deleted.connect(lambda song: remove_song(song)) self.meta_widget.toolbar.pure_songs_mode()