Improve behaviour of select playlist dialog

This commit is contained in:
Keith Edmunds 2021-04-25 18:39:47 +01:00
parent 839f550e4a
commit e086dd35c6

View File

@ -996,7 +996,9 @@ class SelectPlaylistDialog(QDialog):
super().__init__(parent)
self.ui = Ui_dlgSelectPlaylist()
self.ui.setupUi(self)
self.ui.lstPlaylists.itemDoubleClicked.connect(self.listdclick)
self.ui.lstPlaylists.itemDoubleClicked.connect(self.list_doubleclick)
self.ui.buttonBox.accepted.connect(self.open)
self.ui.buttonBox.rejected.connect(self.close)
for (plid, plname) in [
(a.id, a.name) for a in Playlists.get_all_playlists()
@ -1006,9 +1008,17 @@ class SelectPlaylistDialog(QDialog):
p.setData(Qt.UserRole, plid)
self.ui.lstPlaylists.addItem(p)
def listdclick(self, entry):
def list_doubleclick(self, entry):
plid = entry.data(Qt.UserRole)
self.parent().load_playlist(plid)
self.close()
def open(self):
if self.ui.lstPlaylists.selectedItems():
item = self.ui.lstPlaylists.currentItem()
plid = item.data(Qt.UserRole)
self.parent().load_playlist(plid)
self.close()
class Window(QWidget):