Skip to content

Commit

Permalink
enter name and email in the export dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Thienel <[email protected]>
  • Loading branch information
ftl committed Dec 24, 2024
1 parent 23610ea commit 23f8bc0
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 11 deletions.
14 changes: 14 additions & 0 deletions core/export/cabrillo/cabrillo.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type View interface {
SetCategoryMode(string)
SetCategoryOperator(string)
SetCategoryPower(string)
SetName(string)
SetEmail(string)
SetOpenAfterExport(bool)
}

Expand Down Expand Up @@ -58,6 +60,8 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q
c.definition = settings.Contest().Definition

c.updateCategorySettings()
c.view.SetName(c.name)
c.view.SetEmail(c.email)
c.view.SetOpenAfterExport(c.openAfterExport)
accepted := c.view.Show()
if !accepted {
Expand All @@ -66,6 +70,8 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q

export := createCabrilloLog(settings, claimedScore, qsos)
export.Category = c.category
export.Name = c.name
export.Email = c.email

return export, c.openAfterExport, true
}
Expand Down Expand Up @@ -179,6 +185,14 @@ func (c *Controller) SetCategoryPower(power string) {
c.category.Power = cabrillo.CategoryPower(strings.ToUpper(power))
}

func (c *Controller) SetName(name string) {
c.name = name
}

func (c *Controller) SetEmail(email string) {
c.email = email
}

func (c *Controller) SetOpenAfterExport(open bool) {
c.openAfterExport = open
}
Expand Down
9 changes: 1 addition & 8 deletions core/export/cabrillo/cabrillo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,7 @@ CALLSIGN: AA1ZZZ
OPERATORS: AA2ZZZ
GRID-LOCATOR: AA00aa
CLAIMED-SCORE: 123
CATEGORY-ASSISTED:
CATEGORY-BAND:
CATEGORY-MODE:
CATEGORY-OPERATOR:
CATEGORY-POWER:
CLUB:
NAME:
EMAIL:
CERTIFICATE: YES
QSO: 7000 CW 2009-05-30 0002 AA1ZZZ 599 001 ABC S50A 589 004 DEF
END-OF-LOG:
`
Expand Down
42 changes: 39 additions & 3 deletions ui/exportCabrilloDialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type exportCabrilloDialog struct {
categoryMode string
categoryOperator string
categoryPower string
name string
email string
openAfterExport bool
}

Expand Down Expand Up @@ -106,18 +108,38 @@ func (d *exportCabrilloDialog) Show() bool {

separator, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
separator.SetHExpand(true)
separator.SetVExpand(true)
separator.SetMarginTop(5)
separator.SetMarginBottom(5)
grid.Attach(separator, 0, 7, 2, 1)

label, _ = gtk.LabelNew("Name")
label.SetHAlign(gtk.ALIGN_END)
grid.Attach(label, 0, 8, 1, 1)
d.view.nameEntry, _ = gtk.EntryNew()
d.view.nameEntry.SetText(d.name)
grid.Attach(d.view.nameEntry, 1, 8, 1, 1)

label, _ = gtk.LabelNew("Email")
label.SetHAlign(gtk.ALIGN_END)
grid.Attach(label, 0, 9, 1, 1)
d.view.emailEntry, _ = gtk.EntryNew()
d.view.emailEntry.SetText(d.email)
grid.Attach(d.view.emailEntry, 1, 9, 1, 1)

separator, _ = gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL)
separator.SetHExpand(true)
separator.SetVExpand(true)
grid.Attach(separator, 0, 10, 2, 1)

d.view.openAfterExportCheckButton, _ = gtk.CheckButtonNewWithLabel("Open the file after export")
d.view.openAfterExportCheckButton.SetActive(d.openAfterExport)
grid.Attach(d.view.openAfterExportCheckButton, 0, 8, 2, 1)
grid.Attach(d.view.openAfterExportCheckButton, 0, 11, 2, 1)

d.view.setup(d.controller)

dialog, _ := gtk.DialogNew()
d.dialog = dialog
d.dialog.SetDefaultSize(400, 300)
d.dialog.SetDefaultSize(400, 400)
d.dialog.SetTransientFor(nil)
d.dialog.SetPosition(gtk.WIN_POS_CENTER)
d.dialog.Connect("destroy", d.onDestroy)
Expand Down Expand Up @@ -174,6 +196,20 @@ func (d *exportCabrilloDialog) SetCategoryPower(power string) {
}
}

func (d *exportCabrilloDialog) SetName(name string) {
d.name = name
if d.view != nil {
d.view.nameEntry.SetText(name)
}
}

func (d *exportCabrilloDialog) SetEmail(email string) {
d.email = email
if d.view != nil {
d.view.emailEntry.SetText(email)
}
}

func (d *exportCabrilloDialog) SetOpenAfterExport(open bool) {
d.openAfterExport = open
}
16 changes: 16 additions & 0 deletions ui/exportCabrilloView.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type ExportCabrilloController interface {
SetCategoryMode(string)
SetCategoryOperator(string)
SetCategoryPower(string)
SetName(string)
SetEmail(string)
SetOpenAfterExport(bool)
}

Expand All @@ -27,6 +29,8 @@ type exportCabrilloView struct {
categoryModeCombo *gtk.ComboBoxText
categoryOperatorCombo *gtk.ComboBoxText
categoryPowerCombo *gtk.ComboBoxText
nameEntry *gtk.Entry
emailEntry *gtk.Entry
openAfterExportCheckButton *gtk.CheckButton
}

Expand All @@ -38,6 +42,8 @@ func (v *exportCabrilloView) setup(controller ExportCabrilloController) {
v.categoryModeCombo.Connect("changed", v.onCategoryModeChanged)
v.categoryOperatorCombo.Connect("changed", v.onCategoryOperatorChanged)
v.categoryPowerCombo.Connect("changed", v.onCategoryPowerChanged)
v.nameEntry.Connect("changed", v.onNameChanged)
v.emailEntry.Connect("changed", v.onEmailChanged)
v.openAfterExportCheckButton.Connect("toggled", v.onOpenAfterExportToggled)
}

Expand Down Expand Up @@ -65,6 +71,16 @@ func (v *exportCabrilloView) onCategoryPowerChanged() {
v.controller.SetCategoryPower(v.categoryPowerCombo.GetActiveText())
}

func (v *exportCabrilloView) onNameChanged() {
text, _ := v.nameEntry.GetText()
v.controller.SetName(text)
}

func (v *exportCabrilloView) onEmailChanged() {
text, _ := v.emailEntry.GetText()
v.controller.SetEmail(text)
}

func (v *exportCabrilloView) onOpenAfterExportToggled() {
v.controller.SetOpenAfterExport(v.openAfterExportCheckButton.GetActive())
}

0 comments on commit 23f8bc0

Please sign in to comment.