ui: add keyboard accelerators

This commit is contained in:
mappu 2025-01-06 18:33:53 +13:00
parent 90fe6b862e
commit 89f34d8621

28
main.go
View File

@ -346,15 +346,15 @@ func (self *DockerGUI) update_visible_tabs(index int) {
func (self *DockerGUI) create_menu_bar() {
menubar := self.MenuBar()
file_menu := menubar.AddMenuWithTitle("File")
exit_action := qt.NewQAction5("Exit", self.QObject)
file_menu := menubar.AddMenuWithTitle("&File")
exit_action := qt.NewQAction5("E&xit", self.QObject)
exit_action.OnTriggered(func() {
self.Close()
})
file_menu.AddAction(exit_action)
docker_menu := menubar.AddMenuWithTitle("Docker")
refresh_action := qt.NewQAction5("Refresh", self.QObject)
docker_menu := menubar.AddMenuWithTitle("&Docker")
refresh_action := qt.NewQAction5("&Refresh", self.QObject)
refresh_action.OnTriggered(self.refresh_data)
docker_menu.AddAction(refresh_action)
}
@ -364,53 +364,53 @@ func (self *DockerGUI) show_context_menu(position *qt.QPoint) {
current_tab := self.tab_widget.CurrentWidget()
// Add refresh action to context menu
refresh_action := qt.NewQAction5("Refresh", self.QObject)
refresh_action := qt.NewQAction5("&Refresh", self.QObject)
refresh_action.OnTriggered(self.refresh_data)
context_menu.AddAction(refresh_action)
context_menu.AddSeparator()
if current_tab == self.containers_tab {
terminal_action := qt.NewQAction5("Terminal", self.QObject)
terminal_action := qt.NewQAction5("&Terminal", self.QObject)
terminal_action.OnTriggered(func() { self.handle_action("Terminal") })
context_menu.AddAction(terminal_action)
logs_action := qt.NewQAction5("Logs", self.QObject)
logs_action := qt.NewQAction5("&Logs", self.QObject)
logs_action.OnTriggered(func() { self.open_logs() })
context_menu.AddAction(logs_action)
context_menu.AddSeparator()
start_action := qt.NewQAction5("Start", self.QObject)
start_action := qt.NewQAction5("&Start", self.QObject)
start_action.OnTriggered(func() { self.handle_action("Start") })
context_menu.AddAction(start_action)
stop_action := qt.NewQAction5("Stop", self.QObject)
stop_action := qt.NewQAction5("S&top", self.QObject)
stop_action.OnTriggered(func() { self.handle_action("Stop") })
context_menu.AddAction(stop_action)
remove_action := qt.NewQAction5("Remove", self.QObject)
remove_action := qt.NewQAction5("Remo&ve", self.QObject)
remove_action.OnTriggered(func() { self.handle_action("Remove") })
context_menu.AddAction(remove_action)
} else if current_tab == self.images_tab {
pull_action := qt.NewQAction5("Pull", self.QObject)
pull_action := qt.NewQAction5("&Pull", self.QObject)
pull_action.OnTriggered(self.pull_image)
context_menu.AddAction(pull_action)
context_menu.AddSeparator()
remove_action := qt.NewQAction5("Remove", self.QObject)
remove_action := qt.NewQAction5("Remo&ve", self.QObject)
remove_action.OnTriggered(self.remove_image)
context_menu.AddAction(remove_action)
} else if current_tab == self.networks_tab {
remove_action := qt.NewQAction5("Remove", self.QObject)
remove_action := qt.NewQAction5("Remo&ve", self.QObject)
remove_action.OnTriggered(func() { self.handle_action("Remove") })
context_menu.AddAction(remove_action)
} else if current_tab == self.volumes_tab {
remove_action := qt.NewQAction5("Remove", self.QObject)
remove_action := qt.NewQAction5("Remo&ve", self.QObject)
remove_action.OnTriggered(func() { self.handle_action("Remove") })
context_menu.AddAction(remove_action)