add icons to gear menu

This commit is contained in:
Drew Weymouth
2025-07-01 11:16:06 -07:00
parent dcf3e63238
commit 6c4fbada3d
6 changed files with 59 additions and 42 deletions
+5
View File
@@ -55,6 +55,11 @@ var ResMusicnotesSvg = &fyne.StaticResource{
StaticContent: []byte(
"<?xml version=\"1.0\" encoding=\"utf-8\"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->\n<svg fill=\"#000000\" width=\"800px\" height=\"800px\" viewBox=\"0 0 20 20\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M20 2.5V0L6 2v12.17A3 3 0 0 0 5 14H3a3 3 0 0 0 0 6h2a3 3 0 0 0 3-3V5.71L18 4.3v7.88a3 3 0 0 0-1-.17h-2a3 3 0 0 0 0 6h2a3 3 0 0 0 3-3V2.5z\"/></svg>"),
}
var ResOscilloscopeSvg = &fyne.StaticResource{
StaticName: "oscilloscope.svg",
StaticContent: []byte(
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n\r<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->\n<svg fill=\"#000000\" version=\"1.1\" id=\"Capa_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"800px\" height=\"800px\" viewBox=\"0 0 450 450\" xml:space=\"preserve\" stroke=\"#000000\" stroke-width=\"0.00408328\">\n\r<g id=\"SVGRepo_bgCarrier\" stroke-width=\"0\"/>\n\r<g id=\"SVGRepo_tracerCarrier\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n\r<g id=\"SVGRepo_iconCarrier\"> <g> <path d=\"M376.321,0.195H32.001C14.357,0.195,0,14.547,0,32.185v343.959c0,17.638,14.357,31.989,32.001,31.989h344.326 c17.644,0,32.001-14.352,32.001-31.989V32.185C408.322,14.547,393.964,0.195,376.321,0.195z M354.634,36.609 c7.571,0,13.713,6.144,13.713,13.716s-6.142,13.716-13.713,13.716c-7.578,0-13.719-6.144-13.719-13.716 S347.056,36.609,354.634,36.609z M305.492,36.609c7.578,0,13.725,6.144,13.725,13.716s-6.146,13.716-13.725,13.716 c-7.565,0-13.707-6.144-13.707-13.716S297.926,36.609,305.492,36.609z M371.751,371.569H36.57V98.081h335.188v273.488H371.751z M65.792,245.882c0-2.506,2.033-4.539,4.54-4.539h45.067l17.569-59.055c0.577-1.924,2.344-3.242,4.354-3.242l0,0 c2.01,0,3.783,1.324,4.344,3.257l17.428,59.04h20.607l20.017-95.609c0.452-2.169,2.495-3.683,4.622-3.608 c2.217,0.091,4.038,1.761,4.324,3.957L228.9,304.21l13.01-98.154c0.29-2.122,2.01-3.759,4.144-3.925 c2.211-0.118,4.103,1.183,4.717,3.239l14.321,48.35l3.979-12.129c0.614-1.867,2.353-3.127,4.314-3.127h64.611 c2.506,0,4.539,2.033,4.539,4.54c0,2.506-2.033,4.539-4.539,4.539h-61.324l-7.483,22.821c-0.627,1.892-2.312,3.074-4.386,3.127 c-1.986-0.029-3.724-1.342-4.285-3.25l-12.401-41.866l-14.788,111.571c-0.302,2.258-2.229,3.942-4.498,3.942h-0.012 c-2.282-0.006-4.209-1.696-4.492-3.966l-21.244-165.942l-15.244,72.835c-0.443,2.104-2.297,3.605-4.445,3.605h-27.689 c-2.015,0-3.783-1.324-4.353-3.251l-14.047-47.605l-14.165,47.617c-0.574,1.921-2.341,3.239-4.351,3.239H70.332 C67.826,250.422,65.792,248.389,65.792,245.882z\"/> </g> </g>\n\r</svg>\n"),
}
var ResPeopleSvg = &fyne.StaticResource{
StaticName: "people.svg",
StaticContent: []byte(
+1
View File
@@ -10,6 +10,7 @@ fyne bundle -append -prefix Res icons/publicdomain/heart-filled.svg >> bundled.g
fyne bundle -append -prefix Res icons/publicdomain/heart-outline.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/infinity.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/musicnotes.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/oscilloscope.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/people.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/playlist.svg >> bundled.go
fyne bundle -append -prefix Res icons/publicdomain/playqueue.svg >> bundled.go
+7
View File
@@ -0,0 +1,7 @@
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Transformed by: SVG Repo Mixer Tools -->
<svg fill="#000000" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="800px" height="800px" viewBox="0 0 450 450" xml:space="preserve" stroke="#000000" stroke-width="0.00408328">
<g id="SVGRepo_bgCarrier" stroke-width="0"/>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
<g id="SVGRepo_iconCarrier"> <g> <path d="M376.321,0.195H32.001C14.357,0.195,0,14.547,0,32.185v343.959c0,17.638,14.357,31.989,32.001,31.989h344.326 c17.644,0,32.001-14.352,32.001-31.989V32.185C408.322,14.547,393.964,0.195,376.321,0.195z M354.634,36.609 c7.571,0,13.713,6.144,13.713,13.716s-6.142,13.716-13.713,13.716c-7.578,0-13.719-6.144-13.719-13.716 S347.056,36.609,354.634,36.609z M305.492,36.609c7.578,0,13.725,6.144,13.725,13.716s-6.146,13.716-13.725,13.716 c-7.565,0-13.707-6.144-13.707-13.716S297.926,36.609,305.492,36.609z M371.751,371.569H36.57V98.081h335.188v273.488H371.751z M65.792,245.882c0-2.506,2.033-4.539,4.54-4.539h45.067l17.569-59.055c0.577-1.924,2.344-3.242,4.354-3.242l0,0 c2.01,0,3.783,1.324,4.344,3.257l17.428,59.04h20.607l20.017-95.609c0.452-2.169,2.495-3.683,4.622-3.608 c2.217,0.091,4.038,1.761,4.324,3.957L228.9,304.21l13.01-98.154c0.29-2.122,2.01-3.759,4.144-3.925 c2.211-0.118,4.103,1.183,4.717,3.239l14.321,48.35l3.979-12.129c0.614-1.867,2.353-3.127,4.314-3.127h64.611 c2.506,0,4.539,2.033,4.539,4.54c0,2.506-2.033,4.539-4.539,4.539h-61.324l-7.483,22.821c-0.627,1.892-2.312,3.074-4.386,3.127 c-1.986-0.029-3.724-1.342-4.285-3.25l-12.401-41.866l-14.788,111.571c-0.302,2.258-2.229,3.942-4.498,3.942h-0.012 c-2.282-0.006-4.209-1.696-4.492-3.966l-21.244-165.942l-15.244,72.835c-0.443,2.104-2.297,3.605-4.445,3.605h-27.689 c-2.015,0-3.783-1.324-4.353-3.251l-14.047-47.605l-14.165,47.617c-0.574,1.921-2.341,3.239-4.351,3.239H70.332 C67.826,250.422,65.792,248.389,65.792,245.882z"/> </g> </g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

+6 -4
View File
@@ -140,14 +140,16 @@ func (b *BrowsingPane) ClearHistory() {
b.updateHistoryButtons()
}
func (b *BrowsingPane) AddSettingsMenuItem(label string, action func()) {
b.settingsMenu.Items = append(b.settingsMenu.Items,
fyne.NewMenuItem(label, action))
func (b *BrowsingPane) AddSettingsMenuItem(label string, icon fyne.Resource, action func()) {
item := fyne.NewMenuItem(label, action)
item.Icon = icon
b.settingsMenu.Items = append(b.settingsMenu.Items, item)
}
func (b *BrowsingPane) AddSettingsSubmenu(label string, menu *fyne.Menu) {
func (b *BrowsingPane) AddSettingsSubmenu(label string, icon fyne.Resource, menu *fyne.Menu) {
item := fyne.NewMenuItem(label, nil)
item.ChildMenu = menu
item.Icon = icon
b.settingsMenu.Items = append(b.settingsMenu.Items, item)
}
+20 -19
View File
@@ -16,7 +16,7 @@ import (
"github.com/dweymouth/supersonic/ui/controller"
"github.com/dweymouth/supersonic/ui/dialogs"
"github.com/dweymouth/supersonic/ui/shortcuts"
"github.com/dweymouth/supersonic/ui/theme"
myTheme "github.com/dweymouth/supersonic/ui/theme"
"github.com/dweymouth/supersonic/ui/util"
"fyne.io/fyne/v2"
@@ -24,6 +24,7 @@ import (
"fyne.io/fyne/v2/dialog"
"fyne.io/fyne/v2/driver/desktop"
"fyne.io/fyne/v2/lang"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
@@ -37,7 +38,7 @@ type MainWindow struct {
BottomPanel *BottomPanel
ToastOverlay *ToastOverlay
theme *theme.MyTheme
theme *myTheme.MyTheme
haveSystemTray bool
alreadyConnected bool // tracks if we have already connected to a server before
content *mainWindowContent
@@ -50,9 +51,9 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
m := MainWindow{
App: app,
Window: fyneApp.NewWindow(displayAppName),
theme: theme.NewMyTheme(&app.Config.Theme, app.ThemesDir()),
theme: myTheme.NewMyTheme(&app.Config.Theme, app.ThemesDir()),
}
fynetooltip.SetToolTipTextSizeName(theme.SizeNameSubText)
fynetooltip.SetToolTipTextSizeName(myTheme.SizeNameSubText)
m.theme.NormalFont = app.Config.Application.FontNormalTTF
m.theme.BoldFont = app.Config.Application.FontBoldTTF
@@ -99,16 +100,16 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
m.BrowsingPane.ClearHistory()
m.Controller.PromptForLoginAndConnect()
})
m.BrowsingPane.AddSettingsMenuItem(lang.L("Log Out"), func() { app.ServerManager.Logout(true) })
m.BrowsingPane.AddSettingsMenuItem(lang.L("Switch Servers"), func() { app.ServerManager.Logout(false) })
m.BrowsingPane.AddSettingsMenuItem(lang.L("Rescan Library"), func() { app.ServerManager.Server.RescanLibrary() })
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.AddSettingsMenuItem(lang.L("Rescan Library"), theme.ViewRefreshIcon(), func() { app.ServerManager.Server.RescanLibrary() })
m.BrowsingPane.AddSettingsMenuSeparator()
m.BrowsingPane.AddSettingsSubmenu(lang.L("Visualizations"),
m.BrowsingPane.AddSettingsSubmenu(lang.L("Visualizations"), myTheme.VisualizationIcon,
fyne.NewMenu("", []*fyne.MenuItem{
fyne.NewMenuItem(lang.L("Peak Meter"), m.Controller.ShowPeakMeter),
}...))
m.BrowsingPane.AddSettingsMenuSeparator()
m.BrowsingPane.AddSettingsMenuItem(lang.L("Check for Updates"), func() {
m.BrowsingPane.AddSettingsMenuItem(lang.L("Check for Updates"), theme.DownloadIcon(), func() {
go func() {
if t := app.UpdateChecker.CheckLatestVersionTag(); t != "" && t != app.VersionTag() {
fyne.Do(func() { m.ShowNewVersionDialog(displayAppName, t) })
@@ -121,8 +122,8 @@ func NewMainWindow(fyneApp fyne.App, appName, displayAppName, appVersion string,
}
}()
})
m.BrowsingPane.AddSettingsMenuItem(lang.L("Settings")+"...", m.showSettingsDialog)
m.BrowsingPane.AddSettingsMenuItem(lang.L("About")+"...", m.Controller.ShowAboutDialog)
m.BrowsingPane.AddSettingsMenuItem(lang.L("Settings")+"...", theme.SettingsIcon(), m.showSettingsDialog)
m.BrowsingPane.AddSettingsMenuItem(lang.L("About")+"...", theme.InfoIcon(), m.Controller.ShowAboutDialog)
m.addNavigationButtons()
m.BrowsingPane.DisableNavigationButtons()
m.addShortcuts()
@@ -333,28 +334,28 @@ func (m *MainWindow) ShowWhatsNewDialog() {
}
func (m *MainWindow) addNavigationButtons() {
m.BrowsingPane.AddNavigationButton(theme.NowPlayingIcon, controller.NowPlaying, func() {
m.BrowsingPane.AddNavigationButton(myTheme.NowPlayingIcon, controller.NowPlaying, func() {
m.Router.NavigateTo(controller.NowPlayingRoute())
})
m.BrowsingPane.AddNavigationButton(theme.FavoriteIcon, controller.Favorites, func() {
m.BrowsingPane.AddNavigationButton(myTheme.FavoriteIcon, controller.Favorites, func() {
m.Router.NavigateTo(controller.FavoritesRoute())
})
m.BrowsingPane.AddNavigationButton(theme.AlbumIcon, controller.Albums, func() {
m.BrowsingPane.AddNavigationButton(myTheme.AlbumIcon, controller.Albums, func() {
m.Router.NavigateTo(controller.AlbumsRoute())
})
m.BrowsingPane.AddNavigationButton(theme.ArtistIcon, controller.Artists, func() {
m.BrowsingPane.AddNavigationButton(myTheme.ArtistIcon, controller.Artists, func() {
m.Router.NavigateTo(controller.ArtistsRoute())
})
m.BrowsingPane.AddNavigationButton(theme.GenreIcon, controller.Genres, func() {
m.BrowsingPane.AddNavigationButton(myTheme.GenreIcon, controller.Genres, func() {
m.Router.NavigateTo(controller.GenresRoute())
})
m.BrowsingPane.AddNavigationButton(theme.PlaylistIcon, controller.Playlists, func() {
m.BrowsingPane.AddNavigationButton(myTheme.PlaylistIcon, controller.Playlists, func() {
m.Router.NavigateTo(controller.PlaylistsRoute())
})
m.BrowsingPane.AddNavigationButton(theme.TracksIcon, controller.Tracks, func() {
m.BrowsingPane.AddNavigationButton(myTheme.TracksIcon, controller.Tracks, func() {
m.Router.NavigateTo(controller.TracksRoute())
})
m.radioBtn = m.BrowsingPane.AddNavigationButton(theme.RadioIcon, controller.Radios, func() {
m.radioBtn = m.BrowsingPane.AddNavigationButton(myTheme.RadioIcon, controller.Radios, func() {
m.Router.NavigateTo(controller.RadiosRoute())
})
}
+1
View File
@@ -61,6 +61,7 @@ var (
RepeatIcon fyne.Resource = theme.NewThemedResource(res.ResRepeatSvg)
RepeatOneIcon fyne.Resource = theme.NewThemedResource(res.ResRepeatoneSvg)
SortIcon fyne.Resource = theme.NewThemedResource(res.ResUpdownarrowSvg)
VisualizationIcon fyne.Resource = theme.NewThemedResource(res.ResOscilloscopeSvg)
)
type AppearanceMode string