Implemented renaming of playlists.
This commit is contained in:
parent
b2aa7ffd8c
commit
3e579a4fcb
3 changed files with 24 additions and 4 deletions
|
@ -114,10 +114,22 @@ class Playlist:
|
|||
for track in self.tracks:
|
||||
wbz_data += f"{track.path}\n"
|
||||
|
||||
wbz = open(os.path.expanduser(f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"), "w")
|
||||
wbz = open(
|
||||
os.path.expanduser(
|
||||
f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
),
|
||||
"w"
|
||||
)
|
||||
wbz.write(wbz_data)
|
||||
wbz.close()
|
||||
|
||||
def delete(self):
|
||||
os.remove(
|
||||
os.path.expanduser(
|
||||
f"{self.app.settings.library_path}/playlists/{self.title.replace(" ", "_")}.wbz.m3u"
|
||||
),
|
||||
)
|
||||
|
||||
def append_track(self, track):
|
||||
self.tracks.append(track)
|
||||
|
||||
|
|
|
@ -8,17 +8,18 @@ from .tab_bar import PlaylistTabBar
|
|||
|
||||
|
||||
class TabTitle(QLineEdit):
|
||||
def __init__(self, label, parent, index: int):
|
||||
def __init__(self, label, parent, index: int, playlist_view):
|
||||
super().__init__(label, parent)
|
||||
|
||||
self.tab_bar: PlaylistTabBar = parent
|
||||
self.index = index
|
||||
self.playlist_view = playlist_view
|
||||
|
||||
self.setStyleSheet("QLineEdit {background: transparent;}")
|
||||
|
||||
self.setFocusPolicy(Qt.FocusPolicy.TabFocus)
|
||||
|
||||
self.returnPressed.connect(self.clearFocus)
|
||||
self.editingFinished.connect(self.on_edit)
|
||||
|
||||
def mouseDoubleClickEvent(self, event: QMouseEvent):
|
||||
self.tab_bar.tabBarDoubleClicked.emit(self.index)
|
||||
|
@ -30,3 +31,10 @@ class TabTitle(QLineEdit):
|
|||
def contextMenuEvent(self, event):
|
||||
self.tab_bar.contextMenuEvent(event, self)
|
||||
|
||||
def on_edit(self):
|
||||
self.clearFocus()
|
||||
|
||||
self.playlist_view.playlist.delete()
|
||||
|
||||
self.playlist_view.playlist.title = self.text()
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ class PlaylistTabs(QTabWidget):
|
|||
|
||||
index = self.tab_bar.count() - 1
|
||||
|
||||
title = TabTitle(label, self.tab_bar, index)
|
||||
title = TabTitle(label, self.tab_bar, index, widget)
|
||||
|
||||
self.tab_bar.setTabButton(index, QTabBar.ButtonPosition.RightSide, title)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue