Skip to content

Commit

Permalink
feat: changed icons to text buttons for application settings import/e…
Browse files Browse the repository at this point in the history
…xport/reset
  • Loading branch information
exelban committed Feb 6, 2025
1 parent 11158df commit f9b522a
Show file tree
Hide file tree
Showing 20 changed files with 34 additions and 142 deletions.
9 changes: 9 additions & 0 deletions Kit/extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,15 @@ public extension NSView {
return s
}

func buttonView(_ action: Selector, text: String) -> NSButton {
let button = NSButton()
button.title = text
button.contentTintColor = .labelColor
button.action = action
button.target = self
return button
}

func buttonIconView(_ action: Selector, icon: NSImage, height: CGFloat = 22) -> NSButton {
let button = NSButton()
button.heightAnchor.constraint(equalToConstant: height).isActive = true
Expand Down
8 changes: 6 additions & 2 deletions Kit/helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,9 @@ public class EmptyView: NSStackView {
public init(height: CGFloat = 120, isHidden: Bool = false, msg: String) {
super.init(frame: NSRect())

self.heightAnchor.constraint(equalToConstant: height).isActive = true
if height != 0 {
self.heightAnchor.constraint(equalToConstant: height).isActive = true
}

self.translatesAutoresizingMaskIntoConstraints = true
self.orientation = .vertical
Expand All @@ -1049,7 +1051,9 @@ public class EmptyView: NSStackView {
self.identifier = NSUserInterfaceItemIdentifier(rawValue: "emptyView")

let textView: NSTextView = NSTextView()
textView.heightAnchor.constraint(equalToConstant: (height/2)+6).isActive = true
if height != 0 {
textView.heightAnchor.constraint(equalToConstant: ((height)/2)+6).isActive = true
}
textView.alignment = .center
textView.isEditable = false
textView.isSelectable = false
Expand Down

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions Stats/Supporting Files/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
"15 sec" = "15 sec";
"30 sec" = "30 sec";
"60 sec" = "60 sec";
"Save" = "Save";
"Browse" = "Browse";
"Run" = "Run";
"Stop" = "Stop";

// Setup
"Stats Setup" = "Stats Setup";
Expand Down
47 changes: 15 additions & 32 deletions Stats/Views/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,6 @@ class ApplicationSettings: NSStackView {
set { Store.shared.set(key: "CombinedModules_popup", value: newValue) }
}

private var importIcon: NSImage {
if #available(macOS 12.0, *), let icon = iconFromSymbol(name: "square.and.arrow.down", scale: .large) {
return icon
}
return NSImage(named: NSImage.Name("import"))!
}
private var exportIcon: NSImage {
if #available(macOS 12.0, *), let icon = iconFromSymbol(name: "square.and.arrow.up", scale: .large) {
return icon
}
return NSImage(named: NSImage.Name("export"))!
}
private var resetIcon: NSImage {
if #available(macOS 12.0, *), let icon = iconFromSymbol(name: "trash", scale: .large) {
return icon
}
return NSImage(named: NSImage.Name("trash"))!
}
private var uninstallIcon: NSImage {
if #available(macOS 12.0, *), let icon = iconFromSymbol(name: "xmark.circle", scale: .large) {
return icon
}
return NSImage(named: NSImage.Name("cancel"))!
}

private var updateSelector: NSPopUpButton?
private var startAtLoginBtn: NSSwitch?
private var telemetryBtn: NSSwitch?
Expand All @@ -74,6 +49,14 @@ class ApplicationSettings: NSStackView {
private let updateWindow: UpdateWindow = UpdateWindow()
private let moduleSelector: ModuleSelectorView = ModuleSelectorView()

private var CPUeButton: NSButton?
private var CPUpButton: NSButton?
private var GPUButton: NSButton?

private var CPUeTest: CPUeStressTest = CPUeStressTest()
private var CPUpTest: CPUpStressTest = CPUpStressTest()
private var GPUTest: GPUStressTest? = GPUStressTest()

init() {
super.init(frame: NSRect(x: 0, y: 0, width: Constants.Settings.width, height: Constants.Settings.height))
self.translatesAutoresizingMaskIntoConstraints = false
Expand Down Expand Up @@ -144,25 +127,25 @@ class ApplicationSettings: NSStackView {
self.combinedModulesView?.setRowVisibility(3, newState: self.combinedModulesState)
self.combinedModulesView?.setRowVisibility(4, newState: self.combinedModulesState)

scrollView.stackView.addArrangedSubview(PreferencesSection([
scrollView.stackView.addArrangedSubview(PreferencesSection(label: localizedString("Settings"), [
PreferencesRow(
localizedString("Import settings"),
component: buttonIconView(#selector(self.importSettings), icon: self.importIcon)
localizedString("Export settings"),
component: buttonView(#selector(self.exportSettings), text: localizedString("Save"))
),
PreferencesRow(
localizedString("Export settings"),
component: buttonIconView(#selector(self.exportSettings), icon: self.exportIcon)
localizedString("Import settings"),
component: buttonView(#selector(self.importSettings), text: localizedString("Browse"))
),
PreferencesRow(
localizedString("Reset settings"),
component: buttonIconView(#selector(self.resetSettings), icon: self.resetIcon)
component: buttonView(#selector(self.resetSettings), text: localizedString("Reset"))
)
]))

self.fanHelperView = PreferencesSection([
PreferencesRow(
localizedString("Uninstall fan helper"),
component: buttonIconView(#selector(self.uninstallHelper), icon: self.uninstallIcon)
component: buttonView(#selector(self.uninstallHelper), text: localizedString("Uninstall"))
)
])
scrollView.stackView.addArrangedSubview(self.fanHelperView!)
Expand Down

0 comments on commit f9b522a

Please sign in to comment.