fix: send feedback crashed the app on submit (closes #172)
This commit is contained in:
1 parent
2e500b5797
commit
c34b8a51b8
3 files changed
+12
-8
No files matched your search
@@ -44,7 +44,7 @@ class DebugProfile {
|
||||
private static func appPreferences() -> String {
|
||||
return nestedSeparator + Preferences.all
|
||||
.sorted { $0.0 < $1.0 }
|
||||
.map { $0.key + intraSeparator + Preferences.getAsString($0.key)! }
|
||||
.map { $0.key + intraSeparator + Preferences.getAsString($0.key) }
|
||||
.joined(separator: nestedSeparator)
|
||||
}
|
||||
|
||||
|
||||
@@ -61,19 +61,23 @@ class Preferences {
|
||||
defaults.register(defaults: defaultValues)
|
||||
}
|
||||
|
||||
static func get(_ key: String) -> Any? {
|
||||
static func getObject(_ key: String) -> Any? {
|
||||
defaults.object(forKey: key)
|
||||
}
|
||||
|
||||
static func getAsString(_ key: String) -> String? {
|
||||
static func getString(_ key: String) -> String? {
|
||||
defaults.string(forKey: key)
|
||||
}
|
||||
|
||||
static func getAsString(_ key: String) -> String {
|
||||
String(describing: defaults.object(forKey: key))
|
||||
}
|
||||
|
||||
static func set(_ key: String, _ value: Any?) {
|
||||
defaults.set(value, forKey: key)
|
||||
}
|
||||
|
||||
static var all: [String: Any] { defaults.dictionaryRepresentation() }
|
||||
static var all: [String: Any] { defaults.persistentDomain(forName: NSRunningApplication.current.bundleIdentifier!)! }
|
||||
}
|
||||
|
||||
struct Theme {
|
||||
|
||||
@@ -2,7 +2,7 @@ import Cocoa
|
||||
|
||||
class LabelAndControl: NSObject {
|
||||
static func makeLabelWithInput(_ labelText: String, _ rawName: String, _ width: CGFloat, _ suffixText: String? = nil, _ suffixUrl: String? = nil, _ validator: ((String) -> Bool)? = nil) -> [NSView] {
|
||||
let input = TextField(Preferences.getAsString(rawName)!)
|
||||
let input = TextField(Preferences.getString(rawName)!)
|
||||
input.validationHandler = validator
|
||||
input.delegate = input
|
||||
input.visualizeValidationState()
|
||||
@@ -13,19 +13,19 @@ class LabelAndControl: NSObject {
|
||||
|
||||
static func makeLabelWithCheckbox(_ labelText: String, _ rawName: String, extraAction: ActionClosure? = nil) -> [NSView] {
|
||||
let checkbox = NSButton(checkboxWithTitle: "", target: nil, action: nil)
|
||||
setControlValue(checkbox, Preferences.getAsString(rawName)!)
|
||||
setControlValue(checkbox, Preferences.getString(rawName)!)
|
||||
return makeLabelWithProvidedControl(labelText, rawName, checkbox, extraAction: extraAction)
|
||||
}
|
||||
|
||||
static func makeLabelWithDropdown(_ labelText: String, _ rawName: String, _ values: [String], _ suffixText: String? = nil) -> [NSView] {
|
||||
let popUp = NSPopUpButton()
|
||||
popUp.addItems(withTitles: values)
|
||||
popUp.selectItem(withTitle: Preferences.getAsString(rawName)!)
|
||||
popUp.selectItem(withTitle: Preferences.getString(rawName)!)
|
||||
return makeLabelWithProvidedControl(labelText, rawName, popUp, suffixText)
|
||||
}
|
||||
|
||||
static func makeLabelWithSlider(_ labelText: String, _ rawName: String, _ minValue: Double, _ maxValue: Double, _ numberOfTickMarks: Int, _ allowsTickMarkValuesOnly: Bool, _ unitText: String = "") -> [NSView] {
|
||||
let value = Preferences.getAsString(rawName)!
|
||||
let value = Preferences.getString(rawName)!
|
||||
let suffixText = value + " " + unitText
|
||||
let slider = NSSlider()
|
||||
slider.minValue = minValue
|
||||
|
||||
Reference in new issue
Block a user