Skip to content

Commit

Permalink
settings(qemu): fix port forward interface on macOS
Browse files Browse the repository at this point in the history
Fixes #4690
  • Loading branch information
osy committed Nov 24, 2022
1 parent b1140ff commit 2cde3b9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions Platform/macOS/VMConfigNetworkPortForwardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,22 @@ struct VMConfigNetworkPortForwardView: View {
}) {
VStack {
ForEach(config.portForward) { forward in
Button(action: { selectedPortForward = forward }, label: {
let isPopoverShown = Binding<Bool> {
selectedPortForward == forward
} set: { value in
if value {
selectedPortForward = forward
} else {
selectedPortForward = nil
}
}

Button(action: { isPopoverShown.wrappedValue = true }, label: {
let guest = "\(forward.guestAddress ?? ""):\(forward.guestPort)"
let host = "\(forward.hostAddress ?? ""):\(forward.hostPort)"
Text("\(guest) ➡️ \(host)")
}).buttonStyle(.bordered)
.popover(item: $selectedPortForward, arrowEdge: .bottom) { item in
.popover(isPresented: isPopoverShown, arrowEdge: .bottom) {
PortForwardEdit(config: $config, forward: forward).padding()
.frame(width: 250)
}
Expand All @@ -61,7 +71,7 @@ struct PortForwardEdit: View {
VMConfigPortForwardForm(forward: $forward).multilineTextAlignment(.trailing)
HStack {
Spacer()
let index = config.portForward.firstIndex(of: forward)
let index = config.portForward.firstIndex(where: { $0.id == forward.id })
if let index = index {
Button(action: {
config.portForward.remove(at: index)
Expand Down

0 comments on commit 2cde3b9

Please sign in to comment.