瀏覽代碼

wizard: remove Windows VHDX option

Microsoft now distributes ARM64 ISOs (plus CrystalFetch exists).
You can still use VHDX using Other -> Import existing image.
osy 3 周之前
父節點
當前提交
93eedaacf7

+ 16 - 49
Platform/Shared/VMWizardOSWindowsView.swift

@@ -19,7 +19,6 @@ import SwiftUI
 struct VMWizardOSWindowsView: View {
     @ObservedObject var wizardState: VMWizardState
     @State private var isFileImporterPresented: Bool = false
-    @State private var useVhdx: Bool = false
     
     var body: some View {
         VMWizardContent("Windows") {
@@ -37,30 +36,21 @@ struct VMWizardOSWindowsView: View {
                     }
                 
                 if wizardState.isWindows10OrHigher {
-                    Toggle("Import VHDX Image", isOn: $useVhdx)
                     #if os(macOS)
-                    if useVhdx {
-                        #if arch(arm64)
-                        Link(destination: URL(string: "https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64")!) {
-                            Label("Download Windows 11 for ARM64 Preview VHDX", systemImage: "link")
-                        }.buttonStyle(.borderless)
-                        #endif
-                    } else if #available(macOS 12, *) { // CrystalFetch is only available on macOS 12+
-                        Button {
-                            let downloadCrystalFetch = URL(string: "https://mac.getutm.app/crystalfetch/")!
-                            if let crystalFetch = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "llc.turing.CrystalFetch") {
-                                NSWorkspace.shared.openApplication(at: crystalFetch, configuration: .init()) { _, error in
-                                    if error != nil {
-                                        NSWorkspace.shared.open(downloadCrystalFetch)
-                                    }
+                    Button {
+                        let downloadCrystalFetch = URL(string: "https://mac.getutm.app/crystalfetch/")!
+                        if let crystalFetch = NSWorkspace.shared.urlForApplication(withBundleIdentifier: "llc.turing.CrystalFetch") {
+                            NSWorkspace.shared.openApplication(at: crystalFetch, configuration: .init()) { _, error in
+                                if error != nil {
+                                    NSWorkspace.shared.open(downloadCrystalFetch)
                                 }
-                            } else {
-                                NSWorkspace.shared.open(downloadCrystalFetch)
                             }
-                        } label: {
-                            Label("Fetch latest Windows installer…", systemImage: "link")
-                        }.buttonStyle(.link)
-                    }
+                        } else {
+                            NSWorkspace.shared.open(downloadCrystalFetch)
+                        }
+                    } label: {
+                        Label("Fetch latest Windows installer…", systemImage: "link")
+                    }.buttonStyle(.link)
                     #endif
                     Link(destination: URL(string: "https://docs.getutm.app/guides/windows/")!) {
                         Label("Windows Install Guide", systemImage: "link")
@@ -69,31 +59,15 @@ struct VMWizardOSWindowsView: View {
             } header: {
                 Text("Image File Type")
             }
-            .onAppear {
-                // SwiftUI bug: on macOS 11, onAppear() is called every time the check box is clicked
-                if #available(iOS 15, macOS 12, *) {
-                    if wizardState.windowsBootVhdx != nil {
-                        useVhdx = true
-                    }
-                }
-            }
             
             Section {
-                if useVhdx {
-                    FileBrowseField(url: $wizardState.windowsBootVhdx, isFileImporterPresented: $isFileImporterPresented, hasClearButton: false)
-                } else {
-                    FileBrowseField(url: $wizardState.bootImageURL, isFileImporterPresented: $isFileImporterPresented, hasClearButton: false)
-                }
+                FileBrowseField(url: $wizardState.bootImageURL, isFileImporterPresented: $isFileImporterPresented, hasClearButton: false)
                 
                 if wizardState.isBusy {
                     Spinner(size: .large)
                 }
             } header: {
-                if useVhdx {
-                    Text("Boot VHDX Image")
-                } else {
-                    Text("Boot ISO Image")
-                }
+                Text("Boot ISO Image")
             }
             
             if !wizardState.isWindows10OrHigher {
@@ -124,15 +98,8 @@ struct VMWizardOSWindowsView: View {
         wizardState.busyWorkAsync {
             let url = try result.get()
             await MainActor.run {
-                if useVhdx {
-                    wizardState.windowsBootVhdx = url
-                    wizardState.bootImageURL = nil
-                    wizardState.bootDevice = .none
-                } else {
-                    wizardState.windowsBootVhdx = nil
-                    wizardState.bootImageURL = url
-                    wizardState.bootDevice = .cd
-                }
+                wizardState.bootImageURL = url
+                wizardState.bootDevice = .cd
             }
         }
     }

+ 2 - 21
Platform/Shared/VMWizardState.swift

@@ -130,7 +130,6 @@ struct AlertMessage: Identifiable {
     @Published var linuxRootImageURL: URL?
     @Published var linuxBootArguments: String = ""
     @Published var linuxHasRosetta: Bool = false
-    @Published var windowsBootVhdx: URL?
     @Published var isWindows10OrHigher: Bool = true
     @Published var systemArchitecture: QEMUArchitecture = .x86_64
     @Published var systemTarget: any QEMUTarget = QEMUTarget_x86_64.default
@@ -248,7 +247,7 @@ struct AlertMessage: Identifiable {
             }
             nextPage = .hardware
         case .windowsBoot:
-            guard bootImageURL != nil || windowsBootVhdx != nil else {
+            guard bootImageURL != nil else {
                 alertMessage = AlertMessage(NSLocalizedString("Please select a boot image.", comment: "VMWizardState"))
                 return
             }
@@ -263,11 +262,6 @@ struct AlertMessage: Identifiable {
             } else {
                 nextPage = .drives
             }
-            #if arch(arm64)
-            if operatingSystem == .Windows && windowsBootVhdx != nil {
-                nextPage = .sharing
-            }
-            #endif
             if operatingSystem == .Linux && linuxRootImageURL != nil {
                 nextPage = .sharing
                 if useAppleVirtualization {
@@ -354,10 +348,6 @@ struct AlertMessage: Identifiable {
             #endif
         case .Windows:
             config.information.iconURL = UTMConfigurationInfo.builtinIcon(named: "windows")
-            if let windowsBootVhdx = windowsBootVhdx {
-                config.drives.append(UTMAppleConfigurationDrive(existingURL: windowsBootVhdx, isExternal: false))
-                isSkipDiskCreate = true
-            }
         }
         if !isSkipDiskCreate {
             var newDisk = UTMAppleConfigurationDrive(newSize: storageSizeGib * bytesInGib / bytesInMib)
@@ -523,17 +513,8 @@ struct AlertMessage: Identifiable {
         case .Windows:
             config.information.iconURL = UTMConfigurationInfo.builtinIcon(named: "windows")
             config.qemu.hasRTCLocalTime = true
-            if let windowsBootVhdx = windowsBootVhdx {
-                var rootImage = UTMQemuConfigurationDrive()
-                rootImage.imageURL = windowsBootVhdx
-                rootImage.imageType = .disk
-                rootImage.interface = mainDriveInterface
-                config.drives.append(rootImage)
-                let diskDrive = UTMQemuConfigurationDrive(forArchitecture: systemArchitecture, target: systemTarget, isExternal: true)
-                config.drives.append(diskDrive)
-            }
         }
-        if windowsBootVhdx == nil && bootDevice != .drive {
+        if bootDevice != .drive {
             var diskImage = UTMQemuConfigurationDrive()
             diskImage.sizeMib = storageSizeGib * bytesInGib / bytesInMib
             diskImage.imageType = .disk

+ 2 - 7
Platform/Shared/VMWizardSummaryView.swift

@@ -140,14 +140,13 @@ struct VMWizardSummaryView: View {
             if let bootImageURL = wizardState.bootImageURL {
                 TextField("Boot Image", text: .constant(bootImageURL.path))
             }
-            switch wizardState.operatingSystem {
-            case .macOS:
+            if wizardState.operatingSystem == .macOS {
                 #if os(macOS) && arch(arm64)
                 TextField("IPSW", text: .constant(wizardState.macRecoveryIpswURL?.path ?? ""))
                 #else
                 EmptyView()
                 #endif
-            case .Linux:
+            } else if wizardState.operatingSystem == .Linux {
                 TextField("Kernel", text: .constant(wizardState.linuxKernelURL?.path ?? ""))
                 TextField("Initial Ramdisk", text: .constant(wizardState.linuxInitialRamdiskURL?.path ?? ""))
                 TextField("Root Image", text: .constant(wizardState.linuxRootImageURL?.path ?? ""))
@@ -157,10 +156,6 @@ struct VMWizardSummaryView: View {
                     Toggle("Use Rosetta", isOn: $wizardState.linuxHasRosetta)
                 }
                 #endif
-            case .Windows, .Other:
-                if let windowsBootVhdx = wizardState.windowsBootVhdx {
-                    TextField("Disk Image", text: .constant(windowsBootVhdx.path))
-                }
             }
         }
     }