Added ability to select multiple items. Added alt+a to act on all checked items.

This commit is contained in:
Storm Dragon committed 2026-09-16 00:43:20 -04:00
1 parent bd6cfb83eb
commit 059e4e124b
5 files changed
+306 -16

No files matched your search

+80
View File
@@ -235,6 +235,86 @@ def test_collection_actions_and_queue_use_current_payload(window, monkeypatch):
assert targets[-1]['type'] == 'artist'
def test_checked_items_persist_across_tabs_and_alt_a_uses_the_group(window):
w, pending = window
browser = w.libraryBrowser
artistsPage = browser.pages['Artists']
QTest.keyClick(artistsPage.table, Qt.Key_Space)
assert artistsPage.model.data(artistsPage.model.index(0, 0), Qt.CheckStateRole) == Qt.Checked
browser.setCurrentWidget(browser.pages['Albums'])
finish(pending)
albumsPage = browser.currentWidget()
QTest.keyClick(albumsPage.table, Qt.Key_Space)
browser.setCurrentWidget(browser.pages['Favorites'])
favoritesPage = browser.currentWidget()
QTest.keyClick(favoritesPage.table, Qt.Key_Space)
group = browser.actionData(favoritesPage.selectedData())
assert group['type'] == 'checked_items'
assert [item['type'] for item in group['items']] == ['artist', 'album', 'song']
assert favoritesPage.actionsButton.text() == 'Actions (3 checked)'
assert '3 items checked' in favoritesPage.status.text()
targets = []
w.addItemToQueue = targets.append
def choose_queue():
menu = QApplication.activePopupWidget()
action = next(action for action in menu.actions()
if action.text() == 'Add Checked Items to Queue')
menu.close()
action.trigger()
QTimer.singleShot(0, choose_queue)
QTest.keyClick(favoritesPage.table, Qt.Key_A, Qt.AltModifier)
assert targets[-1]['type'] == 'checked_items'
assert len(targets[-1]['items']) == 3
favoritesPage.clearCheckedButton.click()
assert browser.checkedCount() == 0
assert artistsPage.model.data(artistsPage.model.index(0, 0), Qt.CheckStateRole) == Qt.Unchecked
def test_checked_collections_expand_and_deduplicate_songs(window):
w, _ = window
selectedSong = w.client.getAlbum.return_value['songs'][0]
result, label, truncated = w.collectSongsForItem({
'type': 'checked_items',
'label': '3 checked items',
'items': [
{'type': 'artist', 'id': 'artist', 'label': 'Artist'},
{'type': 'album', 'id': 'album', 'label': 'Album'},
{'type': 'song', 'id': selectedSong.id, 'label': selectedSong.title,
'song': selectedSong},
],
})
assert result == [selectedSong]
assert label == '3 checked items'
assert not truncated
def test_checked_favorite_action_attempts_every_item(window):
w, _ = window
w.client.star.side_effect = [None, RuntimeError('synthetic failure'), None]
items = [
{'type': 'artist', 'id': 'artist', 'label': 'Artist'},
{'type': 'album', 'id': 'album', 'label': 'Album'},
{'type': 'song', 'id': 'song', 'label': 'Song'},
]
updated, failed = w._setCheckedItemsFavorite(items, True)
assert updated == 2
assert failed == ['Album']
assert [entry.args for entry in w.client.star.call_args_list] == [
('artist', 'artist'),
('album', 'album'),
('song', 'song'),
]
def test_actual_background_request_does_not_block_back_navigation(window):
import threading
import time