forked from Wobbl/Wobuzz
Added unique names on playlist rename.
This commit is contained in:
parent
b95081e840
commit
a8560add65
3 changed files with 12 additions and 5 deletions
|
@ -124,6 +124,8 @@ class Playlist:
|
|||
wbz.close()
|
||||
|
||||
def delete(self):
|
||||
self.app.utils.unique_names.pop(self.title) # remove from unique names so a new playlist can have the old name
|
||||
|
||||
path = f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
|
||||
if os.path.exists(path):
|
||||
|
|
|
@ -8,9 +8,10 @@ from .tab_bar import PlaylistTabBar
|
|||
|
||||
|
||||
class TabTitle(QLineEdit):
|
||||
def __init__(self, label, parent, index: int, playlist_view):
|
||||
def __init__(self, app, label, parent, index: int, playlist_view):
|
||||
super().__init__(label, parent)
|
||||
|
||||
self.app = app
|
||||
self.tab_bar: PlaylistTabBar = parent
|
||||
self.index = index
|
||||
self.playlist_view = playlist_view
|
||||
|
@ -36,5 +37,8 @@ class TabTitle(QLineEdit):
|
|||
|
||||
self.playlist_view.playlist.delete()
|
||||
|
||||
self.playlist_view.playlist.title = self.text()
|
||||
name = self.app.utils.unique_name(self.text())
|
||||
self.setText(name)
|
||||
|
||||
self.playlist_view.playlist.title = name
|
||||
|
||||
|
|
|
@ -8,10 +8,11 @@ from .tab_title import TabTitle
|
|||
|
||||
class PlaylistTabs(QTabWidget):
|
||||
def __init__(self, library, parent=None):
|
||||
self.library = library
|
||||
|
||||
super().__init__(parent)
|
||||
|
||||
self.library = library
|
||||
self.app = library.app
|
||||
|
||||
self.tab_bar = PlaylistTabBar(self)
|
||||
self.setTabBar(self.tab_bar)
|
||||
self.setDocumentMode(True)
|
||||
|
@ -24,7 +25,7 @@ class PlaylistTabs(QTabWidget):
|
|||
|
||||
index = self.tab_bar.count() - 1
|
||||
|
||||
title = TabTitle(label, self.tab_bar, index, widget)
|
||||
title = TabTitle(self.app, label, self.tab_bar, index, widget)
|
||||
|
||||
self.tab_bar.setTabButton(index, QTabBar.ButtonPosition.RightSide, title)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue