mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-14 00:04:15 +09:00
feat: moved App settings from the menu to the bottom part of the sidebar
This commit is contained in:
@@ -276,12 +276,8 @@ private class SidebarView: NSStackView {
|
||||
private var pauseButton: NSButton? = nil
|
||||
|
||||
private var pauseState: Bool {
|
||||
get {
|
||||
return Store.shared.bool(key: "pause", defaultValue: false)
|
||||
}
|
||||
set {
|
||||
Store.shared.set(key: "pause", value: newValue)
|
||||
}
|
||||
get { Store.shared.bool(key: "pause", defaultValue: false) }
|
||||
set { Store.shared.set(key: "pause", value: newValue) }
|
||||
}
|
||||
|
||||
private var dashboardIcon: NSImage {
|
||||
@@ -291,7 +287,7 @@ private class SidebarView: NSStackView {
|
||||
return NSImage(named: NSImage.Name("apps"))!
|
||||
}
|
||||
private var settingsIcon: NSImage {
|
||||
if #available(macOS 11.0, *), let icon = NSImage(systemSymbolName: "gear", accessibilityDescription: nil) {
|
||||
if #available(macOS 11.0, *), let icon = iconFromSymbol(name: "gear", scale: .large) {
|
||||
return icon
|
||||
}
|
||||
return NSImage(named: NSImage.Name("settings"))!
|
||||
@@ -343,7 +339,6 @@ private class SidebarView: NSStackView {
|
||||
|
||||
self.scrollView.stackView.addArrangedSubview(MenuItem(icon: self.dashboardIcon, title: "Dashboard"))
|
||||
self.scrollView.stackView.addArrangedSubview(spacer)
|
||||
self.scrollView.stackView.addArrangedSubview(MenuItem(icon: self.settingsIcon, title: "Settings"))
|
||||
|
||||
self.supportPopover.behavior = .transient
|
||||
self.supportPopover.contentViewController = self.supportView()
|
||||
@@ -358,8 +353,9 @@ private class SidebarView: NSStackView {
|
||||
let pauseButton = self.makeButton(title: localizedString("Pause the Stats"), image: self.pauseState ? self.resumeIcon : self.pauseIcon, action: #selector(togglePause))
|
||||
self.pauseButton = pauseButton
|
||||
|
||||
additionalButtons.addArrangedSubview(self.makeButton(title: localizedString("Report a bug"), image: self.bugIcon, action: #selector(reportBug)))
|
||||
additionalButtons.addArrangedSubview(self.makeButton(title: localizedString("Settings"), image: self.settingsIcon, action: #selector(openSettings)))
|
||||
additionalButtons.addArrangedSubview(self.makeButton(title: localizedString("Support the application"), image: self.supportIcon, action: #selector(donate)))
|
||||
additionalButtons.addArrangedSubview(self.makeButton(title: localizedString("Report a bug"), image: self.bugIcon, action: #selector(reportBug)))
|
||||
additionalButtons.addArrangedSubview(pauseButton)
|
||||
additionalButtons.addArrangedSubview(self.makeButton(title: localizedString("Close application"), image: self.closeIcon, action: #selector(closeApp)))
|
||||
|
||||
@@ -401,10 +397,6 @@ private class SidebarView: NSStackView {
|
||||
let menu: NSView = MenuItem(icon: m.config.icon, title: m.config.name)
|
||||
self.scrollView.stackView.insertArrangedSubview(menu, at: 2)
|
||||
}
|
||||
|
||||
let spacer = NSView()
|
||||
spacer.heightAnchor.constraint(equalToConstant: 10).isActive = true
|
||||
self.scrollView.stackView.insertArrangedSubview(spacer, at: self.scrollView.stackView.subviews.count - 1)
|
||||
}
|
||||
|
||||
private func makeButton(title: String, image: NSImage, action: Selector) -> NSButton {
|
||||
@@ -420,9 +412,9 @@ private class SidebarView: NSStackView {
|
||||
button.action = action
|
||||
button.target = self
|
||||
button.focusRingType = .none
|
||||
button.widthAnchor.constraint(equalToConstant: 45).isActive = true
|
||||
button.widthAnchor.constraint(equalToConstant: 33).isActive = true
|
||||
|
||||
let rect = NSRect(x: 0, y: 0, width: 45, height: 45)
|
||||
let rect = NSRect(x: 0, y: 0, width: 33, height: 45)
|
||||
let trackingArea = NSTrackingArea(
|
||||
rect: rect,
|
||||
options: [NSTrackingArea.Options.activeAlways, NSTrackingArea.Options.mouseEnteredAndExited, NSTrackingArea.Options.activeInActiveApp],
|
||||
@@ -436,9 +428,9 @@ private class SidebarView: NSStackView {
|
||||
|
||||
private func supportView() -> NSViewController {
|
||||
let vc: NSViewController = NSViewController(nibName: nil, bundle: nil)
|
||||
let view: NSStackView = NSStackView(frame: NSRect(x: 0, y: 0, width: 160, height: 40))
|
||||
view.spacing = 7
|
||||
view.edgeInsets = NSEdgeInsets(top: 0, left: 8, bottom: 0, right: 0)
|
||||
let view: NSStackView = NSStackView(frame: NSRect(x: 0, y: 0, width: 180, height: 54))
|
||||
view.spacing = 10
|
||||
view.edgeInsets = NSEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
|
||||
view.orientation = .horizontal
|
||||
|
||||
let github = SupportButtonView(name: "GitHub Sponsors", image: "github", action: {
|
||||
@@ -463,6 +455,10 @@ private class SidebarView: NSStackView {
|
||||
return vc
|
||||
}
|
||||
|
||||
@objc private func openSettings() {
|
||||
NotificationCenter.default.post(name: .openModuleSettings, object: nil, userInfo: ["module": "Settings"])
|
||||
}
|
||||
|
||||
@objc private func reportBug() {
|
||||
NSWorkspace.shared.open(URL(string: "https://github.com/exelban/stats/issues/new")!)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user