License button to open LICENSE file

This commit is contained in:
Michal Horejsek
2020-12-03 14:54:58 +01:00
committed by Jakub Cuth
parent 8515f6e6ac
commit f295d03641
8 changed files with 81 additions and 1 deletions

View File

@ -102,7 +102,7 @@ Item {
Row { Row {
anchors.left : parent.left anchors.left : parent.left
Rectangle { height: Style.dialog.spacing; width: (wrapper.width- credits.width - release.width - sepaCreditsRelease.width)/2; color: "transparent"} Rectangle { height: Style.dialog.spacing; width: (wrapper.width - credits.width - licenseFile.width - release.width - sepaCreditsRelease.width)/2; color: "transparent"}
ClickIconText { ClickIconText {
id:credits id:credits
@ -114,6 +114,20 @@ Item {
onClicked : winMain.dialogCredits.show() onClicked : winMain.dialogCredits.show()
} }
Rectangle {id: sepaLicenseFile ; height: Style.dialog.spacing; width: Style.main.dummy; color: "transparent"}
ClickIconText {
id:licenseFile
iconText : ""
text : qsTr("License", "link to click on to view license file")
textColor : Style.main.textDisabled
fontSize : Style.main.fontSize
textUnderline : true
onClicked : {
go.openLicenseFile()
}
}
Rectangle {id: sepaCreditsRelease ; height: Style.dialog.spacing; width: Style.main.dummy; color: "transparent"} Rectangle {id: sepaCreditsRelease ; height: Style.dialog.spacing; width: Style.main.dummy; color: "transparent"}
ClickIconText { ClickIconText {

View File

@ -106,6 +106,20 @@ Item {
} }
} }
Text {
id: licenseFile
text : qsTr("License", "link to click on to open license file")
color : Style.main.textDisabled
font.pointSize: Style.main.fontSize * Style.pt
font.underline: true
MouseArea {
anchors.fill: parent
onClicked : {
go.openLicenseFile()
}
cursorShape: Qt.PointingHandCursor
}
}
Text { Text {
id: releaseNotes id: releaseNotes

View File

@ -433,6 +433,10 @@ func (f *FrontendQt) resetSource() {
} }
} }
func (f *FrontendQt) openLicenseFile() {
go open.Run(f.config.GetLicenseFilePath())
}
// getLocalVersionInfo is identical to bridge. // getLocalVersionInfo is identical to bridge.
func (f *FrontendQt) getLocalVersionInfo() { func (f *FrontendQt) getLocalVersionInfo() {
defer f.Qml.ProcessFinished() defer f.Qml.ProcessFinished()

View File

@ -73,6 +73,7 @@ type GoQMLInterface struct {
_ func(okay bool) `signal:"importStructuresLoadFinished"` _ func(okay bool) `signal:"importStructuresLoadFinished"`
_ func() `signal:"openManual"` _ func() `signal:"openManual"`
_ func(showMessage bool) `signal:"runCheckVersion"` _ func(showMessage bool) `signal:"runCheckVersion"`
_ func() `slot:"openLicenseFile"`
_ func() `slot:"getLocalVersionInfo"` _ func() `slot:"getLocalVersionInfo"`
_ func() `slot:"loadImportReports"` _ func() `slot:"loadImportReports"`
@ -167,6 +168,7 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
s.SetIsRestarting(false) s.SetIsRestarting(false)
s.SetProgramTitle(f.programName) s.SetProgramTitle(f.programName)
s.ConnectOpenLicenseFile(f.openLicenseFile)
s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo) s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo)
s.ConnectIsNewVersionAvailable(f.isNewVersionAvailable) s.ConnectIsNewVersionAvailable(f.isNewVersionAvailable)
s.ConnectGetBackendVersion(func() string { s.ConnectGetBackendVersion(func() string {

View File

@ -415,6 +415,10 @@ func (s *FrontendQt) isNewVersionAvailable(showMessage bool) {
}() }()
} }
func (s *FrontendQt) openLicenseFile() {
go open.Run(s.config.GetLicenseFilePath())
}
func (s *FrontendQt) getLocalVersionInfo() { func (s *FrontendQt) getLocalVersionInfo() {
defer s.Qml.ProcessFinished() defer s.Qml.ProcessFinished()
localVersion := s.updates.GetLocalVersion() localVersion := s.updates.GetLocalVersion()

View File

@ -91,6 +91,7 @@ type GoQMLInterface struct {
_ func() `slot:"errorSystray"` _ func() `slot:"errorSystray"`
_ func() `slot:"normalSystray"` _ func() `slot:"normalSystray"`
_ func() `slot:"openLicenseFile"`
_ func() `slot:"getLocalVersionInfo"` _ func() `slot:"getLocalVersionInfo"`
_ func(showMessage bool) `slot:"isNewVersionAvailable"` _ func(showMessage bool) `slot:"isNewVersionAvailable"`
_ func() string `slot:"getBackendVersion"` _ func() string `slot:"getBackendVersion"`
@ -152,6 +153,7 @@ func (s *GoQMLInterface) SetFrontend(f *FrontendQt) {
s.ConnectClearCache(f.clearCache) s.ConnectClearCache(f.clearCache)
s.ConnectClearKeychain(f.clearKeychain) s.ConnectClearKeychain(f.clearKeychain)
s.ConnectOpenLicenseFile(f.openLicenseFile)
s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo) s.ConnectGetLocalVersionInfo(f.getLocalVersionInfo)
s.ConnectIsNewVersionAvailable(f.isNewVersionAvailable) s.ConnectIsNewVersionAvailable(f.isNewVersionAvailable)
s.ConnectGetIMAPPort(f.getIMAPPort) s.ConnectGetIMAPPort(f.getIMAPPort)

View File

@ -189,6 +189,45 @@ func (c *Config) GetLogPrefix() string {
return "v" + c.version + "_" + c.revision return "v" + c.version + "_" + c.revision
} }
// GetLicenseFilePath returns path to liense file.
func (c *Config) GetLicenseFilePath() string {
// User can install app to different location, or user can run it
// directly from the package without installation, or it could be
// automatically updated (app started from differenet location).
// For all those cases, first let's check LICENSE next to the binary.
path := filepath.Join(filepath.Dir(os.Args[0]), "LICENSE")
if _, err := os.Stat(path); err == nil {
return path
}
switch runtime.GOOS {
case "linux":
appName := c.appName
if c.appName == "importExport" {
appName = "import-export"
}
return "/usr/share/doc/protonmail/" + appName + "/LICENSE"
case "darwin": //nolint[goconst]
path := filepath.Join(filepath.Dir(os.Args[0]), "..", "Resources", "LICENSE")
if _, err := os.Stat(path); err == nil {
return path
}
appName := "ProtonMail Bridge.app"
if c.appName == "importExport" {
appName = "ProtonMail Import-Export.app"
}
return "/Applications/" + appName + "/Contents/Resources/LICENSE"
case "windows":
// This should not happen, Windows should be handled by relative
// location to the binary above. This is just fallback which may
// or may not work, depends where user installed the app and how
// user started the app.
return "C:\\Program Files\\Proton Technologies AG\\ProtonMail Bridge\\LICENSE"
}
return ""
}
// GetTLSCertPath returns path to certificate; used for TLS servers (IMAP, SMTP and API). // GetTLSCertPath returns path to certificate; used for TLS servers (IMAP, SMTP and API).
func (c *Config) GetTLSCertPath() string { func (c *Config) GetTLSCertPath() string {
return filepath.Join(c.appDirs.UserConfig(), "cert.pem") return filepath.Join(c.appDirs.UserConfig(), "cert.pem")

View File

@ -6,6 +6,7 @@ Changelog [format](http://keepachangelog.com/en/1.0.0/)
### Added ### Added
* GODT-906 Handle RFC2047-encoded content transfer encoding values. * GODT-906 Handle RFC2047-encoded content transfer encoding values.
* GODT-270 Added license button in footer to open LICENSE file.
### Changed ### Changed
* GODT-893 Bump go-rfc5322 dependency to v0.2.1 to properly detect syntax errors during parsing. * GODT-893 Bump go-rfc5322 dependency to v0.2.1 to properly detect syntax errors during parsing.