In track add dialog, ESC clears currently selected track
This commit is contained in:
parent
8651dae3f3
commit
403c470c8a
@ -1903,14 +1903,19 @@ class DbDialog(QDialog):
|
||||
def add_selected(self) -> None:
|
||||
"""Handle Add button"""
|
||||
|
||||
if not self.ui.matchList.selectedItems() and not self.ui.txtNote.text():
|
||||
track = None
|
||||
|
||||
if self.ui.matchList.selectedItems():
|
||||
item = self.ui.matchList.currentItem()
|
||||
if item:
|
||||
track = item.data(Qt.ItemDataRole.UserRole)
|
||||
|
||||
note = self.ui.txtNote.text()
|
||||
|
||||
if not note and not track:
|
||||
return
|
||||
|
||||
track = None
|
||||
item = self.ui.matchList.currentItem()
|
||||
if item:
|
||||
track = item.data(Qt.ItemDataRole.UserRole)
|
||||
self.add_track(track)
|
||||
self.add_track(track, self.ui.txtNote.text())
|
||||
|
||||
def add_selected_and_close(self) -> None:
|
||||
"""Handle Add and Close button"""
|
||||
@ -1918,7 +1923,7 @@ class DbDialog(QDialog):
|
||||
self.add_selected()
|
||||
self.accept()
|
||||
|
||||
def add_track(self, track: Tracks) -> None:
|
||||
def add_track(self, track: Optional[Tracks], note: str) -> None:
|
||||
"""Add passed track to playlist on screen"""
|
||||
|
||||
if self.get_one_track:
|
||||
@ -1927,20 +1932,10 @@ class DbDialog(QDialog):
|
||||
return
|
||||
|
||||
if track:
|
||||
self.musicmuster.visible_playlist_tab().insert_track(
|
||||
self.session, track, note=self.ui.txtNote.text()
|
||||
)
|
||||
self.musicmuster.visible_playlist_tab().insert_track(self.session, track, note)
|
||||
else:
|
||||
self.musicmuster.visible_playlist_tab().insert_header(
|
||||
self.session, note=self.ui.txtNote.text()
|
||||
)
|
||||
self.musicmuster.visible_playlist_tab().insert_header(self.session, note)
|
||||
|
||||
# TODO: this shouldn't be needed as insert_track() saves
|
||||
# playlist
|
||||
# # Save to database (which will also commit changes)
|
||||
# self.musicmuster.visible_playlist_tab().save_playlist(self.session)
|
||||
# Clear note field and select search text to make it easier for
|
||||
# next search
|
||||
self.ui.txtNote.clear()
|
||||
self.select_searchtext()
|
||||
|
||||
@ -1969,9 +1964,20 @@ class DbDialog(QDialog):
|
||||
"""Add items that are double-clicked"""
|
||||
|
||||
track = entry.data(Qt.ItemDataRole.UserRole)
|
||||
self.add_track(track)
|
||||
# Select search text to make it easier for next search
|
||||
self.select_searchtext()
|
||||
note = self.ui.txtNote.text()
|
||||
self.add_track(track, note)
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
"""
|
||||
Clear selection on ESC if there is one
|
||||
"""
|
||||
|
||||
if event.key() == Qt.Key.Key_Escape:
|
||||
if self.ui.matchList.selectedItems():
|
||||
self.ui.matchList.clearSelection()
|
||||
return
|
||||
|
||||
super(DbDialog, self).keyPressEvent(event)
|
||||
|
||||
def select_searchtext(self) -> None:
|
||||
"""Select the searchbox"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user