Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: remove multiple songs from playlist #874

Merged
merged 1 commit into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions feeluown/gui/components/player_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,17 @@ def __init__(self, app, *args, **kwargs):
self.setModel(PlayerPlaylistView._model)

def contextMenuEvent(self, e):
index = self.indexAt(e.pos())
if not index.isValid():
indexes = self.selectedIndexes()
if not indexes:
return

song = index.data(Qt.UserRole)[0]
songs = [index.data(Qt.UserRole)[0] for index in indexes]
menu = QMenu()
action = menu.addAction('从播放队列中移除')
menu.addSeparator()
SongMenuInitializer(self._app, song).apply(menu)

action.triggered.connect(lambda: self._app.playlist.remove(song))
action.triggered.connect(lambda: self._remove_songs(songs))
if len(songs) == 1:
menu.addSeparator()
SongMenuInitializer(self._app, songs).apply(menu)
menu.exec_(e.globalPos())

def scroll_to_current_song(self):
Expand All @@ -88,3 +88,7 @@ def scroll_to_current_song(self):
# In order to highlight the current song.
self.selectionModel().select(index, QItemSelectionModel.SelectCurrent)
self.scrollTo(index, QAbstractItemView.PositionAtCenter)

def _remove_songs(self, songs):
for song in songs:
self._app.playlist.remove(song)
1 change: 1 addition & 0 deletions feeluown/gui/widgets/song_minicard_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class SongMiniCardListView(ItemViewNoScrollMixin, QListView):
def __init__(self, parent=None, **kwargs):
super().__init__(parent=parent, **kwargs)

self.setSelectionMode(QListView.ContiguousSelection)
self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
self.setMouseTracking(True)
Expand Down
Loading