add about dialog
This commit is contained in:
@@ -16,6 +16,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
appname = "supersonic"
|
appname = "supersonic"
|
||||||
displayName = "Supersonic"
|
displayName = "Supersonic"
|
||||||
|
appVersion = "0.0.1-alpha1"
|
||||||
configFile = "config.toml"
|
configFile = "config.toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -39,7 +40,7 @@ func main() {
|
|||||||
if h <= 1 {
|
if h <= 1 {
|
||||||
h = 800
|
h = 800
|
||||||
}
|
}
|
||||||
mainWindow := ui.NewMainWindow(fyneApp, displayName, myApp, fyne.NewSize(w, h))
|
mainWindow := ui.NewMainWindow(fyneApp, displayName, appVersion, myApp, fyne.NewSize(w, h))
|
||||||
|
|
||||||
// TODO: There is some race condition with running this initial startup
|
// TODO: There is some race condition with running this initial startup
|
||||||
// task immediately before showing and running the window/Fyne main loop where
|
// task immediately before showing and running the window/Fyne main loop where
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -26,3 +26,7 @@ fyne bundle -append -prefix Res icons/freepik/theatermasks.png >> bundled.go
|
|||||||
fyne bundle -append -prefix Res icons/freepik/theatermasks-invert.png >> bundled.go
|
fyne bundle -append -prefix Res icons/freepik/theatermasks-invert.png >> bundled.go
|
||||||
fyne bundle -append -prefix Res icons/publicdomain/shuffle.svg >> bundled.go
|
fyne bundle -append -prefix Res icons/publicdomain/shuffle.svg >> bundled.go
|
||||||
fyne bundle -append -prefix Res icons/publicdomain/shuffle-invert.svg >> bundled.go
|
fyne bundle -append -prefix Res icons/publicdomain/shuffle-invert.svg >> bundled.go
|
||||||
|
|
||||||
|
fyne bundle -append -prefix Res ../LICENSE >> bundled.go
|
||||||
|
fyne bundle -append -prefix Res licenses/BSDLICENSE >> bundled.go
|
||||||
|
fyne bundle -append -prefix Res licenses/MITLICENSE >> bundled.go
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (C) 2018 Fyne.io developers (see AUTHORS)
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of Fyne.io nor the names of its contributors may be
|
||||||
|
used to endorse or promote products derived from this software without
|
||||||
|
specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
|
||||||
|
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
@@ -22,6 +22,7 @@ type Controller struct {
|
|||||||
// if not nil, this popup should be hidden when escape is pressed
|
// if not nil, this popup should be hidden when escape is pressed
|
||||||
EscapablePopUp *widget.PopUp
|
EscapablePopUp *widget.PopUp
|
||||||
|
|
||||||
|
AppVersion string
|
||||||
MainWindow fyne.Window
|
MainWindow fyne.Window
|
||||||
App *backend.App
|
App *backend.App
|
||||||
NavHandler NavigationHandler
|
NavHandler NavigationHandler
|
||||||
@@ -206,6 +207,14 @@ func (m *Controller) PromptForLoginAndConnect() {
|
|||||||
pop.Show()
|
pop.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Controller) ShowAboutDialog() {
|
||||||
|
dlg := dialogs.NewAboutDialog(c.AppVersion)
|
||||||
|
pop := widget.NewModalPopUp(dlg, c.MainWindow.Canvas())
|
||||||
|
dlg.OnDismiss = pop.Hide
|
||||||
|
c.ClosePopUpOnEscape(pop)
|
||||||
|
pop.Show()
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Controller) trySetPasswordAndConnectToServer(server *backend.ServerConfig, password string) error {
|
func (c *Controller) trySetPasswordAndConnectToServer(server *backend.ServerConfig, password string) error {
|
||||||
if err := c.App.ServerManager.SetServerPassword(server, password); err != nil {
|
if err := c.App.ServerManager.SetServerPassword(server, password); err != nil {
|
||||||
log.Printf("error setting keyring credentials: %v", err)
|
log.Printf("error setting keyring credentials: %v", err)
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
package dialogs
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/url"
|
||||||
|
"supersonic/res"
|
||||||
|
"supersonic/ui/layouts"
|
||||||
|
|
||||||
|
"fyne.io/fyne/v2"
|
||||||
|
"fyne.io/fyne/v2/canvas"
|
||||||
|
"fyne.io/fyne/v2/container"
|
||||||
|
"fyne.io/fyne/v2/layout"
|
||||||
|
"fyne.io/fyne/v2/theme"
|
||||||
|
"fyne.io/fyne/v2/widget"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AboutDialog struct {
|
||||||
|
widget.BaseWidget
|
||||||
|
|
||||||
|
OnDismiss func()
|
||||||
|
|
||||||
|
content fyne.CanvasObject
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAboutDialog(version string) *AboutDialog {
|
||||||
|
a := &AboutDialog{}
|
||||||
|
a.ExtendBaseWidget(a)
|
||||||
|
|
||||||
|
a.content = container.NewVBox(
|
||||||
|
container.NewAppTabs(
|
||||||
|
container.NewTabItem("Supersonic", a.buildMainTabContainer(version)),
|
||||||
|
container.NewTabItem("Credits", a.buildCreditsContainer()),
|
||||||
|
container.NewTabItem("GPL v3", container.NewScroll(a.licenseLabel(res.ResLICENSE))),
|
||||||
|
container.NewTabItem("BSD-3-Clause", container.NewScroll(a.licenseLabel(res.ResBSDLICENSE))),
|
||||||
|
container.NewTabItem("MIT", container.NewScroll(a.licenseLabel(res.ResMITLICENSE))),
|
||||||
|
),
|
||||||
|
widget.NewSeparator(),
|
||||||
|
container.NewHBox(
|
||||||
|
layout.NewSpacer(),
|
||||||
|
widget.NewButton("Close", func() {
|
||||||
|
if a.OnDismiss != nil {
|
||||||
|
a.OnDismiss()
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AboutDialog) MinSize() fyne.Size {
|
||||||
|
return fyne.NewSize(420, a.BaseWidget.MinSize().Height)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AboutDialog) buildMainTabContainer(version string) *fyne.Container {
|
||||||
|
iconImage := canvas.NewImageFromResource(res.ResAppicon250Png)
|
||||||
|
iconImage.FillMode = canvas.ImageFillContain
|
||||||
|
iconImage.SetMinSize(fyne.NewSize(64, 64))
|
||||||
|
title := widget.NewRichTextWithText("Supersonic")
|
||||||
|
title.Segments[0].(*widget.TextSegment).Style.TextStyle.Bold = true
|
||||||
|
title.Segments[0].(*widget.TextSegment).Style.SizeName = theme.SizeNameSubHeadingText
|
||||||
|
title.Segments[0].(*widget.TextSegment).Style.Alignment = fyne.TextAlignCenter
|
||||||
|
versionLbl := newCenterAlignLabel(fmt.Sprintf("version %s", version))
|
||||||
|
copyright := newCenterAlignLabel("Copyright © 2022–2023 Drew Weymouth and contributors")
|
||||||
|
license := widget.NewRichTextWithText("GNU General Public License version 3 (GPL v3)")
|
||||||
|
ts := license.Segments[0].(*widget.TextSegment)
|
||||||
|
ts.Style.TextStyle.Bold = true
|
||||||
|
ts.Style.Alignment = fyne.TextAlignCenter
|
||||||
|
ghUrl, _ := url.Parse("https://github.com/dweymouth/supersonic")
|
||||||
|
github := container.NewCenter(widget.NewHyperlink("Github page", ghUrl))
|
||||||
|
|
||||||
|
return container.New(&layouts.CenterPadLayout{PadTopBottom: 10},
|
||||||
|
container.NewVBox(iconImage,
|
||||||
|
container.New(&layouts.VboxCustomPadding{ExtraPad: -10}, title, versionLbl, copyright, license, github)))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AboutDialog) licenseLabel(res *fyne.StaticResource) *widget.Label {
|
||||||
|
str := string(res.StaticContent)
|
||||||
|
lbl := widget.NewLabel(str)
|
||||||
|
lbl.Wrapping = fyne.TextWrapWord
|
||||||
|
return lbl
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AboutDialog) buildCreditsContainer() fyne.CanvasObject {
|
||||||
|
fyneURL, _ := url.Parse("https://fyne.io")
|
||||||
|
goSubsonicURL, _ := url.Parse("https://github.com/delucks/go-subsonic")
|
||||||
|
goTomlURL, _ := url.Parse("https://github.com/pelletier/go-toml")
|
||||||
|
freepikURL, _ := url.Parse("https://www.flaticon.com/authors/freepik")
|
||||||
|
appIconCredit := widget.NewLabel("The Supersonic app icon is a derivative of a work created by Piotr Siedlecki and placed in the public domain.")
|
||||||
|
appIconCredit.Wrapping = fyne.TextWrapWord
|
||||||
|
return container.New(&layouts.VboxCustomPadding{ExtraPad: -10},
|
||||||
|
widget.NewLabel("Major frameworks and modules used in this application include:"),
|
||||||
|
container.NewHBox(widget.NewHyperlink("Fyne toolkit", fyneURL), widget.NewLabel("BSD 3-Clause License")),
|
||||||
|
container.NewHBox(widget.NewHyperlink("go-subsonic", goSubsonicURL), widget.NewLabel("GPL v3 License")),
|
||||||
|
container.NewHBox(widget.NewHyperlink("go-toml", goTomlURL), widget.NewLabel("MIT License")),
|
||||||
|
appIconCredit,
|
||||||
|
container.NewHBox(widget.NewLabel("Additional icons by:"), widget.NewHyperlink("Freepik on flaticon.com", freepikURL)),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AboutDialog) CreateRenderer() fyne.WidgetRenderer {
|
||||||
|
return widget.NewSimpleRenderer(a.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
func newCenterAlignLabel(text string) *widget.Label {
|
||||||
|
lbl := widget.NewLabel(text)
|
||||||
|
lbl.Alignment = fyne.TextAlignCenter
|
||||||
|
return lbl
|
||||||
|
}
|
||||||
+3
-1
@@ -47,7 +47,7 @@ var (
|
|||||||
HomePage = controller.AlbumsRoute()
|
HomePage = controller.AlbumsRoute()
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App, size fyne.Size) MainWindow {
|
func NewMainWindow(fyneApp fyne.App, appName, appVersion string, app *backend.App, size fyne.Size) MainWindow {
|
||||||
m := MainWindow{
|
m := MainWindow{
|
||||||
App: app,
|
App: app,
|
||||||
Window: fyneApp.NewWindow(appName),
|
Window: fyneApp.NewWindow(appName),
|
||||||
@@ -55,6 +55,7 @@ func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App, size fyne
|
|||||||
}
|
}
|
||||||
|
|
||||||
m.Controller = &controller.Controller{
|
m.Controller = &controller.Controller{
|
||||||
|
AppVersion: appVersion,
|
||||||
MainWindow: m.Window,
|
MainWindow: m.Window,
|
||||||
App: app,
|
App: app,
|
||||||
}
|
}
|
||||||
@@ -84,6 +85,7 @@ func NewMainWindow(fyneApp fyne.App, appName string, app *backend.App, size fyne
|
|||||||
m.Controller.PromptForLoginAndConnect()
|
m.Controller.PromptForLoginAndConnect()
|
||||||
})
|
})
|
||||||
m.BrowsingPane.AddSettingsMenuItem("Log Out", app.ServerManager.Logout)
|
m.BrowsingPane.AddSettingsMenuItem("Log Out", app.ServerManager.Logout)
|
||||||
|
m.BrowsingPane.AddSettingsMenuItem("About...", m.Controller.ShowAboutDialog)
|
||||||
m.addNavigationButtons()
|
m.addNavigationButtons()
|
||||||
m.BrowsingPane.DisableNavigationButtons()
|
m.BrowsingPane.DisableNavigationButtons()
|
||||||
m.addShortcuts()
|
m.addShortcuts()
|
||||||
|
|||||||
Reference in New Issue
Block a user