Fix crash on DNS/proxy table updates (macOS)
Also invert DNS addresses/domains position.
This commit is contained in:
parent
5a97ad0241
commit
49dcbf2553
|
@ -165,18 +165,18 @@
|
|||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Zfd-mA-qV9">
|
||||
<rect key="frame" x="0.0" y="0.0" width="500" height="330"/>
|
||||
<subviews>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Baa-Z1-JJJ">
|
||||
<rect key="frame" x="150" y="0.0" width="350" height="160"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="160" id="BTk-TZ-Dat"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="L6f-kb-mEG">
|
||||
<rect key="frame" x="150" y="170" width="350" height="160"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="160" id="zCq-d8-x9i"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="Baa-Z1-JJJ">
|
||||
<rect key="frame" x="150" y="0.0" width="350" height="160"/>
|
||||
<constraints>
|
||||
<constraint firstAttribute="height" constant="160" id="BTk-TZ-Dat"/>
|
||||
</constraints>
|
||||
</customView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="bottom" secondItem="Baa-Z1-JJJ" secondAttribute="bottom" id="DZf-vr-lkr"/>
|
||||
|
@ -212,8 +212,8 @@
|
|||
<outlet property="constraintChoiceBottom" destination="0mN-72-zeu" id="Lf7-4v-Gae"/>
|
||||
<outlet property="constraintSettingsTop" destination="ymz-zd-mjc" id="sN1-KM-hgC"/>
|
||||
<outlet property="popupChoice" destination="bFA-yD-Roy" id="lYe-Ho-P0K"/>
|
||||
<outlet property="viewDNSAddresses" destination="Baa-Z1-JJJ" id="Vg5-Ut-Fo8"/>
|
||||
<outlet property="viewDNSDomains" destination="L6f-kb-mEG" id="kp4-Xa-UhO"/>
|
||||
<outlet property="viewDNSAddresses" destination="L6f-kb-mEG" id="cbb-T7-MeD"/>
|
||||
<outlet property="viewDNSDomains" destination="Baa-Z1-JJJ" id="msU-UP-bJZ"/>
|
||||
<outlet property="viewSettings" destination="Zfd-mA-qV9" id="831-9h-AXu"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
|
|
|
@ -28,19 +28,19 @@ import PassepartoutCore
|
|||
|
||||
class DNSViewController: NSViewController, ProfileCustomization {
|
||||
private struct Templates {
|
||||
static let domain = ""
|
||||
|
||||
static let server = "0.0.0.0"
|
||||
|
||||
static let domain = ""
|
||||
}
|
||||
|
||||
@IBOutlet private weak var popupChoice: NSPopUpButton!
|
||||
|
||||
@IBOutlet private weak var viewSettings: NSView!
|
||||
|
||||
@IBOutlet private weak var viewDNSDomains: NSView!
|
||||
|
||||
@IBOutlet private weak var viewDNSAddresses: NSView!
|
||||
|
||||
@IBOutlet private weak var viewDNSDomains: NSView!
|
||||
|
||||
@IBOutlet private var constraintChoiceBottom: NSLayoutConstraint!
|
||||
|
||||
@IBOutlet private var constraintSettingsTop: NSLayoutConstraint!
|
||||
|
@ -66,16 +66,6 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
tableDNSDomains.title = L10n.App.NetworkSettings.Dns.Cells.Domains.title.asCaption
|
||||
viewDNSDomains.addSubview(tableDNSDomains)
|
||||
tableDNSDomains.translatesAutoresizingMaskIntoConstraints = false
|
||||
NSLayoutConstraint.activate([
|
||||
tableDNSDomains.topAnchor.constraint(equalTo: viewDNSDomains.topAnchor),
|
||||
tableDNSDomains.bottomAnchor.constraint(equalTo: viewDNSDomains.bottomAnchor),
|
||||
tableDNSDomains.leftAnchor.constraint(equalTo: viewDNSDomains.leftAnchor),
|
||||
tableDNSDomains.rightAnchor.constraint(equalTo: viewDNSDomains.rightAnchor),
|
||||
])
|
||||
|
||||
tableDNSAddresses.title = L10n.App.NetworkSettings.Dns.Cells.Addresses.title.asCaption
|
||||
viewDNSAddresses.addSubview(tableDNSAddresses)
|
||||
tableDNSAddresses.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
@ -86,6 +76,16 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
tableDNSAddresses.rightAnchor.constraint(equalTo: viewDNSAddresses.rightAnchor),
|
||||
])
|
||||
|
||||
tableDNSDomains.title = L10n.App.NetworkSettings.Dns.Cells.Domains.title.asCaption
|
||||
viewDNSDomains.addSubview(tableDNSDomains)
|
||||
tableDNSDomains.translatesAutoresizingMaskIntoConstraints = false
|
||||
NSLayoutConstraint.activate([
|
||||
tableDNSDomains.topAnchor.constraint(equalTo: viewDNSDomains.topAnchor),
|
||||
tableDNSDomains.bottomAnchor.constraint(equalTo: viewDNSDomains.bottomAnchor),
|
||||
tableDNSDomains.leftAnchor.constraint(equalTo: viewDNSDomains.leftAnchor),
|
||||
tableDNSDomains.rightAnchor.constraint(equalTo: viewDNSDomains.rightAnchor),
|
||||
])
|
||||
|
||||
popupChoice.removeAllItems()
|
||||
for choice in choices {
|
||||
popupChoice.addItem(withTitle: choice.description)
|
||||
|
@ -93,8 +93,8 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
popupChoice.selectItem(at: popupChoice.numberOfItems - 1)
|
||||
}
|
||||
}
|
||||
tableDNSDomains.rowTemplate = Templates.domain
|
||||
tableDNSAddresses.rowTemplate = Templates.server
|
||||
tableDNSDomains.rowTemplate = Templates.domain
|
||||
loadSettings(from: currentChoice)
|
||||
}
|
||||
|
||||
|
@ -112,8 +112,8 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
return
|
||||
}
|
||||
view.endEditing()
|
||||
networkSettings.dnsSearchDomains = tableDNSDomains.rows
|
||||
networkSettings.dnsServers = tableDNSAddresses.rows
|
||||
networkSettings.dnsSearchDomains = tableDNSDomains.rows
|
||||
|
||||
delegate?.profileCustomization(self, didUpdateDNS: .manual, withManualSettings: networkSettings)
|
||||
}
|
||||
|
@ -137,17 +137,8 @@ class DNSViewController: NSViewController, ProfileCustomization {
|
|||
}
|
||||
}
|
||||
|
||||
tableDNSDomains.isEnabled = (currentChoice == .manual)
|
||||
tableDNSDomains.rows = networkSettings.dnsSearchDomains ?? []
|
||||
tableDNSDomains.isRemoveEnabled = false
|
||||
tableDNSDomains.selectedRow = nil
|
||||
tableDNSDomains.reloadData()
|
||||
|
||||
tableDNSAddresses.isAddEnabled = (currentChoice == .manual)
|
||||
tableDNSAddresses.rows = networkSettings.dnsServers ?? []
|
||||
tableDNSAddresses.isRemoveEnabled = false
|
||||
tableDNSAddresses.selectedRow = nil
|
||||
tableDNSAddresses.reloadData()
|
||||
tableDNSAddresses.reset(withRows: networkSettings.dnsServers ?? [], isAddEnabled: currentChoice == .manual)
|
||||
tableDNSDomains.reset(withRows: networkSettings.dnsSearchDomains ?? [], isAddEnabled: currentChoice == .manual)
|
||||
|
||||
let isServer = (currentChoice == .server)
|
||||
constraintChoiceBottom.priority = isServer ? .defaultHigh : .defaultLow
|
||||
|
|
|
@ -135,11 +135,7 @@ class ProxyViewController: NSViewController, ProfileCustomization {
|
|||
textProxyAddress.stringValue = networkSettings.proxyAddress ?? ""
|
||||
textProxyPort.isEnabled = (currentChoice == .manual)
|
||||
textProxyPort.stringValue = networkSettings.proxyPort?.description ?? ""
|
||||
tableProxyBypass.rows = networkSettings.proxyBypassDomains ?? []
|
||||
tableProxyBypass.isAddEnabled = (currentChoice == .manual)
|
||||
tableProxyBypass.isRemoveEnabled = false
|
||||
tableProxyBypass.selectedRow = nil
|
||||
tableProxyBypass.reloadData()
|
||||
tableProxyBypass.reset(withRows: networkSettings.proxyBypassDomains ?? [], isAddEnabled: currentChoice == .manual)
|
||||
|
||||
let isServer = (currentChoice == .server)
|
||||
constraintChoiceBottom.priority = isServer ? .defaultHigh : .defaultLow
|
||||
|
|
|
@ -36,7 +36,7 @@ class TextTableView: NSView {
|
|||
|
||||
var title = ""
|
||||
|
||||
var rows: [String] = []
|
||||
private(set) var rows: [String] = []
|
||||
|
||||
var selectedRow: Int? {
|
||||
didSet {
|
||||
|
@ -95,6 +95,15 @@ class TextTableView: NSView {
|
|||
|
||||
// MARK: Actions
|
||||
|
||||
func reset(withRows rows: [String], isAddEnabled: Bool) {
|
||||
endEditing()
|
||||
self.rows = rows
|
||||
self.isAddEnabled = isAddEnabled
|
||||
isRemoveEnabled = false
|
||||
selectedRow = nil
|
||||
reloadData()
|
||||
}
|
||||
|
||||
func reloadData() {
|
||||
tableView.reloadData()
|
||||
}
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
"configuration.alerts.commit.buttons.reconnect" = "Reconnect now";
|
||||
"configuration.alerts.commit.buttons.skip" = "Skip";
|
||||
|
||||
"network_settings.dns.cells.domains.title" = "Domains";
|
||||
"network_settings.dns.cells.addresses.title" = "Servers";
|
||||
"network_settings.dns.cells.domains.title" = "Domains";
|
||||
"network_settings.proxy.cells.bypass_domains.title" = "Bypass domains";
|
||||
|
||||
"preferences.title" = "%@ Preferences";
|
||||
|
|
Loading…
Reference in New Issue