add TracksPage
This commit is contained in:
@@ -55,6 +55,10 @@ type PlaylistPageConfig struct {
|
|||||||
TracklistColumns []string
|
TracklistColumns []string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type TracksPageConfig struct {
|
||||||
|
TracklistColumns []string
|
||||||
|
}
|
||||||
|
|
||||||
type LocalPlaybackConfig struct {
|
type LocalPlaybackConfig struct {
|
||||||
AudioDeviceName string
|
AudioDeviceName string
|
||||||
AudioExclusive bool
|
AudioExclusive bool
|
||||||
@@ -83,6 +87,7 @@ type Config struct {
|
|||||||
FavoritesPage FavoritesPageConfig
|
FavoritesPage FavoritesPageConfig
|
||||||
NowPlayingPage NowPlayingPageConfig
|
NowPlayingPage NowPlayingPageConfig
|
||||||
PlaylistPage PlaylistPageConfig
|
PlaylistPage PlaylistPageConfig
|
||||||
|
TracksPage TracksPageConfig
|
||||||
LocalPlayback LocalPlaybackConfig
|
LocalPlayback LocalPlaybackConfig
|
||||||
Scrobbling ScrobbleConfig
|
Scrobbling ScrobbleConfig
|
||||||
ReplayGain ReplayGainConfig
|
ReplayGain ReplayGainConfig
|
||||||
@@ -117,6 +122,9 @@ func DefaultConfig(appVersionTag string) *Config {
|
|||||||
PlaylistPage: PlaylistPageConfig{
|
PlaylistPage: PlaylistPageConfig{
|
||||||
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
},
|
},
|
||||||
|
TracksPage: TracksPageConfig{
|
||||||
|
TracklistColumns: []string{"Artist", "Album", "Time", "Plays"},
|
||||||
|
},
|
||||||
LocalPlayback: LocalPlaybackConfig{
|
LocalPlayback: LocalPlaybackConfig{
|
||||||
// "auto" is the name to pass to MPV for autoselecting the output device
|
// "auto" is the name to pass to MPV for autoselecting the output device
|
||||||
AudioDeviceName: "auto",
|
AudioDeviceName: "auto",
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ func (r Router) CreatePage(rte controller.Route) Page {
|
|||||||
return NewPlaylistPage(rte.Arg, &r.App.Config.PlaylistPage, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.ImageManager)
|
return NewPlaylistPage(rte.Arg, &r.App.Config.PlaylistPage, r.Controller, r.App.ServerManager, r.App.PlaybackManager, r.App.ImageManager)
|
||||||
case controller.Playlists:
|
case controller.Playlists:
|
||||||
return NewPlaylistsPage(r.Controller, r.App.ServerManager)
|
return NewPlaylistsPage(r.Controller, r.App.ServerManager)
|
||||||
|
case controller.Tracks:
|
||||||
|
return NewTracksPage(r.Controller, &r.App.Config.TracksPage, r.App.LibraryManager)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package browsing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"supersonic/backend"
|
||||||
|
"supersonic/res"
|
||||||
|
"supersonic/ui/controller"
|
||||||
|
"supersonic/ui/layouts"
|
||||||
|
"supersonic/ui/widgets"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TracksPage struct {
|
||||||
|
widget.BaseWidget
|
||||||
|
|
||||||
|
tracksPageState
|
||||||
|
|
||||||
|
title *widget.RichText
|
||||||
|
tracklist *widgets.Tracklist
|
||||||
|
loader widgets.TracklistLoader
|
||||||
|
playRandom *widget.Button
|
||||||
|
container *fyne.Container
|
||||||
|
}
|
||||||
|
|
||||||
|
type tracksPageState struct {
|
||||||
|
contr *controller.Controller
|
||||||
|
conf *backend.TracksPageConfig
|
||||||
|
lm *backend.LibraryManager
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewTracksPage(contr *controller.Controller, conf *backend.TracksPageConfig, lm *backend.LibraryManager) *TracksPage {
|
||||||
|
t := &TracksPage{tracksPageState: tracksPageState{contr: contr, conf: conf, lm: lm}}
|
||||||
|
t.ExtendBaseWidget(t)
|
||||||
|
t.tracklist = widgets.NewTracklist(nil)
|
||||||
|
t.tracklist.AutoNumber = true
|
||||||
|
t.tracklist.SetVisibleColumns(conf.TracklistColumns)
|
||||||
|
contr.ConnectTracklistActions(t.tracklist)
|
||||||
|
t.title = widget.NewRichTextWithText("All Tracks")
|
||||||
|
t.title.Segments[0].(*widget.TextSegment).Style.SizeName = widget.RichTextStyleHeading.SizeName
|
||||||
|
t.playRandom = widget.NewButtonWithIcon("Play random", res.ResShuffleInvertSvg, t.playRandomSongs)
|
||||||
|
t.createContainer()
|
||||||
|
t.Reload()
|
||||||
|
return t
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) createContainer() {
|
||||||
|
playRandomVbox := container.NewVBox(layout.NewSpacer(), t.playRandom, layout.NewSpacer())
|
||||||
|
topRow := container.NewHBox(t.title, playRandomVbox, layout.NewSpacer()) //searchVbox, util.NewHSpace(15))
|
||||||
|
t.container = container.New(&layouts.MaxPadLayout{PadLeft: 15, PadRight: 15, PadTop: 5, PadBottom: 15},
|
||||||
|
container.NewBorder(topRow, nil, nil, nil, t.tracklist))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) Route() controller.Route {
|
||||||
|
return controller.TracksRoute()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) Reload() {
|
||||||
|
t.tracklist.Clear()
|
||||||
|
iter := t.lm.AllTracksIterator()
|
||||||
|
// loads asynchronously
|
||||||
|
t.loader = widgets.NewTracklistLoader(t.tracklist, iter)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) CreateRenderer() fyne.WidgetRenderer {
|
||||||
|
return widget.NewSimpleRenderer(t.container)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) Save() SavedPage {
|
||||||
|
state := t.tracksPageState
|
||||||
|
return &state
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *tracksPageState) Restore() Page {
|
||||||
|
return NewTracksPage(s.contr, s.conf, s.lm)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TracksPage) playRandomSongs() {
|
||||||
|
t.contr.App.PlaybackManager.PlayRandomSongs("")
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ const (
|
|||||||
NowPlaying
|
NowPlaying
|
||||||
Playlist
|
Playlist
|
||||||
Playlists
|
Playlists
|
||||||
|
Tracks
|
||||||
)
|
)
|
||||||
|
|
||||||
type Route struct {
|
type Route struct {
|
||||||
@@ -52,6 +53,10 @@ func PlaylistsRoute() Route {
|
|||||||
return Route{Page: Playlists}
|
return Route{Page: Playlists}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TracksRoute() Route {
|
||||||
|
return Route{Page: Tracks}
|
||||||
|
}
|
||||||
|
|
||||||
func ArtistsRoute() Route {
|
func ArtistsRoute() Route {
|
||||||
return Route{Page: Artists}
|
return Route{Page: Artists}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-1
@@ -26,9 +26,10 @@ var (
|
|||||||
ShortcutNavFour = desktop.CustomShortcut{KeyName: fyne.Key4, Modifier: os.ControlModifier}
|
ShortcutNavFour = desktop.CustomShortcut{KeyName: fyne.Key4, Modifier: os.ControlModifier}
|
||||||
ShortcutNavFive = desktop.CustomShortcut{KeyName: fyne.Key5, Modifier: os.ControlModifier}
|
ShortcutNavFive = desktop.CustomShortcut{KeyName: fyne.Key5, Modifier: os.ControlModifier}
|
||||||
ShortcutNavSix = desktop.CustomShortcut{KeyName: fyne.Key6, Modifier: os.ControlModifier}
|
ShortcutNavSix = desktop.CustomShortcut{KeyName: fyne.Key6, Modifier: os.ControlModifier}
|
||||||
|
ShortcutNavSeven = desktop.CustomShortcut{KeyName: fyne.Key7, Modifier: os.ControlModifier}
|
||||||
|
|
||||||
NavShortcuts = []desktop.CustomShortcut{ShortcutNavOne, ShortcutNavTwo, ShortcutNavThree,
|
NavShortcuts = []desktop.CustomShortcut{ShortcutNavOne, ShortcutNavTwo, ShortcutNavThree,
|
||||||
ShortcutNavFour, ShortcutNavFive, ShortcutNavSix}
|
ShortcutNavFour, ShortcutNavFive, ShortcutNavSix, ShortcutNavSeven}
|
||||||
)
|
)
|
||||||
|
|
||||||
type MainWindow struct {
|
type MainWindow struct {
|
||||||
@@ -187,6 +188,9 @@ func (m *MainWindow) addNavigationButtons() {
|
|||||||
m.BrowsingPane.AddNavigationButton(res.ResPlaylistInvertPng, func() {
|
m.BrowsingPane.AddNavigationButton(res.ResPlaylistInvertPng, func() {
|
||||||
m.Router.NavigateTo(controller.PlaylistsRoute())
|
m.Router.NavigateTo(controller.PlaylistsRoute())
|
||||||
})
|
})
|
||||||
|
m.BrowsingPane.AddNavigationButton(res.ResMusicnotesInvertPng, func() {
|
||||||
|
m.Router.NavigateTo(controller.TracksRoute())
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MainWindow) addShortcuts() {
|
func (m *MainWindow) addShortcuts() {
|
||||||
|
|||||||
Reference in New Issue
Block a user