From 514cd73ef84e3b3ff74918789ba1aa96749dbc01 Mon Sep 17 00:00:00 2001 From: Alex Mazanov Date: Sun, 23 Oct 2022 11:35:58 -0400 Subject: [PATCH] Improved Plugins screen usability #301 --- SwiftBar/Plugin/PluginMetadata.swift | 4 ++++ .../UI/Preferences/PluginDetailsView.swift | 21 ++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/SwiftBar/Plugin/PluginMetadata.swift b/SwiftBar/Plugin/PluginMetadata.swift index 5344089..d5c8fc0 100644 --- a/SwiftBar/Plugin/PluginMetadata.swift +++ b/SwiftBar/Plugin/PluginMetadata.swift @@ -179,6 +179,10 @@ class PluginMetadata: ObservableObject { } } + static func cleanMetadata(fileURL: URL) { + try? fileURL.removeExtendedAttribute(forName: "com.ameba.SwiftBar") + } + static func empty() -> PluginMetadata { PluginMetadata() } diff --git a/SwiftBar/UI/Preferences/PluginDetailsView.swift b/SwiftBar/UI/Preferences/PluginDetailsView.swift index 0821d15..5739f1b 100644 --- a/SwiftBar/UI/Preferences/PluginDetailsView.swift +++ b/SwiftBar/UI/Preferences/PluginDetailsView.swift @@ -95,9 +95,24 @@ struct PluginDetailsView: View { Preferences.Section(title: "", content: {}) Preferences.Section(label: { - Button("Save in Plugin File", action: { - PluginMetadata.writeMetadata(metadata: md, fileURL: URL(fileURLWithPath: plugin.file)) - }) + HStack { + if #available(macOS 11.0, *) { + Button(action: { + NSWorkspace.shared.open(URL(string: "https://github.com/swiftbar/SwiftBar#metadata-for-binary-plugins")!) + }, label: { + Image(systemName: "questionmark.circle") + }) + } + Spacer() + Button("Reset", action: { + PluginMetadata.cleanMetadata(fileURL: URL(fileURLWithPath: plugin.file)) + plugin.refreshPluginMetadata() + }) + Button("Save in Plugin File", action: { + PluginMetadata.writeMetadata(metadata: md, fileURL: URL(fileURLWithPath: plugin.file)) + }) + } + }, content: {}) } }