知了 Cicada · 任何会议和直播的实时字幕、同声传译、AI 会议纪要,Mac、Windows、Linux、Android 免费开源。Live subtitles, interpreting and meeting notes for any call or stream, on Mac, Windows, Linux and Android.
Swift androidlinuxlive-captionsmacosmeeting-notesmenubar-appsimultaneous-interpretationspeech-recognitionsubtitlesswiftswiftuitranslationwindows
feat: Make the notes window's yellow button tuck it away to the menu bar, like 收起
wquguru89ecdffb8e7d
diff --git a/Sources/LiveSubs/AppModel.swift b/Sources/LiveSubs/AppModel.swiftindex 004ef82..43cce85 100644--- a/Sources/LiveSubs/AppModel.swift+++ b/Sources/LiveSubs/AppModel.swift@@ -1389,6 +1389,7 @@ final class AppModel: ObservableObject {case "notesCapturable": notesWindow.setCapturable(arg != "off")case "notesShare": setNotesCapturable(arg != "off") // the setting itself, as its badge or switch doescase "notesClose": notesWindow.performClose()+ case "notesMinimize": notesWindow.performMiniaturize()case "closeWindow":// closeWindow:<main|settings|onboarding>: what the window's close button does.let w = NSApp.windows.first { w indiff --git a/Sources/LiveSubs/NotesWindow.swift b/Sources/LiveSubs/NotesWindow.swiftindex 5dea2f7..a95edb1 100644--- a/Sources/LiveSubs/NotesWindow.swift+++ b/Sources/LiveSubs/NotesWindow.swift@@ -45,7 +45,7 @@ final class NotesWindowController: NSObject, NSWindowDelegate {func show() {guard let model else { return }if panel == nil {- let p = NSPanel(contentRect: defaultFrame(), styleMask: [.titled, .closable, .resizable, .fullSizeContentView, .nonactivatingPanel],+ let p = NotesPanel(contentRect: defaultFrame(), styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView, .nonactivatingPanel],backing: .buffered, defer: false)p.titleVisibility = .hiddenp.titlebarAppearsTransparent = true@@ -53,6 +53,8 @@ final class NotesWindowController: NSObject, NSWindowDelegate {p.isFloatingPanel = onTopp.level = onTop ? .floating : .normalp.delegate = self+ p.onMiniaturize = { [weak self] in self?.hide() }+ p.standardWindowButton(.miniaturizeButton)?.isEnabled = true// Clicking it leaves the meeting app active and our other windows where they are;// it only takes the keyboard for its text fields.p.hidesOnDeactivate = false@@ -112,6 +114,8 @@ final class NotesWindowController: NSObject, NSWindowDelegate {/// Debug control only: what the close button does.func performClose() { panel?.performClose(nil) }+ /// Debug control only: what the minimize button does.+ func performMiniaturize() { panel?.performMiniaturize(nil) }/// 录屏时可见, and the debug command that flips it for one screenshot without saving it.func setCapturable(_ on: Bool) { panel?.sharingType = on ? .readOnly : .none }@@ -123,6 +127,20 @@ final class NotesWindowController: NSObject, NSWindowDelegate {}}+/// The yellow button tucks the window away to the menu bar, like 收起: with only the menu bar+/// item there is no Dock to minimize into, and the panel's 打开 brings it back either way.+private final class NotesPanel: NSPanel {+ var onMiniaturize: (() -> Void)?+ // AppKit greys the button out for a floating, all-Spaces panel, and re-greys it on every+ // titlebar update; it hides instead of minimizing, so keep it lit.+ override func update() {+ super.update()+ if let b = standardWindowButton(.miniaturizeButton), !b.isEnabled { b.isEnabled = true }+ }+ override func performMiniaturize(_ sender: Any?) { onMiniaturize?() }+ override func miniaturize(_ sender: Any?) { onMiniaturize?() }+}+// MARK: - Viewsstruct NotesWindowView: View {