From d78d4300657d08f96f5e39c9ef09087e02b08b2b Mon Sep 17 00:00:00 2001 From: Pedro Cuenca Date: Mon, 20 Feb 2023 20:44:51 +0100 Subject: [PATCH] Reveal model folder in Finder --- Diffusion-macOS/ControlsView.swift | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Diffusion-macOS/ControlsView.swift b/Diffusion-macOS/ControlsView.swift index e0a93ce..04d26f1 100644 --- a/Diffusion-macOS/ControlsView.swift +++ b/Diffusion-macOS/ControlsView.swift @@ -88,9 +88,11 @@ struct ControlsView: View { } func modelDidChange(model: ModelInfo) { + guard pipelineLoader?.model != model else { return } + print("Loading model \(model)") Settings.shared.currentModel = model - + pipelineLoader?.cancel() pipelineState = .downloading(0) Task.init { @@ -144,13 +146,21 @@ struct ControlsView: View { ScrollView { Group { DisclosureGroup(isExpanded: $disclosedModel) { + let revealOption = "-- reveal --" Picker("", selection: $model) { ForEach(Self.models, id: \.modelVersion) { modelLabel($0) } + Text("Reveal in Finder…").tag(revealOption) } - .onChange(of: model) { theModel in - guard let model = ModelInfo.from(modelVersion: theModel) else { return } + .onChange(of: model) { selection in + guard selection != revealOption else { + let selected = pipelineLoader?.compiledPath + NSWorkspace.shared.selectFile(selected?.string, inFileViewerRootedAtPath: PipelineLoader.models.string) + model = Settings.shared.currentModel.modelVersion + return + } + guard let model = ModelInfo.from(modelVersion: selection) else { return } modelDidChange(model: model) } } label: {