forked from Wobbl/Wobuzz
Fixed some bugs that happened when tracks got rearranged.
This commit is contained in:
parent
b2bd8ef784
commit
519b2d0adb
10 changed files with 72 additions and 17 deletions
|
@ -50,13 +50,18 @@ class PlaylistView(QTreeWidget):
|
|||
track = track_item.track
|
||||
|
||||
track_item.index_user_sort = i
|
||||
track_item.index = i
|
||||
|
||||
track_item.setText(5, str(i + 1))
|
||||
|
||||
self.playlist.tracks[i] = track
|
||||
|
||||
track.set_occurrences()
|
||||
|
||||
i += 1
|
||||
|
||||
self.app.player.cache_next_track()
|
||||
if self.app.player.current_playlist.has_tracks():
|
||||
self.app.player.cache_next_track()
|
||||
|
||||
def dropEvent(self, event: QDropEvent):
|
||||
# receive items that were dropped and create new items from its tracks (new items bc. widgets can only have
|
||||
|
@ -105,9 +110,6 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
i += 1
|
||||
|
||||
if not self.topLevelItemCount() == 0:
|
||||
self.topLevelItem(0).setIcon(0, self.playing_mark)
|
||||
|
||||
def on_track_activation(self, item, column):
|
||||
if not self.app.player.current_playlist == self.playlist:
|
||||
self.app.player.current_playlist = self.playlist
|
||||
|
@ -117,14 +119,16 @@ class PlaylistView(QTreeWidget):
|
|||
|
||||
def on_track_change(self, previous_track, track):
|
||||
# remove playing mark from first track bc it may not be in the history
|
||||
self.topLevelItem(0).setIcon(0, QIcon(None))
|
||||
#self.topLevelItem(0).setIcon(0, QIcon(None))
|
||||
|
||||
# unmark the previous track and mark the current track as playing
|
||||
if previous_track:
|
||||
previous_track.item.setIcon(0, QIcon(None))
|
||||
for item in previous_track.items:
|
||||
item.setIcon(0, QIcon(None))
|
||||
|
||||
if track:
|
||||
track.item.setIcon(0, self.playing_mark)
|
||||
item = self.topLevelItem(self.app.player.current_playlist.current_track_index)
|
||||
item.setIcon(0, self.playing_mark)
|
||||
|
||||
def append_track(self, track):
|
||||
TrackItem(track, self.topLevelItemCount() - 1, self)
|
||||
|
|
|
@ -24,14 +24,21 @@ class PlaylistTabBar(QTabBar):
|
|||
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
self.tabBarClicked.connect(self.on_click)
|
||||
self.tabBarDoubleClicked.connect(self.on_doubleclick)
|
||||
|
||||
def dragEnterEvent(self, event: QDragEnterEvent):
|
||||
index = self.tabAt(event.position().toPoint())
|
||||
|
||||
self.tab_widget.setCurrentIndex(index)
|
||||
|
||||
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
||||
index = self.tabAt(event.position().toPoint())
|
||||
def on_click(self, index):
|
||||
playlist_view = self.tab_widget.widget(index)
|
||||
playlist = playlist_view.playlist
|
||||
|
||||
self.app.gui.clicked_playlist = playlist
|
||||
|
||||
def on_doubleclick(self, index):
|
||||
playlist_view = self.tab_widget.widget(index)
|
||||
playlist = playlist_view.playlist
|
||||
|
||||
|
|
|
@ -11,7 +11,13 @@ class TrackItem(QTreeWidgetItem):
|
|||
self.track = track
|
||||
self.index_user_sort = index
|
||||
|
||||
track.item = self
|
||||
self.index = index
|
||||
|
||||
self.playlist = parent.playlist
|
||||
|
||||
track.items.append(self)
|
||||
|
||||
track.set_occurrences()
|
||||
|
||||
self.setFlags(
|
||||
Qt.ItemFlag.ItemIsEnabled |
|
||||
|
|
|
@ -83,6 +83,9 @@ class TrackControl(QToolBar):
|
|||
elif self.app.player.current_playlist.has_tracks(): # stopped but tracks in the current playlist
|
||||
self.app.player.start_playing()
|
||||
|
||||
elif self.app.player.current_playlist.title == "None":
|
||||
self.app.player.start_playlist(self.app.gui.clicked_playlist)
|
||||
|
||||
def on_playstate_update(self):
|
||||
if self.app.player.playing:
|
||||
if self.app.player.paused:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue