add library switcher submenu to gear menu
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -3,6 +3,7 @@
|
||||
fyne bundle -package res -prefix Res appicon-256.png > bundled.go
|
||||
fyne bundle -append -prefix Res icons/coreui/playlist-add-next.svg >> bundled.go
|
||||
fyne bundle -append -prefix Res icons/freepik/playbutton.png >> bundled.go
|
||||
fyne bundle -append -prefix Res icons/majesticons/library.svg >> bundled.go
|
||||
fyne bundle -append -prefix Res icons/publicdomain/cast.svg >> bundled.go
|
||||
fyne bundle -append -prefix Res icons/publicdomain/disc.svg >> bundled.go
|
||||
fyne bundle -append -prefix Res icons/publicdomain/headphones.svg >> bundled.go
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
These icons are from the Majesticons Solid Interface Icons collection by halfmage on svgrepo.com and are available under the MIT license
|
||||
|
||||
https://www.svgrepo.com/page/licensing/#MIT
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="none"><path fill="#000000" fill-rule="evenodd" d="M11.514 3.126a1 1 0 0 1 .972 0l9 5A1 1 0 0 1 21 10v9a1 1 0 1 1 0 2H3a1 1 0 1 1 0-2v-9a1 1 0 0 1-.486-1.874l9-5zM9 13a1 1 0 1 0-2 0v3a1 1 0 1 0 2 0v-3zm4 0a1 1 0 1 0-2 0v3a1 1 0 1 0 2 0v-3zm4 0a1 1 0 1 0-2 0v3a1 1 0 1 0 2 0v-3z" clip-rule="evenodd"/></svg>
|
||||
|
After Width: | Height: | Size: 519 B |
@@ -15,6 +15,7 @@
|
||||
"Albums": "Albums",
|
||||
"albums": "albums",
|
||||
"All": "All",
|
||||
"All Libraries": "All Libraries",
|
||||
"All Tracks": "All Tracks",
|
||||
"Allow multiple app instances": "Allow multiple app instances",
|
||||
"Alt. URL": "Alt. URL",
|
||||
@@ -182,6 +183,7 @@
|
||||
"Search page": "Search page",
|
||||
"Search playlists or new playlist name": "Search playlists or new playlist name",
|
||||
"sec": "sec",
|
||||
"Select Library": "Select Library",
|
||||
"selected": "selected",
|
||||
"Send playback statistics to server": "Send playback statistics to server",
|
||||
"Server": "Server",
|
||||
|
||||
@@ -153,6 +153,14 @@ func (b *BrowsingPane) AddSettingsSubmenu(label string, icon fyne.Resource, menu
|
||||
b.settingsMenu.Items = append(b.settingsMenu.Items, item)
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) SetSubmenuForMenuItem(label string, submenu *fyne.Menu) {
|
||||
for _, item := range b.settingsMenu.Items {
|
||||
if item.Label == label {
|
||||
item.ChildMenu = submenu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (b *BrowsingPane) AddSettingsMenuSeparator() {
|
||||
b.settingsMenu.Items = append(b.settingsMenu.Items,
|
||||
fyne.NewMenuItemSeparator())
|
||||
|
||||
+49
-1
@@ -43,8 +43,11 @@ type MainWindow struct {
|
||||
alreadyConnected bool // tracks if we have already connected to a server before
|
||||
content *mainWindowContent
|
||||
|
||||
// needs to bes shown/hidden when switching between servers based on whether they support radio
|
||||
// needs to be shown/hidden when switching between servers based on whether they support radio
|
||||
radioBtn fyne.CanvasObject
|
||||
|
||||
// updated when changing servers or libraries
|
||||
librarySubmenu *fyne.Menu
|
||||
}
|
||||
|
||||
func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string, app *backend.App) MainWindow {
|
||||
@@ -102,6 +105,8 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
|
||||
})
|
||||
m.BrowsingPane.AddSettingsMenuItem(lang.L("Log Out"), theme.LogoutIcon(), func() { app.ServerManager.Logout(true) })
|
||||
m.BrowsingPane.AddSettingsMenuItem(lang.L("Switch Servers"), theme.LoginIcon(), func() { app.ServerManager.Logout(false) })
|
||||
m.BrowsingPane.AddSettingsSubmenu(lang.L("Select Library"), myTheme.LibraryIcon, fyne.NewMenu("",
|
||||
fyne.NewMenuItem(lang.L("All Libraries"), func() { /* dummy - will get replaced on server login */ })))
|
||||
m.BrowsingPane.AddSettingsMenuItem(lang.L("Rescan Library"), theme.ViewRefreshIcon(), func() { app.ServerManager.Server.RescanLibrary() })
|
||||
m.BrowsingPane.AddSettingsMenuSeparator()
|
||||
m.BrowsingPane.AddSettingsSubmenu(lang.L("Visualizations"), myTheme.VisualizationIcon,
|
||||
@@ -229,6 +234,49 @@ func (m *MainWindow) RunOnServerConnectedTasks(app *backend.App, displayAppName
|
||||
}()
|
||||
}
|
||||
|
||||
doSetLibrary := func(libraryID string, menuIdx int) {
|
||||
fyne.Do(func() {
|
||||
m.App.ServerManager.Server.SetLibrary(libraryID)
|
||||
// Pages in the history could contain content
|
||||
// outside the new library, so clear history
|
||||
m.BrowsingPane.ClearHistory()
|
||||
// ... and reload current page for the same reason
|
||||
m.BrowsingPane.Reload()
|
||||
// check only the menu item for the new library
|
||||
for i, menuItem := range m.librarySubmenu.Items {
|
||||
menuItem.Checked = (i == menuIdx)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
libraries, err := app.ServerManager.Server.GetLibraries()
|
||||
if err != nil {
|
||||
log.Printf("error loading server libraries: %s", err.Error())
|
||||
}
|
||||
libraryMenu := fyne.NewMenu("")
|
||||
libraryMenuItemOffset := 0
|
||||
if len(libraries) != 1 {
|
||||
// If there is exactly one library in the list,
|
||||
// we just want to have one menu entry with that library's name.
|
||||
// Otherwise, add the "All Libraries" menu item at the top.
|
||||
libraryMenu.Items = append(libraryMenu.Items,
|
||||
fyne.NewMenuItem(lang.L("All Libraries"), func() {
|
||||
doSetLibrary("", 0)
|
||||
}))
|
||||
libraryMenuItemOffset = 1
|
||||
}
|
||||
for i, l := range libraries {
|
||||
_l := l
|
||||
_i := i + libraryMenuItemOffset
|
||||
libraryMenu.Items = append(libraryMenu.Items,
|
||||
fyne.NewMenuItem(_l.Name, func() {
|
||||
doSetLibrary(_l.ID, _i)
|
||||
}))
|
||||
}
|
||||
m.librarySubmenu = libraryMenu
|
||||
m.librarySubmenu.Items[0].Checked = true
|
||||
m.BrowsingPane.SetSubmenuForMenuItem(lang.L("Select Library"), libraryMenu)
|
||||
|
||||
fyne.Do(func() {
|
||||
m.BrowsingPane.EnableNavigationButtons()
|
||||
m.Router.NavigateTo(m.StartupPage())
|
||||
|
||||
@@ -62,6 +62,7 @@ var (
|
||||
RepeatOneIcon fyne.Resource = theme.NewThemedResource(res.ResRepeatoneSvg)
|
||||
SortIcon fyne.Resource = theme.NewThemedResource(res.ResUpdownarrowSvg)
|
||||
VisualizationIcon fyne.Resource = theme.NewThemedResource(res.ResOscilloscopeSvg)
|
||||
LibraryIcon fyne.Resource = theme.NewThemedResource(res.ResLibrarySvg)
|
||||
)
|
||||
|
||||
type AppearanceMode string
|
||||
|
||||
Reference in New Issue
Block a user