Skip to content

Commit b8973f1

Browse files
committed
finished general tab in settings + app icon
1 parent 0d1e7c2 commit b8973f1

17 files changed

Lines changed: 230 additions & 16 deletions

NumWorksMac/App/AppController.swift

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ final class AppController: NSObject, NSWindowDelegate {
88
let windowManagement = WindowManagement()
99
private var menuBarController: MenuBarController?
1010
private var cancellables = Set<AnyCancellable>()
11+
private var settingsWindowOpen = false
1112

1213
private var suppressFrameSaves = false
1314
private let windowFrameDefaultsKey = "MainWindowFrame"
@@ -23,21 +24,12 @@ final class AppController: NSObject, NSWindowDelegate {
2324
}
2425

2526
private func applyDockIconVisibility() {
26-
let show = Preferences.shared.showDockIcon
27+
let show = settingsWindowOpen ? true : Preferences.shared.showDockIcon
2728
let policy: NSApplication.ActivationPolicy = show ? .regular : .accessory
2829

2930
if NSApp.activationPolicy() != policy {
3031
_ = NSApp.setActivationPolicy(policy)
3132
}
32-
33-
if Preferences.shared.isAppVisible {
34-
windowManagement.show()
35-
if Preferences.shared.isPinned {
36-
windowManagement.setPinned(true)
37-
}
38-
}
39-
40-
NSApp.activate(ignoringOtherApps: true)
4133
}
4234

4335
func start() {
@@ -78,6 +70,22 @@ final class AppController: NSObject, NSWindowDelegate {
7870
}
7971
.store(in: &cancellables)
8072

73+
NotificationCenter.default.publisher(for: .settingsWindowDidAppear)
74+
.receive(on: RunLoop.main)
75+
.sink { [weak self] _ in
76+
self?.settingsWindowOpen = true
77+
self?.applyDockIconVisibility()
78+
}
79+
.store(in: &cancellables)
80+
81+
NotificationCenter.default.publisher(for: .settingsWindowDidDisappear)
82+
.receive(on: RunLoop.main)
83+
.sink { [weak self] _ in
84+
self?.settingsWindowOpen = false
85+
self?.applyDockIconVisibility()
86+
}
87+
.store(in: &cancellables)
88+
8189
NotificationCenter.default.publisher(for: NSWindow.didChangeOcclusionStateNotification, object: windowManagement.nsWindow)
8290
.sink { [weak self] _ in
8391
guard let self else { return }

NumWorksMac/App/NumWorksMacApp.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ struct NumWorksMacApp: App {
88
Settings {
99
SettingsView()
1010
}
11+
.defaultSize(width: 520, height: 420)
1112
.commands {
1213
CommandGroup(replacing: .appSettings) {
1314
SettingsLink {
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon_16x16.png",
5+
"idiom" : "mac",
6+
"scale" : "1x",
7+
"size" : "16x16"
8+
},
9+
{
10+
"filename" : "icon_16x16@2x.png",
11+
"idiom" : "mac",
12+
"scale" : "2x",
13+
"size" : "16x16"
14+
},
15+
{
16+
"filename" : "icon_32x32.png",
17+
"idiom" : "mac",
18+
"scale" : "1x",
19+
"size" : "32x32"
20+
},
21+
{
22+
"filename" : "icon_32x32@2x.png",
23+
"idiom" : "mac",
24+
"scale" : "2x",
25+
"size" : "32x32"
26+
},
27+
{
28+
"filename" : "icon_128x128.png",
29+
"idiom" : "mac",
30+
"scale" : "1x",
31+
"size" : "128x128"
32+
},
33+
{
34+
"filename" : "icon_128x128@2x.png",
35+
"idiom" : "mac",
36+
"scale" : "2x",
37+
"size" : "128x128"
38+
},
39+
{
40+
"filename" : "icon_256x256.png",
41+
"idiom" : "mac",
42+
"scale" : "1x",
43+
"size" : "256x256"
44+
},
45+
{
46+
"filename" : "icon_256x256@2x.png",
47+
"idiom" : "mac",
48+
"scale" : "2x",
49+
"size" : "256x256"
50+
},
51+
{
52+
"filename" : "icon_512x512.png",
53+
"idiom" : "mac",
54+
"scale" : "1x",
55+
"size" : "512x512"
56+
},
57+
{
58+
"filename" : "icon_512x512@2x.png",
59+
"idiom" : "mac",
60+
"scale" : "2x",
61+
"size" : "512x512"
62+
}
63+
],
64+
"info" : {
65+
"author" : "xcode",
66+
"version" : 1
67+
}
68+
}
5.54 KB
Loading
13.2 KB
Loading
671 Bytes
Loading
1.37 KB
Loading
13.2 KB
Loading
34.5 KB
Loading
1.37 KB
Loading

0 commit comments

Comments
 (0)