feat: added label to Stack widget that allow to show bluetooth device name instead of id

This commit is contained in:
Serhiy Mytrovtsiy
2026-03-30 19:05:09 +02:00
parent 663febfc53
commit 484235d015
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -14,15 +14,17 @@ import Cocoa
public struct Stack_t: KeyValue_p {
public var key: String
public var value: String
public var label: String?
var index: Int {
get { Store.shared.int(key: "stack_\(self.key)_index", defaultValue: -1) }
set { Store.shared.set(key: "stack_\(self.key)_index", value: newValue) }
}
public init(key: String, value: String) {
public init(key: String, value: String, label: String? = nil) {
self.key = key
self.value = value
self.label = label
}
}
@@ -392,7 +394,7 @@ private class OrderTableView: NSView, NSTableViewDelegate, NSTableViewDataSource
text.identifier = NSUserInterfaceItemIdentifier(item.key)
switch tableColumn?.identifier.rawValue {
case "name": text.stringValue = item.key
case "name": text.stringValue = item.label ?? item.key
default: break
}
+1 -1
View File
@@ -126,7 +126,7 @@ public class Bluetooth: Module {
active.forEach { (d: BLEDevice) in
if d.state {
d.batteryLevel.forEach { (p: KeyValue_t) in
list.append(Stack_t(key: "\(d.address)-\(p.key)", value: "\(p.value)%"))
list.append(Stack_t(key: "\(d.address)-\(p.key)", value: "\(p.value)%", label: d.name))
}
}
}