mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-10 00:58:37 +00:00
added timeZone settings for timeButton. #136
This commit is contained in:
parent
1d1d666986
commit
0775ea0412
@ -17,9 +17,9 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>0.19.1</string>
|
||||
<string>0.19.2</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>125</string>
|
||||
<string>129</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.utilities</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
|
||||
@ -325,7 +325,7 @@ class SupportedTypesHolder {
|
||||
enum ItemType: Decodable {
|
||||
case staticButton(title: String)
|
||||
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
|
||||
case timeButton(formatTemplate: String)
|
||||
case timeButton(formatTemplate: String, timeZone: String)
|
||||
case battery()
|
||||
case dock()
|
||||
case volume()
|
||||
@ -347,6 +347,7 @@ enum ItemType: Decodable {
|
||||
case from
|
||||
case to
|
||||
case full
|
||||
case timeZone
|
||||
case units
|
||||
case api_key
|
||||
case icon_type
|
||||
@ -392,7 +393,8 @@ enum ItemType: Decodable {
|
||||
|
||||
case .timeButton:
|
||||
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
|
||||
self = .timeButton(formatTemplate: template)
|
||||
let timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) ?? nil
|
||||
self = .timeButton(formatTemplate: template, timeZone: timeZone!)
|
||||
|
||||
case .battery:
|
||||
self = .battery()
|
||||
|
||||
@ -24,7 +24,7 @@ extension ItemType {
|
||||
return "com.toxblh.mtmr.staticButton."
|
||||
case .appleScriptTitledButton(source: _):
|
||||
return "com.toxblh.mtmr.appleScriptButton."
|
||||
case .timeButton(formatTemplate: _):
|
||||
case .timeButton(formatTemplate: _, timeZone: _):
|
||||
return "com.toxblh.mtmr.timeButton."
|
||||
case .battery():
|
||||
return "com.toxblh.mtmr.battery."
|
||||
@ -251,8 +251,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
||||
barItem = CustomButtonTouchBarItem(identifier: identifier, title: title)
|
||||
case .appleScriptTitledButton(source: let source, refreshInterval: let interval):
|
||||
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval)
|
||||
case .timeButton(formatTemplate: let template):
|
||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
|
||||
case .timeButton(formatTemplate: let template, timeZone: let timeZone):
|
||||
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone)
|
||||
case .battery():
|
||||
barItem = BatteryBarItem(identifier: identifier)
|
||||
case .dock:
|
||||
|
||||
@ -4,8 +4,11 @@ class TimeTouchBarItem: CustomButtonTouchBarItem {
|
||||
private let dateFormatter = DateFormatter()
|
||||
private var timer: Timer!
|
||||
|
||||
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String) {
|
||||
init(identifier: NSTouchBarItem.Identifier, formatTemplate: String, timeZone: String? = nil) {
|
||||
dateFormatter.setLocalizedDateFormatFromTemplate(formatTemplate)
|
||||
if let abbr = timeZone {
|
||||
dateFormatter.timeZone = TimeZone(abbreviation: abbr)
|
||||
}
|
||||
super.init(identifier: identifier, title: " ")
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(updateTime), userInfo: nil, repeats: true)
|
||||
isBordered = false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user