From 14e1bb0bf4e5d4d67e15a3cc54ea5964011ad141 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Fri, 10 Feb 2023 19:55:30 -0800 Subject: [PATCH] add select all shortcut to album and playlist pages --- ui/browsing/albumpage.go | 4 ++++ ui/browsing/browsingpane.go | 10 ++++++++++ ui/browsing/playlistpage.go | 4 ++++ ui/mainwindow.go | 3 +++ ui/widgets/tracklist.go | 5 +++++ 5 files changed, 26 insertions(+) diff --git a/ui/browsing/albumpage.go b/ui/browsing/albumpage.go index b5957c4..5e73ce6 100644 --- a/ui/browsing/albumpage.go +++ b/ui/browsing/albumpage.go @@ -108,6 +108,10 @@ func (a *AlbumPage) Tapped(*fyne.PointEvent) { a.tracklist.UnselectAll() } +func (a *AlbumPage) SelectAll() { + a.tracklist.SelectAll() +} + func (a *AlbumPage) onPlayTrackAt(tracknum int) { a.pm.PlayAlbum(a.albumID, tracknum) } diff --git a/ui/browsing/browsingpane.go b/ui/browsing/browsingpane.go index 278fa25..8a6670a 100644 --- a/ui/browsing/browsingpane.go +++ b/ui/browsing/browsingpane.go @@ -31,6 +31,10 @@ type Searchable interface { SearchWidget() fyne.Focusable } +type CanSelectAll interface { + SelectAll() +} + type CanShowNowPlaying interface { OnSongChange(song *subsonic.Child) } @@ -89,6 +93,12 @@ func (b *BrowsingPane) GetSearchBarIfAny() fyne.Focusable { return nil } +func (b *BrowsingPane) SelectAll() { + if s, ok := b.curPage.(CanSelectAll); ok { + s.SelectAll() + } +} + func (b *BrowsingPane) doSetPage(p Page) bool { if b.curPage != nil && b.curPage.Route() == p.Route() { return false diff --git a/ui/browsing/playlistpage.go b/ui/browsing/playlistpage.go index 635434d..886d086 100644 --- a/ui/browsing/playlistpage.go +++ b/ui/browsing/playlistpage.go @@ -99,6 +99,10 @@ func (a *PlaylistPage) Tapped(*fyne.PointEvent) { a.tracklist.UnselectAll() } +func (a *PlaylistPage) SelectAll() { + a.tracklist.SelectAll() +} + func (a *PlaylistPage) onPlayTrackAt(tracknum int) { a.pm.PlayPlaylist(a.playlistID, tracknum) } diff --git a/ui/mainwindow.go b/ui/mainwindow.go index 399ad14..8c08a34 100644 --- a/ui/mainwindow.go +++ b/ui/mainwindow.go @@ -117,6 +117,9 @@ func (m *MainWindow) addShortcuts() { m.Window.Canvas().Focus(s) } }) + m.Canvas().AddShortcut(&fyne.ShortcutSelectAll{}, func(_ fyne.Shortcut) { + m.BrowsingPane.SelectAll() + }) m.Canvas().SetOnTypedKey(func(e *fyne.KeyEvent) { if e.Name == fyne.KeySpace { diff --git a/ui/widgets/tracklist.go b/ui/widgets/tracklist.go index 32fde47..e3eb23f 100644 --- a/ui/widgets/tracklist.go +++ b/ui/widgets/tracklist.go @@ -170,6 +170,11 @@ func (t *Tracklist) SetNowPlaying(trackID string) { t.list.Refresh() } +func (t *Tracklist) SelectAll() { + t.selectionMgr.SelectAll() + t.Refresh() +} + func (t *Tracklist) UnselectAll() { t.selectionMgr.UnselectAll() t.Refresh()