Select next/previous non-note row with j/k
This commit is contained in:
parent
0c67ba7b3e
commit
4a24640666
@ -129,6 +129,9 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
self.actionOpenPlaylist.triggered.connect(self.open_playlist)
|
||||
self.actionPlay_next.triggered.connect(self.play_next)
|
||||
self.actionSearch_database.triggered.connect(self.search_database)
|
||||
self.actionSelect_next_track.triggered.connect(self.select_next_track)
|
||||
self.actionSelect_previous_track.triggered.connect(
|
||||
self.select_previous_track)
|
||||
self.actionSetNext.triggered.connect(self.set_next_track)
|
||||
self.actionSkip_next.triggered.connect(self.play_next)
|
||||
self.actionSkipToEnd.triggered.connect(self.test_skip_to_end)
|
||||
@ -390,6 +393,16 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
playlist = Playlists.open(dlg.plid)
|
||||
self.load_playlist(playlist)
|
||||
|
||||
def select_next_track(self):
|
||||
"Select next or first track in playlist"
|
||||
|
||||
self.visible_playlist().select_next_track()
|
||||
|
||||
def select_previous_track(self):
|
||||
"Select previous or first track in playlist"
|
||||
|
||||
self.visible_playlist().select_previous_track()
|
||||
|
||||
def set_next_track(self, next_track_id=None):
|
||||
"Set selected track as next"
|
||||
|
||||
|
||||
@ -364,6 +364,71 @@ class Playlist(QTableWidget):
|
||||
# Called when we change tabs
|
||||
self._repaint(save_playlist=False)
|
||||
|
||||
def select_next_track(self):
|
||||
"""
|
||||
Select next or first track. Don't select notes. Wrap at last row.
|
||||
"""
|
||||
|
||||
selected_rows = [row for row in
|
||||
set([a.row() for a in self.selectedItems()])]
|
||||
# we will only handle zero or one selected rows
|
||||
if len(selected_rows) > 1:
|
||||
return
|
||||
# select first row if none selected
|
||||
if len(selected_rows) == 0:
|
||||
row = 0
|
||||
else:
|
||||
row = selected_rows[0] + 1
|
||||
if row >= self.rowCount():
|
||||
row = 0
|
||||
|
||||
# Don't select notes
|
||||
wrapped = False
|
||||
while row in self._meta_get_notes():
|
||||
row += 1
|
||||
if row >= self.rowCount():
|
||||
if wrapped:
|
||||
# we're already wrapped once, so there are no
|
||||
# non-notes
|
||||
return
|
||||
row = 0
|
||||
wrapped = True
|
||||
|
||||
self.selectRow(row)
|
||||
|
||||
def select_previous_track(self):
|
||||
"""
|
||||
Select previous or last track. Don't select notes. Wrap at first row.
|
||||
"""
|
||||
|
||||
selected_rows = [row for row in
|
||||
set([a.row() for a in self.selectedItems()])]
|
||||
# we will only handle zero or one selected rows
|
||||
if len(selected_rows) > 1:
|
||||
return
|
||||
# select last row if none selected
|
||||
last_row = self.rowCount() - 1
|
||||
if len(selected_rows) == 0:
|
||||
row = last_row
|
||||
else:
|
||||
row = selected_rows[0] - 1
|
||||
if row < 0:
|
||||
row = last_row
|
||||
|
||||
# Don't select notes
|
||||
wrapped = False
|
||||
while row in self._meta_get_notes():
|
||||
row -= 1
|
||||
if row < 0:
|
||||
if wrapped:
|
||||
# we're already wrapped once, so there are no
|
||||
# non-notes
|
||||
return
|
||||
row = last_row
|
||||
wrapped = True
|
||||
|
||||
self.selectRow(row)
|
||||
|
||||
def set_selected_as_next(self):
|
||||
"""
|
||||
Sets the selected track as the next track.
|
||||
|
||||
@ -760,6 +760,9 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<addaction name="actionMoveSelected"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExport_playlist"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionSelect_next_track"/>
|
||||
<addaction name="actionSelect_previous_track"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Tracks">
|
||||
<property name="title">
|
||||
@ -958,6 +961,22 @@ border: 1px solid rgb(85, 87, 83);</string>
|
||||
<string>Ctrl+N</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelect_next_track">
|
||||
<property name="text">
|
||||
<string>Select next track</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>J</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSelect_previous_track">
|
||||
<property name="text">
|
||||
<string>Select previous track</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>K</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons.qrc"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user