Commit 4c9fe6a3 authored by Loïck Bonniot's avatar Loïck Bonniot

[gui] Create package common and add Help action

parent 446405a2
Pipeline #875 passed with stage
......@@ -14,3 +14,7 @@ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIG
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.`
const help = `Your configuration and authentication files are stored under your home directory, in a .dfss folder.
You may want to save this folder in a secure way in order to re-use your account on several computers.`
......@@ -2,7 +2,7 @@ package authform
import (
"dfss/dfssc/user"
"dfss/gui/config"
"dfss/gui/common"
"github.com/spf13/viper"
"github.com/visualfc/goqt/ui"
)
......@@ -27,7 +27,7 @@ func NewWidget(onAuth func()) *Widget {
)
form.SetDisabled(false)
if err != nil {
config.ShowMsgBox(err.Error(), true)
common.ShowMsgBox(err.Error(), true)
tokenField.SetFocus()
tokenField.SelectAll()
} else {
......
package config
package common
// This file handles basic feedback messages.
......@@ -7,7 +7,6 @@ import (
"io/ioutil"
"dfss/auth"
"github.com/spf13/viper"
"github.com/visualfc/goqt/ui"
)
......
......@@ -4,8 +4,8 @@ import (
"strings"
"dfss/dfssc/sign"
"dfss/gui/common"
"dfss/gui/config"
"github.com/spf13/viper"
"github.com/visualfc/goqt/ui"
)
......@@ -42,7 +42,7 @@ func NewWidget() *Widget {
createButton.OnClicked(func() {
form.SetDisabled(true)
config.PasswordDialog(func(err error, pwd string) {
common.PasswordDialog(func(err error, pwd string) {
if err != nil {
form.SetDisabled(false)
return // wrong key or rejection, aborting
......@@ -56,9 +56,9 @@ func NewWidget() *Widget {
)
if err != nil {
config.ShowMsgBox(err.Error(), true)
common.ShowMsgBox(err.Error(), true)
} else {
config.ShowMsgBox("Contract successfully sent to signers!", false)
common.ShowMsgBox("Contract successfully sent to signers!", false)
fileField.SetText("")
}
form.SetDisabled(false)
......
......@@ -3,6 +3,7 @@ package main
import (
"dfss"
"dfss/dfssp/contract"
"dfss/gui/common"
"dfss/gui/config"
"github.com/spf13/viper"
"github.com/visualfc/goqt/ui"
......@@ -73,6 +74,11 @@ func (w *window) addActions() {
fetchAct := ui.NewActionWithTextParent("&Fetch", w)
fetchAct.OnTriggered(w.showFetchForm)
helpAct := ui.NewActionWithTextParent("&Help", w)
helpAct.OnTriggered(func() {
common.ShowMsgBox(help, false)
})
aboutAct := ui.NewActionWithTextParent("&About", w)
aboutAct.OnTriggered(func() {
ui.QMessageBoxAbout(w, "About DFSS Client", about)
......@@ -93,6 +99,7 @@ func (w *window) addActions() {
fileMenu.AddAction(fetchAct)
helpMenu := w.MenuBar().AddMenuWithTitle("&Help")
helpMenu.AddAction(helpAct)
helpMenu.AddAction(aboutAct)
helpMenu.AddSeparator()
helpMenu.AddAction(aboutQtAct)
......
......@@ -3,7 +3,7 @@ package main
import (
"dfss/dfssc/sign"
"dfss/gui/authform"
"dfss/gui/config"
"dfss/gui/common"
"dfss/gui/contractform"
"dfss/gui/showcontract"
"dfss/gui/signform"
......@@ -50,17 +50,17 @@ func (w *window) showShowContract(filename string) {
w.contract = showcontract.Load(filename)
if w.contract == nil {
config.ShowMsgBox("Unable to load file", true)
common.ShowMsgBox("Unable to load file", true)
return
}
w.setScreen(showcontract.NewWidget(w.contract, w.showSignForm))
}
func (w *window) showSignForm() {
config.PasswordDialog(func(err error, pwd string) {
common.PasswordDialog(func(err error, pwd string) {
widget := signform.NewWidget(w.contract, pwd)
if widget == nil {
config.ShowMsgBox("Unable to start the signing procedure", true)
common.ShowMsgBox("Unable to start the signing procedure", true)
return
}
w.setScreen(widget)
......@@ -69,7 +69,7 @@ func (w *window) showSignForm() {
func (w *window) showFetchForm() {
w.current.Q().SetDisabled(true)
config.PasswordDialog(func(err error, pwd string) {
common.PasswordDialog(func(err error, pwd string) {
if err != nil {
w.current.Q().SetDisabled(false)
return
......@@ -87,11 +87,11 @@ func (w *window) showFetchForm() {
err := sign.FetchContract(pwd, uuid, path)
if err != nil {
config.ShowMsgBox(err.Error(), true)
common.ShowMsgBox(err.Error(), true)
return
}
w.showShowContract(path)
config.ShowMsgBox("Contract stored as "+path, false)
common.ShowMsgBox("Contract stored as "+path, false)
})
dialog.OnFinished(func(_ int32) {
......
......@@ -4,6 +4,7 @@ import (
"io/ioutil"
"dfss/dfssc/user"
"dfss/gui/common"
"dfss/gui/config"
"github.com/spf13/viper"
......@@ -41,7 +42,7 @@ func NewWidget(onRegistered func(pw string)) *Widget {
"", "", "", emailField.Text(), 2048,
)
if err != nil {
config.ShowMsgBox(err.Error(), true)
common.ShowMsgBox(err.Error(), true)
} else {
viper.Set("email", emailField.Text())
onRegistered(passwordField.Text())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment