Skip to content

Commit

Permalink
fill the file menu with all item
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Thienel <[email protected]>
  • Loading branch information
ftl committed Dec 3, 2024
1 parent 9542a15 commit 6ccfa41
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 10 deletions.
83 changes: 79 additions & 4 deletions fyneui/mainMenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import "fyne.io/fyne/v2"

type MainMenuController interface {
Open()
OpenContestRulesPage()
OpenContestUploadPage()
OpenConfigurationFile()
Quit()

OpenWiki()
Expand All @@ -27,7 +30,17 @@ type mainMenu struct {
}

type fileMenu struct {
fileOpen *fyne.MenuItem
fileNew,
fileOpen,
fileSaveAs,
fileExportCabrillo,
fileExportADIF,
fileExportCSV,
fileExportCallhistory,
fileOpenRules,
fileOpenUpload,
fileOpenSettings,
fileOpenConfigurationFile,
fileQuit *fyne.MenuItem
}

Expand All @@ -41,9 +54,9 @@ type windowMenu struct {
}

type helpMenu struct {
helpWiki *fyne.MenuItem
helpSponsors *fyne.MenuItem
helpAbout *fyne.MenuItem
helpWiki,
helpSponsors,
helpAbout *fyne.MenuItem
}

func setupMainMenu(mainWindow fyne.Window, controller MainMenuController, shortcuts ShortcutProvider) *mainMenu {
Expand All @@ -67,22 +80,84 @@ func setupMainMenu(mainWindow fyne.Window, controller MainMenuController, shortc
// FILE

func (m *mainMenu) setupFileMenu() []*fyne.MenuItem {
m.fileNew = fyne.NewMenuItem("New...", m.onFileNew)

m.fileOpen = fyne.NewMenuItem("Open...", m.onFileOpen)
m.fileOpen.Shortcut = m.shortcuts.Get(OpenShortcut)

m.fileSaveAs = fyne.NewMenuItem("Save As...", m.onFileSaveAs)
m.fileExportCabrillo = fyne.NewMenuItem("Export Cabrillo...", m.onFileExportCabrillo)
m.fileExportADIF = fyne.NewMenuItem("Export ADIF...", m.onFileExportADIF)
m.fileExportCSV = fyne.NewMenuItem("Export CSV...", m.onFileExportCSV)
m.fileExportCallhistory = fyne.NewMenuItem("Export Call History...", m.onFileExportCallhistory)
m.fileOpenRules = fyne.NewMenuItem("Open Contest Rules...", m.onFileOpenRules)
m.fileOpenUpload = fyne.NewMenuItem("Open Upload Page...", m.onFileOpenUpload)
m.fileOpenConfigurationFile = fyne.NewMenuItem("Open Configuration File...", m.onFileOpenConfigurationFile)

m.fileOpenSettings = fyne.NewMenuItem("Settings...", m.onFileOpenSettings)
m.fileOpenSettings.Shortcut = m.shortcuts.Get(OpenSettingsShortcut)

m.fileQuit = fyne.NewMenuItem("Quit", m.onFileQuit)
m.fileQuit.Shortcut = m.shortcuts.Get(QuitShortcut)
m.fileQuit.IsQuit = true

return []*fyne.MenuItem{
m.fileNew,
m.fileOpen,
m.fileSaveAs,
fyne.NewMenuItemSeparator(),
m.fileExportCabrillo,
m.fileExportADIF,
m.fileExportCSV,
m.fileExportCallhistory,
fyne.NewMenuItemSeparator(),
m.fileOpenRules,
m.fileOpenUpload,
fyne.NewMenuItemSeparator(),
m.fileOpenConfigurationFile,
m.fileOpenSettings,
fyne.NewMenuItemSeparator(),
m.fileQuit,
}
}

func (m *mainMenu) onFileNew() {
}

func (m *mainMenu) onFileOpen() {
m.controller.Open()
}

func (m *mainMenu) onFileSaveAs() {
}

func (m *mainMenu) onFileExportCabrillo() {
}

func (m *mainMenu) onFileExportADIF() {
}

func (m *mainMenu) onFileExportCSV() {
}

func (m *mainMenu) onFileExportCallhistory() {
}

func (m *mainMenu) onFileOpenRules() {
m.controller.OpenContestRulesPage()
}

func (m *mainMenu) onFileOpenUpload() {
m.controller.OpenContestUploadPage()
}

func (m *mainMenu) onFileOpenConfigurationFile() {
m.controller.OpenConfigurationFile()
}

func (m *mainMenu) onFileOpenSettings() {
}

func (m *mainMenu) onFileQuit() {
m.controller.Quit()
}
Expand Down
19 changes: 13 additions & 6 deletions fyneui/shortcuts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
type ShortcutID string

const (
OpenShortcut ShortcutID = "open"
QuitShortcut ShortcutID = "quit"
OpenShortcut ShortcutID = "open"
OpenSettingsShortcut ShortcutID = "open_settings"
QuitShortcut ShortcutID = "quit"
)

type ShortcutConsumer interface {
Expand All @@ -34,6 +35,7 @@ func (s *Shortcut) AddTo(consumer ShortcutConsumer) {

type ShortcutController interface {
Open()
OpenSettings()
Quit()
}

Expand All @@ -44,13 +46,18 @@ type Shortcuts struct {
func setupShortcuts(controller ShortcutController) *Shortcuts {
return &Shortcuts{
shortcuts: map[ShortcutID]*Shortcut{
OpenShortcut: &Shortcut{
ID: "open",
OpenShortcut: {
ID: OpenShortcut,
Action: controller.Open,
CustomShortcut: desktop.CustomShortcut{Modifier: fyne.KeyModifierControl, KeyName: fyne.KeyO},
},
QuitShortcut: &Shortcut{
ID: "quit",
OpenSettingsShortcut: {
ID: OpenSettingsShortcut,
Action: controller.OpenSettings,
CustomShortcut: desktop.CustomShortcut{Modifier: fyne.KeyModifierControl, KeyName: fyne.KeyPeriod},
},
QuitShortcut: {
ID: QuitShortcut,
Action: controller.Quit,
CustomShortcut: desktop.CustomShortcut{Modifier: fyne.KeyModifierControl, KeyName: fyne.KeyQ},
},
Expand Down

0 comments on commit 6ccfa41

Please sign in to comment.