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

Created and passed the autoResize parameter to the dock widget

This commit is contained in:
willsunnn 2019-05-09 22:04:10 -07:00
parent 7c9dd26eb0
commit 3bde1fe4b1
No known key found for this signature in database
GPG Key ID: CFC1084E3C414094
6 changed files with 27 additions and 16 deletions

View File

@ -283,7 +283,6 @@
6027D1B72080E52A004FFDC7 /* BrightnessViewController.swift */,
607EEA4C2087A8DA009DA5F0 /* CurrencyBarItem.swift */,
B081732B213739FE005D4908 /* DnDBarItem.swift */,
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
60F7D453208CC31400ABF5D2 /* InputSourceBarItem.swift */,
60C44AFC20A373A100C0EC91 /* MusicBarItem.swift */,
B0846A742220C968000288A7 /* NetworkBarItem.swift */,
@ -293,6 +292,7 @@
6027D1B82080E52A004FFDC7 /* VolumeViewController.swift */,
607EEA4A2087835F009DA5F0 /* WeatherBarItem.swift */,
B08126F0217BE19000A98970 /* WidgetProtocol.swift */,
60669B4220AD8FA80074E817 /* GroupBarItem.swift */,
);
path = Widgets;
sourceTree = "<group>";
@ -633,7 +633,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = D6D8BR2QNB;
DEVELOPMENT_TEAM = P5KK92AA97;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks",

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14313.18"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14490.70"/>
</dependencies>
<scenes>
<!--Application-->
@ -619,7 +619,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleSourceList:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="iwa-gc-5KM"/>
</connections>
</menuItem>
<menuItem title="Enter Full Screen" keyEquivalent="f" id="4J7-dP-txa">

View File

@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>0.20.3</string>
<key>CFBundleVersion</key>
<string>201</string>
<string>220</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSMinimumSystemVersion</key>

View File

@ -197,9 +197,12 @@ class SupportedTypesHolder {
)
},
"dock": { _ in
(
item: .dock(),
"dock": { decoder in
enum CodingKeys: String, CodingKey { case autoResize }
let container = try decoder.container(keyedBy: CodingKeys.self)
let autoResize = try container.decodeIfPresent(Bool.self, forKey: .autoResize) ?? false
return (
item: .dock(autoResize: autoResize),
action: .none,
longAction: .none,
parameters: [:]
@ -327,7 +330,7 @@ enum ItemType: Decodable {
case appleScriptTitledButton(source: SourceProtocol, refreshInterval: Double)
case timeButton(formatTemplate: String, timeZone: String?)
case battery()
case dock()
case dock(autoResize: Bool)
case volume()
case brightness(refreshInterval: Double)
case weather(interval: Double, units: String, api_key: String, icon_type: String)
@ -360,6 +363,7 @@ enum ItemType: Decodable {
case workTime
case restTime
case flip
case autoResize
}
enum ItemTypeRaw: String, Decodable {
@ -403,7 +407,8 @@ enum ItemType: Decodable {
self = .battery()
case .dock:
self = .dock()
let autoResize = try container.decodeIfPresent(Bool.self, forKey: .autoResize) ?? false
self = .dock(autoResize: autoResize)
case .volume:
self = .volume()

View File

@ -27,7 +27,7 @@ extension ItemType {
return "com.toxblh.mtmr.timeButton."
case .battery():
return "com.toxblh.mtmr.battery."
case .dock():
case .dock(autoResize: _):
return "com.toxblh.mtmr.dock"
case .volume():
return "com.toxblh.mtmr.volume"
@ -251,8 +251,8 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
barItem = TimeTouchBarItem(identifier: identifier, formatTemplate: template, timeZone: timeZone)
case .battery():
barItem = BatteryBarItem(identifier: identifier)
case .dock:
barItem = AppScrubberTouchBarItem(identifier: identifier)
case let .dock(autoResize: autoResize):
barItem = AppScrubberTouchBarItem(identifier: identifier, autoResize: autoResize)
case .volume:
if case let .image(source)? = item.additionalParameters[.image] {
barItem = VolumeViewController(identifier: identifier, image: source.image)

View File

@ -17,6 +17,7 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
private let minTicks: Int = 5
private let maxTicks: Int = 20
private var lastSelected: Int = 0
private var autoResize: Bool = false
private var persistentAppIdentifiers: [String] = []
private var runningAppsIdentifiers: [String] = []
@ -27,10 +28,15 @@ class AppScrubberTouchBarItem: NSCustomTouchBarItem, NSScrubberDelegate, NSScrub
}
private var applications: [DockItem] = []
convenience override init(identifier: NSTouchBarItem.Identifier) {
self.init(identifier: identifier, autoResize: false)
}
override init(identifier: NSTouchBarItem.Identifier) {
init(identifier: NSTouchBarItem.Identifier, autoResize: Bool) {
super.init(identifier: identifier)
self.autoResize = autoResize
scrubber = NSScrubber()
scrubber.delegate = self
scrubber.dataSource = self