vm

package
v0.0.0-...-9384ad0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 29, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PCPlayPause playerCmd = 2<<iota - 1
	PCStop
	PCNext
	PCPrev
)

Variables

This section is empty.

Functions

func BestURL

func BestURL(images []types.Image, targetPx int) string

Types

type App

type App struct {
	State         *reactive.Prop[AppState]
	Auth          *Auth
	Player        *Player
	Nav           *reactive.Prop[NavState]
	Client        types.Client
	Images        *ImageService
	LikedTracks   *TrackListVM
	SearchResults *TrackListVM
}

func New

func New(ctx context.Context, auth types.Authenticator, clientFactory func(context.Context, types.Session) types.Client, db *badger.DB) *App

type AppState

type AppState string
const (
	StateAuth AppState = "auth"
	StateMain AppState = "main"
)

func (AppState) Index

func (m AppState) Index() int

func (AppState) String

func (m AppState) String() string

type Auth

type Auth struct {
	State    *reactive.Prop[AuthState]
	Error    *reactive.Prop[error]
	LoginCmd *reactive.CtxCommand
	Session  types.Session
	// contains filtered or unexported fields
}

type AuthState

type AuthState string
const (
	ASChecking    AuthState = "Checking"
	ASNeedsLogin  AuthState = "Needs login"
	ASAuthorizing AuthState = "Authorizing"
	ASReady       AuthState = "Ready"
	ASAuthError   AuthState = "Authorization error"
)

type ImageService

type ImageService struct {
	// contains filtered or unexported fields
}

func NewImageService

func NewImageService(ctx context.Context, db *badger.DB) *ImageService

func (*ImageService) Close

func (s *ImageService) Close()

func (*ImageService) Load

func (s *ImageService) Load(url string, onLoad func(*qt.QPixmap))

func (*ImageService) LoadCover

func (s *ImageService) LoadCover(album *metadatapb.Album, targetPx int, onLoad func(*qt.QPixmap))
type NavState string
const (
	NavHome        NavState = "Home"
	NavSearch      NavState = "Search"
	NavLikedTracks NavState = "Liked Songs"
)
func NavStateFrom(s string) NavState
func (s NavState) String() string

type Player

type Player struct {
	Current   *reactive.CmpProp[*metadatapb.Track, string]
	IsPlaying *reactive.Prop[bool]
	Progress  *reactive.Prop[int64]
	Volume    *reactive.Prop[uint32]
	CanNext   *reactive.Prop[bool]

	PlayerCmd *reactive.ECommand[playerCmd]
	// contains filtered or unexported fields
}

func (*Player) BindClient

func (p *Player) BindClient(ctx context.Context, c types.Client)

func (*Player) Client

func (p *Player) Client() types.Client

func (*Player) Exec

func (p *Player) Exec(pc playerCmd) func()

func (*Player) SeekPos

func (p *Player) SeekPos(posMs int64)

type TrackListVM

type TrackListVM struct {
	// contains filtered or unexported fields
}

func NewTrackListVM

func NewTrackListVM(lru *cache.LRU[*metadatapb.Track]) *TrackListVM

func (*TrackListVM) AddBatch

func (vm *TrackListVM) AddBatch(tracks []*metadatapb.Track)

func (*TrackListVM) AddBatchGuarded

func (vm *TrackListVM) AddBatchGuarded(searchID uint64, tracks []*metadatapb.Track)

AddBatchGuarded is like AddBatch but only writes if the provided searchID matches the current searchID, discarding results from superseded searches.

func (*TrackListVM) Clear

func (vm *TrackListVM) Clear()

func (*TrackListVM) CurrentSearchID

func (vm *TrackListVM) CurrentSearchID() uint64

CurrentSearchID returns the current search ID without incrementing.

func (*TrackListVM) Get

func (vm *TrackListVM) Get(index int) (**metadatapb.Track, bool)

func (*TrackListVM) LastScrollY

func (vm *TrackListVM) LastScrollY() int

func (*TrackListVM) Len

func (vm *TrackListVM) Len() int

func (*TrackListVM) LoadAsync

func (vm *TrackListVM) LoadAsync(index int, cb func(*metadatapb.Track))

func (*TrackListVM) NewSearchID

func (vm *TrackListVM) NewSearchID() uint64

NewSearchID increments and returns a new search ID. Goroutines should capture this ID and only write results if it matches CurrentSearchID.

func (*TrackListVM) OnLengthChanged

func (vm *TrackListVM) OnLengthChanged(cb func(int)) func()

func (*TrackListVM) SaveScrollY

func (vm *TrackListVM) SaveScrollY(y int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL