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:
@@ -294,7 +294,7 @@ public extension NSView {
|
||||
}
|
||||
|
||||
func selectView(action: Selector, items: [KeyValue_p], selected: String) -> NSPopUpButton {
|
||||
let select: NSPopUpButton = NSPopUpButton(frame: NSRect(x: 0, y: 0, width: 50, height: 28))
|
||||
let select: NSPopUpButton = NSPopUpButton(frame: NSRect(x: 0, y: 4, width: 50, height: 28))
|
||||
select.target = self
|
||||
select.action = action
|
||||
|
||||
|
||||
@@ -1245,17 +1245,15 @@ public class PreferencesSection: NSStackView {
|
||||
|
||||
self.container.orientation = .vertical
|
||||
self.container.wantsLayer = true
|
||||
self.container.layer?.cornerRadius = 5
|
||||
self.container.layer?.borderColor = NSColor.separatorColor.withAlphaComponent(0.05).cgColor
|
||||
self.container.layer?.borderWidth = 1
|
||||
self.container.layer?.backgroundColor = NSColor.quaternaryLabelColor.withAlphaComponent(0.025).cgColor
|
||||
self.container.layer?.cornerRadius = Constants.Settings.margin
|
||||
self.container.edgeInsets = NSEdgeInsets(
|
||||
top: Constants.Settings.margin/2,
|
||||
top: Constants.Settings.margin/1.25,
|
||||
left: Constants.Settings.margin,
|
||||
bottom: Constants.Settings.margin/2,
|
||||
bottom: Constants.Settings.margin/1.25,
|
||||
right: Constants.Settings.margin
|
||||
)
|
||||
self.container.spacing = Constants.Settings.margin/2
|
||||
self.container.spacing = Constants.Settings.margin/1.25
|
||||
self.addArrangedSubview(self.container)
|
||||
|
||||
for item in components {
|
||||
@@ -1268,7 +1266,6 @@ public class PreferencesSection: NSStackView {
|
||||
}
|
||||
|
||||
public override func updateLayer() {
|
||||
self.container.layer?.borderColor = NSColor.separatorColor.withAlphaComponent(0.05).cgColor
|
||||
self.container.layer?.backgroundColor = NSColor.quaternaryLabelColor.withAlphaComponent(0.025).cgColor
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ internal class Settings: NSStackView, Settings_v, NSTableViewDelegate, NSTableVi
|
||||
if #available(macOS 11.0, *) {
|
||||
self.tableView.style = .plain
|
||||
}
|
||||
self.tableView.rowHeight = 27
|
||||
self.tableView.rowHeight = 32
|
||||
|
||||
let nameColumn = NSTableColumn(identifier: nameColumnID)
|
||||
nameColumn.headerCell.title = localizedString("Name")
|
||||
@@ -209,7 +209,7 @@ internal class Settings: NSStackView, Settings_v, NSTableViewDelegate, NSTableVi
|
||||
select.widthAnchor.constraint(lessThanOrEqualToConstant: 132).isActive = true
|
||||
cell.addSubview(select)
|
||||
case statusColumnID:
|
||||
let button: NSButton = NSButton(frame: NSRect(x: 0, y: 5, width: 10, height: 10))
|
||||
let button: NSButton = NSButton(frame: NSRect(x: 0, y: 8, width: 10, height: 10))
|
||||
button.identifier = NSUserInterfaceItemIdentifier("\(row)")
|
||||
button.setButtonType(.switch)
|
||||
button.state = item.enabled ? .on : .off
|
||||
|
||||
@@ -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