VMConfigDisplayView.swift 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // Copyright © 2020 osy. All rights reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. import SwiftUI
  17. struct VMConfigDisplayView: View {
  18. @Binding var config: UTMQemuConfigurationDisplay
  19. @Binding var system: UTMQemuConfigurationSystem
  20. var isGLSupported: Bool {
  21. config.hardware.rawValue.contains("-gl-") || config.hardware.rawValue.hasSuffix("-gl")
  22. }
  23. var body: some View {
  24. VStack {
  25. Form {
  26. Section(header: Text("Hardware")) {
  27. VMConfigConstantPicker("Emulated Display Card", selection: $config.hardware, type: system.architecture.displayDeviceType)
  28. Toggle("GPU Acceleration Supported", isOn: .constant(isGLSupported)).disabled(true)
  29. if isGLSupported {
  30. Text("Guest drivers are required for 3D acceleration.")
  31. .font(.footnote)
  32. }
  33. if config.hardware.rawValue.contains("-vga") ||
  34. config.hardware.rawValue == "VGA" ||
  35. config.hardware.rawValue == "vmware-svga" {
  36. NumberTextField("VGA Device RAM (MB)", number: $config.vgaRamMib.bound, prompt: "16")
  37. }
  38. }
  39. DetailedSection("Auto Resolution", description: "Requires SPICE guest agent tools to be installed.") {
  40. Toggle(isOn: $config.isDynamicResolution, label: {
  41. #if os(macOS)
  42. Text("Resize display to window size automatically")
  43. #else
  44. Text("Resize display to screen size and orientation automatically")
  45. #endif
  46. })
  47. }
  48. Section(header: Text("Scaling")) {
  49. VMConfigConstantPicker("Upscaling", selection: $config.upscalingFilter)
  50. VMConfigConstantPicker("Downscaling", selection: $config.downscalingFilter)
  51. Toggle(isOn: $config.isNativeResolution, label: {
  52. Text("Retina Mode")
  53. })
  54. }
  55. }
  56. }.disableAutocorrection(true)
  57. }
  58. }
  59. struct VMConfigDisplayView_Previews: PreviewProvider {
  60. @State static private var config = UTMQemuConfigurationDisplay()
  61. @State static private var system = UTMQemuConfigurationSystem()
  62. static var previews: some View {
  63. VMConfigDisplayView(config: $config, system: $system)
  64. }
  65. }