1
0
mirror of https://github.com/Toxblh/MTMR.git synced 2026-01-10 00:58:37 +00:00

remove flexSpace

This commit is contained in:
Serg 2018-04-14 02:09:34 +07:00
parent 12f9220e34
commit 9ef185d214
6 changed files with 1 additions and 23 deletions

View File

@ -115,7 +115,6 @@ enum ItemType: Decodable {
case staticButton(title: String)
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
case timeButton(formatTemplate: String)
case flexSpace()
case volume()
case brightness()
@ -132,7 +131,6 @@ enum ItemType: Decodable {
case staticButton
case appleScriptTitledButton
case timeButton
case flexSpace
case volume
case brightness
}
@ -151,8 +149,6 @@ enum ItemType: Decodable {
case .timeButton:
let template = try container.decodeIfPresent(String.self, forKey: .formatTemplate) ?? "HH:mm"
self = .timeButton(formatTemplate: template)
case .flexSpace:
self = .flexSpace()
case .volume:
self = .volume()
case .brightness:
@ -212,8 +208,6 @@ func ==(lhs: ItemType, rhs: ItemType) -> Bool {
switch (lhs, rhs) {
case let (.staticButton(a), .staticButton(b)):
return a == b
case let (.flexSpace(a), .flexSpace(b)):
return a == b
case let (.appleScriptTitledButton(a, b), .appleScriptTitledButton(c, d)):
return a == c && b == d

View File

@ -23,8 +23,6 @@ extension ItemType {
return "com.toxblh.mtmr.appleScriptButton."
case .timeButton(formatTemplate: _):
return "com.toxblh.mtmr.timeButton."
case .flexSpace():
return "NSTouchBarItem.Identifier.flexibleSpace"
case .volume():
return "com.toxblh.mtmr.volume"
case .brightness():
@ -81,9 +79,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
for item in jsonItems {
let identifierString = item.type.identifierBase.appending(UUID().uuidString)
let identifier = item.type == ItemType.flexSpace()
? NSTouchBarItem.Identifier.flexibleSpace
: NSTouchBarItem.Identifier(identifierString)
let identifier = NSTouchBarItem.Identifier(identifierString)
itemDefinitions[identifier] = item
if item.align == .left {
leftIdentifiers.append(identifier)
@ -144,8 +140,6 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
barItem = AppleScriptTouchBarItem(identifier: identifier, source: source, interval: interval, onTap: action)
case .timeButton(formatTemplate: let template):
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template)
case .flexSpace:
barItem = nil
case .volume:
barItem = VolumeViewController(identifier: identifier)
case .brightness:

View File

@ -11,7 +11,6 @@
"keycode": 113,
"width": 36,
},
{ "type": "flexSpace" },
{ "type": "volumeDown", "width": 44 },
{ "type": "volumeUp", "width": 44 },
{ "type": "previous" },

View File

@ -101,11 +101,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
"formatTemplate": "HH:mm" //optional
```
- `flexSpace` to easily split touch bar in two parts: left and right
```json
"type": "flexSpace"
```
## Actions:
- `hidKey`
```json
@ -183,7 +178,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
},
"refreshInterval": 1
},
{ "type": "flexSpace" },
{ "type": "previous", "width": 36 },
{ "type": "play", "width": 36 },
{ "type": "next", "width": 36 },
@ -214,7 +208,6 @@ File for customize your preset for MTMR: `open ~/Library/Application Support/MTM
"action": "appleScript", "actionAppleScript": {"inline": "if application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with w in windows\r\t\t\trepeat with t in tabs of w\r\t\t\t\ttell t\r\t\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then --последнее условие проверяет, запущена ли музыка\r\t\t\t\t\t\tactivate\r\t\t\t\t\t\tset index of w to 1\r\t\t\t\t\t\tdelay 0.1\r\t\t\t\t\t\tset current tab of w to t\r\t\t\t\t\tend if\r\t\t\t\tend tell\r\t\t\tend repeat\r\t\tend repeat\r\tend tell\rend if"},
},
{ "type": "appleScriptTitledButton", "source": { "inline": "tell application \"Reminders\"\r\tset activeReminders to name of (reminders of list \"Напоминания\" whose completed is false)\r\tif activeReminders is not {} then\r\t\treturn first item of activeReminders\r\telse\r\t\treturn \"\"\r\tend if\rend tell" }, "refreshInterval": 30},
{ "type": "flexSpace" },
{ "type": "appleScriptTitledButton", "source": { "inline": "if application \"iTunes\" is running then\r\ttell application \"iTunes\"\r\t\tif player state is not stopped then return \"\"\r\tend tell\rend if\rif application \"Safari\" is running then\r\ttell application \"Safari\"\r\t\trepeat with t in tabs of windows\r\t\t\ttell t\r\t\t\t\tif URL starts with \"https:\/\/music.yandex.ru\" and name does not end with \"на Яндекс.Музыке\" then\r\t\t\t\t\treturn \"\"\r\t\t\t\tend if\r\t\t\tend tell\r\t\tend repeat\r\tend tell\rend if\rreturn \"▶\"" }, "refreshInterval": 30, "width": 40},
{ "type": "volumeDown", "width": 44 },
{ "type": "volumeUp", "width": 44 },

View File

@ -24,7 +24,6 @@
},
"refreshInterval": 30
},
{ "type": "flexSpace" },
{
"type": "appleScriptTitledButton",
"source": {

View File

@ -40,7 +40,6 @@
},
"refreshInterval": 1
},
{ "type": "flexSpace" },
{ "type": "play", "width": 36 },
{ "type": "next", "width": 36 },
{ "type": "sleep", "width": 36 },