qstatus/qStatus/Windows/FloatingPanel.swift
Paweł Orzech c27437b33c
Initial implementation of qStatus macOS menubar app
Native macOS app for posting to Mastodon, WordPress (self-hosted), and Micro.blog.
Features: global hotkey (Ctrl+Option+Cmd+T), multiple accounts with selection,
image attachments (up to 4, drag-and-drop), floating panel UI, Keychain storage.
2026-02-27 23:40:51 +01:00

34 lines
970 B
Swift

import AppKit
import SwiftUI
final class FloatingPanel: NSPanel {
init(contentView: some View) {
super.init(
contentRect: NSRect(x: 0, y: 0, width: 440, height: 380),
styleMask: [.titled, .closable, .fullSizeContentView, .nonactivatingPanel],
backing: .buffered,
defer: false
)
isFloatingPanel = true
level = .floating
titleVisibility = .hidden
titlebarAppearsTransparent = true
isMovableByWindowBackground = true
isReleasedWhenClosed = false
animationBehavior = .utilityWindow
hidesOnDeactivate = false
collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
backgroundColor = .windowBackgroundColor
self.contentView = NSHostingView(rootView: contentView)
center()
}
override var canBecomeKey: Bool { true }
override func cancelOperation(_ sender: Any?) {
close()
}
}