Skip to content

Instantly share code, notes, and snippets.

@cosven
Created June 30, 2018 00:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosven/0ab4ede663f2754ae35d9e75ffbb3190 to your computer and use it in GitHub Desktop.
Save cosven/0ab4ede663f2754ae35d9e75ffbb3190 to your computer and use it in GitHub Desktop.
feeluown 项目一些废弃代码
def contextMenuEvent(self, event):
menu = QMenu()
index = self.indexAt(event.pos())
song = self.model().data(index, Qt.UserRole)
if song.album:
show_album_action = QAction('专辑:{}'.format(song.album.name), menu)
show_album_action.triggered.connect(
partial(self.show_album_needed.emit, song.album))
menu.addAction(show_album_action)
if song.artists:
if len(song.artists) == 1:
artist = song.artists[0]
show_artist_action = QAction('歌手:{}'.format(artist.name), menu)
show_artist_action.triggered.connect(
partial(self.show_artist_needed.emit, artist))
menu.addAction(show_artist_action)
else:
show_artists_menu = QMenu('歌手:{}'.format(song.artists_name), menu)
for artist in song.artists:
show_x_action = QAction(artist.name, show_artists_menu)
show_artists_menu.addAction(show_x_action)
show_x_action.triggered.connect(
partial(self.show_artist_needed.emit, artist))
menu.addMenu(show_artists_menu)
menu.exec(event.globalPos())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment