fix: hide dock icon when main window closes
This commit is contained in:
1 parent
e9d4335db9
commit
9866773f34
2 files changed
+21
-4
No files matched your search
@@ -51,10 +51,8 @@ struct SettingsView: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
HStack(spacing: 18) {
|
||||
FixedSidebar(selection: $navigation.selection)
|
||||
.padding(.leading, 18)
|
||||
.padding(.vertical, 18)
|
||||
Group {
|
||||
switch navigation.selection {
|
||||
case .home: HomeTab()
|
||||
@@ -65,6 +63,7 @@ struct SettingsView: View {
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
||||
}
|
||||
.padding(18)
|
||||
.background(WindowCanvasBackground())
|
||||
.frame(minWidth: 1040, minHeight: 700)
|
||||
}
|
||||
@@ -138,6 +137,7 @@ private struct FixedSidebar: View {
|
||||
.padding(.top, 0)
|
||||
.padding(.bottom, 12)
|
||||
.frame(width: 264)
|
||||
.frame(maxHeight: .infinity, alignment: .top)
|
||||
.glassPanel(cornerRadius: 32)
|
||||
.onAppear { refresh() }
|
||||
.onReceive(NotificationCenter.default.publisher(for: .openLessHistoryChanged)) { _ in refresh() }
|
||||
|
||||
@@ -2,15 +2,17 @@ import AppKit
|
||||
import SwiftUI
|
||||
|
||||
@MainActor
|
||||
final class SettingsWindowController {
|
||||
final class SettingsWindowController: NSObject, NSWindowDelegate {
|
||||
private var window: NSWindow?
|
||||
private let navigation = SettingsNavigationModel()
|
||||
|
||||
func show(tab: OpenLessMainTab = .home) {
|
||||
NSApp.setActivationPolicy(.regular)
|
||||
navigation.selection = tab
|
||||
if let window = window {
|
||||
window.makeKeyAndOrderFront(nil)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
alignTrafficLights(in: window)
|
||||
return
|
||||
}
|
||||
let hosting = NSHostingController(rootView: SettingsView(navigation: navigation))
|
||||
@@ -26,6 +28,7 @@ final class SettingsWindowController {
|
||||
win.tabbingMode = .disallowed
|
||||
win.center()
|
||||
win.isReleasedWhenClosed = false
|
||||
win.delegate = self
|
||||
self.window = win
|
||||
win.makeKeyAndOrderFront(nil)
|
||||
NSApp.activate(ignoringOtherApps: true)
|
||||
@@ -35,6 +38,20 @@ final class SettingsWindowController {
|
||||
}
|
||||
}
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
NSApp.setActivationPolicy(.accessory)
|
||||
}
|
||||
|
||||
func windowDidResize(_ notification: Notification) {
|
||||
guard let window = notification.object as? NSWindow else { return }
|
||||
alignTrafficLights(in: window)
|
||||
}
|
||||
|
||||
func windowDidBecomeKey(_ notification: Notification) {
|
||||
guard let window = notification.object as? NSWindow else { return }
|
||||
alignTrafficLights(in: window)
|
||||
}
|
||||
|
||||
private func alignTrafficLights(in window: NSWindow) {
|
||||
let buttons: [NSButton?] = [
|
||||
window.standardWindowButton(.closeButton),
|
||||
|
||||
Reference in new issue
Block a user