feat: changed icons to text buttons for application settings import/export/reset

This commit is contained in:
Serhiy Mytrovtsiy
2025-02-06 16:33:42 +01:00
parent 11158df5b1
commit f9b522aeb3
20 changed files with 35 additions and 143 deletions

View File

@@ -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

View File

@@ -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
@@ -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

View File

@@ -1,27 +0,0 @@
{
"images": [
{
"filename": "baseline_cancel_black_24pt_1x.png",
"idiom": "universal",
"scale": "1x",
"size": "24x24"
},
{
"filename": "baseline_cancel_black_24pt_2x.png",
"idiom": "universal",
"scale": "2x",
"size": "24x24"
},
{
"filename": "baseline_cancel_black_24pt_3x.png",
"idiom": "universal",
"scale": "3x",
"size": "24x24"
}
],
"info": {
"author": "xcode",
"template-rendering-intent": "template",
"version": 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 223 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 541 B

View File

@@ -1,27 +0,0 @@
{
"images": [
{
"filename": "baseline_ios_share_black_24pt_1x.png",
"idiom": "universal",
"scale": "1x",
"size": "24x24"
},
{
"filename": "baseline_ios_share_black_24pt_2x.png",
"idiom": "universal",
"scale": "2x",
"size": "24x24"
},
{
"filename": "baseline_ios_share_black_24pt_3x.png",
"idiom": "universal",
"scale": "3x",
"size": "24x24"
}
],
"info": {
"author": "xcode",
"template-rendering-intent": "template",
"version": 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 167 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 362 B

View File

@@ -1,27 +0,0 @@
{
"images": [
{
"filename": "baseline_download_black_24pt_1x.png",
"idiom": "universal",
"scale": "1x",
"size": "24x24"
},
{
"filename": "baseline_download_black_24pt_2x.png",
"idiom": "universal",
"scale": "2x",
"size": "24x24"
},
{
"filename": "baseline_download_black_24pt_3x.png",
"idiom": "universal",
"scale": "3x",
"size": "24x24"
}
],
"info": {
"author": "xcode",
"template-rendering-intent": "template",
"version": 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 B

View File

@@ -1,27 +0,0 @@
{
"images": [
{
"filename": "baseline_delete_black_24pt_1x.png",
"idiom": "universal",
"scale": "1x",
"size": "24x24"
},
{
"filename": "baseline_delete_black_24pt_2x.png",
"idiom": "universal",
"scale": "2x",
"size": "24x24"
},
{
"filename": "baseline_delete_black_24pt_3x.png",
"idiom": "universal",
"scale": "3x",
"size": "24x24"
}
],
"info": {
"author": "xcode",
"template-rendering-intent": "template",
"version": 1
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 B

View File

@@ -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";

View File

@@ -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?
@@ -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
@@ -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([
PreferencesRow(
localizedString("Import settings"),
component: buttonIconView(#selector(self.importSettings), icon: self.importIcon)
),
scrollView.stackView.addArrangedSubview(PreferencesSection(label: localizedString("Settings"), [
PreferencesRow(
localizedString("Export settings"),
component: buttonIconView(#selector(self.exportSettings), icon: self.exportIcon)
component: buttonView(#selector(self.exportSettings), text: localizedString("Save"))
),
PreferencesRow(
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!)