Close assignment window with main window
This commit is contained in:
parent
8d98e85453
commit
5e595fe460
1 changed files with 45 additions and 2 deletions
|
|
@ -60,6 +60,8 @@ type App struct {
|
||||||
errorLabel *widget.Label
|
errorLabel *widget.Label
|
||||||
reconnectButton *widget.Button
|
reconnectButton *widget.Button
|
||||||
assignmentButton *widget.Button
|
assignmentButton *widget.Button
|
||||||
|
|
||||||
|
assignmentWindow fyne.Window
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewApp creates the graphical rs2322tcp client application.
|
// NewApp creates the graphical rs2322tcp client application.
|
||||||
|
|
@ -232,6 +234,12 @@ func (a *App) showAssignments() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do not create another assignment window when one is already open.
|
||||||
|
if a.assignmentWindow != nil {
|
||||||
|
a.assignmentWindow.Show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
cfg := a.clientApplication.Config()
|
cfg := a.clientApplication.Config()
|
||||||
devices := a.clientApplication.Devices()
|
devices := a.clientApplication.Devices()
|
||||||
|
|
||||||
|
|
@ -295,6 +303,19 @@ func (a *App) showAssignments() {
|
||||||
"Gerätezuordnung",
|
"Gerätezuordnung",
|
||||||
)
|
)
|
||||||
assignmentWindow.Resize(fyne.NewSize(650, 450))
|
assignmentWindow.Resize(fyne.NewSize(650, 450))
|
||||||
|
|
||||||
|
// Remember the child window so it can be closed together with
|
||||||
|
// the main window.
|
||||||
|
a.assignmentWindow = assignmentWindow
|
||||||
|
|
||||||
|
assignmentWindow.SetOnClosed(func() {
|
||||||
|
// Only clear the reference if this is still the current
|
||||||
|
// assignment window.
|
||||||
|
if a.assignmentWindow == assignmentWindow {
|
||||||
|
a.assignmentWindow = nil
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
assignmentWindow.SetContent(
|
assignmentWindow.SetContent(
|
||||||
container.NewBorder(
|
container.NewBorder(
|
||||||
nil,
|
nil,
|
||||||
|
|
@ -309,18 +330,40 @@ func (a *App) showAssignments() {
|
||||||
container.NewVScroll(content),
|
container.NewVScroll(content),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
assignmentWindow.Show()
|
assignmentWindow.Show()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// closeAssignmentWindow closes the currently open device-assignment window.
|
||||||
|
//
|
||||||
|
// This is deliberately kept separate from Close() so that the child window
|
||||||
|
// can be closed without changing any configuration or technical client
|
||||||
|
// state.
|
||||||
|
func (a *App) closeAssignmentWindow() {
|
||||||
|
if a == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if a.assignmentWindow == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
window := a.assignmentWindow
|
||||||
|
a.assignmentWindow = nil
|
||||||
|
window.Close()
|
||||||
|
}
|
||||||
|
|
||||||
// Close closes the technical client application.
|
// Close closes the technical client application.
|
||||||
//
|
//
|
||||||
// The Runtime and the server connection are closed before the GUI window
|
// Any open child GUI window is closed first. The technical client is then
|
||||||
// itself is closed.
|
// shut down.
|
||||||
func (a *App) Close() {
|
func (a *App) Close() {
|
||||||
if a == nil {
|
if a == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.closeAssignmentWindow()
|
||||||
|
|
||||||
_ = a.clientApplication.Close()
|
_ = a.clientApplication.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue