Skip to content

Commit 3a79d06

Browse files
committed
settings(apple): support custom resolution options
1 parent b5ee806 commit 3a79d06

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

Platform/macOS/VMConfigAppleDisplayView.swift

+13-3
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ struct VMConfigAppleDisplayView: View {
3838
lhs.resolution.heightInPixels == rhs.heightInPixels
3939
}
4040
}
41-
private let defaultResolution = NamedResolution(name: "",
42-
resolution: Resolution(width: 1920, height: 1200))
41+
42+
private static let customResolution = NamedResolution(name: NSLocalizedString("Custom", comment: "VMConfigAppleDisplayView"),
43+
resolution: Resolution(width: 0, height: 0))
44+
45+
private var customResolution: NamedResolution {
46+
Self.customResolution
47+
}
4348

4449
private let resolutions = [
50+
Self.customResolution,
4551
NamedResolution(name: "1024 × 640 — 16:10",
4652
resolution: Resolution(width: 1024, height: 640)),
4753
NamedResolution(name: "1024 × 665 — MacBook Pro (14-inch, 2021) Scaled",
@@ -127,7 +133,7 @@ struct VMConfigAppleDisplayView: View {
127133
return item
128134
}
129135
}
130-
return defaultResolution
136+
return customResolution
131137
} set: { newValue in
132138
config.widthInPixels = newValue.resolution.widthInPixels
133139
config.heightInPixels = newValue.resolution.heightInPixels
@@ -151,6 +157,10 @@ struct VMConfigAppleDisplayView: View {
151157
.tag(item)
152158
}
153159
}
160+
if displayResolution.wrappedValue == customResolution {
161+
NumberTextField("Width", number: $config.widthInPixels)
162+
NumberTextField("Height", number: $config.heightInPixels)
163+
}
154164
Toggle("HiDPI (Retina)", isOn: isHidpi)
155165
.help("Only available on macOS virtual machines.")
156166
}

0 commit comments

Comments
 (0)