diff --git a/Juice.xcodeproj/project.pbxproj b/Juice.xcodeproj/project.pbxproj index faa079f..63bda41 100644 --- a/Juice.xcodeproj/project.pbxproj +++ b/Juice.xcodeproj/project.pbxproj @@ -30,9 +30,29 @@ 728EB93A1E061B4700920B83 /* PreferencesStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 728EB9391E061B4700920B83 /* PreferencesStorage.swift */; }; 728EB9431E06661800920B83 /* AboutPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 728EB9411E06661800920B83 /* AboutPreferencesViewController.swift */; }; 728EB9441E06661800920B83 /* AboutPreferencesViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 728EB9421E06661800920B83 /* AboutPreferencesViewController.xib */; }; + 72DA735D1E09FE19003F9262 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72DA735C1E09FE19003F9262 /* AppDelegate.swift */; }; + 72DA735F1E09FE19003F9262 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 72DA735E1E09FE19003F9262 /* Assets.xcassets */; }; + 72DA73621E09FE19003F9262 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 72DA73601E09FE19003F9262 /* MainMenu.xib */; }; + 72DA73691E09FED9003F9262 /* StartOnLaunchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72DA73681E09FED9003F9262 /* StartOnLaunchController.swift */; }; + 72DA736A1E09FED9003F9262 /* StartOnLaunchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72DA73681E09FED9003F9262 /* StartOnLaunchController.swift */; }; + 72DA736C1E09FF2E003F9262 /* JuiceHelper.app in Copy JuiceHelper */ = {isa = PBXBuildFile; fileRef = 72DA735A1E09FE19003F9262 /* JuiceHelper.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; BB1E603B06F7547FED9412FB /* Pods_Juice.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 89FE5472659FE380046C1766 /* Pods_Juice.framework */; }; /* End PBXBuildFile section */ +/* Begin PBXCopyFilesBuildPhase section */ + 72DA736B1E09FF0B003F9262 /* Copy JuiceHelper */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Contents/Library/LoginItems; + dstSubfolderSpec = 1; + files = ( + 72DA736C1E09FF2E003F9262 /* JuiceHelper.app in Copy JuiceHelper */, + ); + name = "Copy JuiceHelper"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXFileReference section */ 3C77461788BEC6533AC87A19 /* Pods-Juice.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juice.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Juice/Pods-Juice.debug.xcconfig"; sourceTree = ""; }; 7230D7521E05E8C70001F3E9 /* GeneralPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeneralPreferencesViewController.swift; path = Classes/GeneralPreferencesViewController.swift; sourceTree = ""; }; @@ -61,6 +81,14 @@ 728EB9391E061B4700920B83 /* PreferencesStorage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = PreferencesStorage.swift; path = Classes/PreferencesStorage.swift; sourceTree = ""; }; 728EB9411E06661800920B83 /* AboutPreferencesViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AboutPreferencesViewController.swift; path = Classes/AboutPreferencesViewController.swift; sourceTree = ""; }; 728EB9421E06661800920B83 /* AboutPreferencesViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = AboutPreferencesViewController.xib; path = Classes/AboutPreferencesViewController.xib; sourceTree = ""; }; + 72DA735A1E09FE19003F9262 /* JuiceHelper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = JuiceHelper.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 72DA735C1E09FE19003F9262 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 72DA735E1E09FE19003F9262 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 72DA73611E09FE19003F9262 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; + 72DA73631E09FE19003F9262 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 72DA73681E09FED9003F9262 /* StartOnLaunchController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StartOnLaunchController.swift; path = Juice/Classes/StartOnLaunchController.swift; sourceTree = ""; }; + 72DA736D1E09FF45003F9262 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; }; + 72DAC54A1E0A0A050036E3BF /* JuiceHelper.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = JuiceHelper.entitlements; sourceTree = ""; }; 77622EE75A5C033BF8EAACB4 /* Pods-Juice.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juice.release.xcconfig"; path = "Pods/Target Support Files/Pods-Juice/Pods-Juice.release.xcconfig"; sourceTree = ""; }; 89FE5472659FE380046C1766 /* Pods_Juice.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Juice.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -74,6 +102,13 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72DA73571E09FE19003F9262 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ @@ -98,7 +133,9 @@ 725AA5B31E05BF3A006E5DDE = { isa = PBXGroup; children = ( + 72DA73671E09FEA7003F9262 /* Shared */, 725AA5BE1E05BF3A006E5DDE /* Juice */, + 72DA735B1E09FE19003F9262 /* JuiceHelper */, 725AA5BD1E05BF3A006E5DDE /* Products */, A49489D7401DD5FE5654CC8B /* Pods */, F424A84904A6C0FD21B47862 /* Frameworks */, @@ -109,6 +146,7 @@ isa = PBXGroup; children = ( 725AA5BC1E05BF3A006E5DDE /* Juice.app */, + 72DA735A1E09FE19003F9262 /* JuiceHelper.app */, ); name = Products; sourceTree = ""; @@ -199,6 +237,26 @@ name = About; sourceTree = ""; }; + 72DA735B1E09FE19003F9262 /* JuiceHelper */ = { + isa = PBXGroup; + children = ( + 72DAC54A1E0A0A050036E3BF /* JuiceHelper.entitlements */, + 72DA735C1E09FE19003F9262 /* AppDelegate.swift */, + 72DA735E1E09FE19003F9262 /* Assets.xcassets */, + 72DA73601E09FE19003F9262 /* MainMenu.xib */, + 72DA73631E09FE19003F9262 /* Info.plist */, + ); + path = JuiceHelper; + sourceTree = ""; + }; + 72DA73671E09FEA7003F9262 /* Shared */ = { + isa = PBXGroup; + children = ( + 72DA73681E09FED9003F9262 /* StartOnLaunchController.swift */, + ); + name = Shared; + sourceTree = ""; + }; A49489D7401DD5FE5654CC8B /* Pods */ = { isa = PBXGroup; children = ( @@ -211,6 +269,7 @@ F424A84904A6C0FD21B47862 /* Frameworks */ = { isa = PBXGroup; children = ( + 72DA736D1E09FF45003F9262 /* ServiceManagement.framework */, 89FE5472659FE380046C1766 /* Pods_Juice.framework */, ); name = Frameworks; @@ -229,6 +288,7 @@ 725AA5BA1E05BF3A006E5DDE /* Resources */, D2DB0B28616C3280A83203AD /* [CP] Embed Pods Frameworks */, 5F28ED56966804616466A5BC /* [CP] Copy Pods Resources */, + 72DA736B1E09FF0B003F9262 /* Copy JuiceHelper */, ); buildRules = ( ); @@ -239,6 +299,23 @@ productReference = 725AA5BC1E05BF3A006E5DDE /* Juice.app */; productType = "com.apple.product-type.application"; }; + 72DA73591E09FE19003F9262 /* JuiceHelper */ = { + isa = PBXNativeTarget; + buildConfigurationList = 72DA73661E09FE19003F9262 /* Build configuration list for PBXNativeTarget "JuiceHelper" */; + buildPhases = ( + 72DA73561E09FE19003F9262 /* Sources */, + 72DA73571E09FE19003F9262 /* Frameworks */, + 72DA73581E09FE19003F9262 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = JuiceHelper; + productName = JuiceHelper; + productReference = 72DA735A1E09FE19003F9262 /* JuiceHelper.app */; + productType = "com.apple.product-type.application"; + }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -259,6 +336,16 @@ }; }; }; + 72DA73591E09FE19003F9262 = { + CreatedOnToolsVersion = 8.2; + DevelopmentTeam = YN24FFRTC8; + ProvisioningStyle = Automatic; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 1; + }; + }; + }; }; }; buildConfigurationList = 725AA5B71E05BF3A006E5DDE /* Build configuration list for PBXProject "Juice" */; @@ -275,6 +362,7 @@ projectRoot = ""; targets = ( 725AA5BB1E05BF3A006E5DDE /* Juice */, + 72DA73591E09FE19003F9262 /* JuiceHelper */, ); }; /* End PBXProject section */ @@ -293,6 +381,15 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + 72DA73581E09FE19003F9262 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 72DA735F1E09FE19003F9262 /* Assets.xcassets in Resources */, + 72DA73621E09FE19003F9262 /* MainMenu.xib in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ @@ -362,12 +459,22 @@ 728EB93A1E061B4700920B83 /* PreferencesStorage.swift in Sources */, 725AA5DD1E05D3CD006E5DDE /* StatusItemMenu.swift in Sources */, 7230D7541E05E8C70001F3E9 /* GeneralPreferencesViewController.swift in Sources */, + 72DA73691E09FED9003F9262 /* StartOnLaunchController.swift in Sources */, 728EB9361E060DA900920B83 /* FileBackedChargeScaleDisplay.swift in Sources */, 728EB9311E06033300920B83 /* PowerSource+Extensions.swift in Sources */, 7230D7591E05F4960001F3E9 /* CreditsPreferencesViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; + 72DA73561E09FE19003F9262 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 72DA736A1E09FED9003F9262 /* StartOnLaunchController.swift in Sources */, + 72DA735D1E09FE19003F9262 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXSourcesBuildPhase section */ /* Begin PBXVariantGroup section */ @@ -379,6 +486,14 @@ name = MainMenu.xib; sourceTree = ""; }; + 72DA73601E09FE19003F9262 /* MainMenu.xib */ = { + isa = PBXVariantGroup; + children = ( + 72DA73611E09FE19003F9262 /* Base */, + ); + name = MainMenu.xib; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -482,7 +597,7 @@ CODE_SIGN_ENTITLEMENTS = Juice/Juice.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2016.12.18033401; + CURRENT_PROJECT_VERSION = 529; DEVELOPMENT_TEAM = YN24FFRTC8; INFOPLIST_FILE = Juice/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; @@ -500,7 +615,7 @@ CODE_SIGN_ENTITLEMENTS = Juice/Juice.entitlements; CODE_SIGN_IDENTITY = "Mac Developer"; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 2016.12.18033401; + CURRENT_PROJECT_VERSION = 529; DEVELOPMENT_TEAM = YN24FFRTC8; INFOPLIST_FILE = Juice/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; @@ -510,6 +625,42 @@ }; name = Release; }; + 72DA73641E09FE19003F9262 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = JuiceHelper/JuiceHelper.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 529; + DEVELOPMENT_TEAM = YN24FFRTC8; + INFOPLIST_FILE = JuiceHelper/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.JuiceHelper; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 72DA73651E09FE19003F9262 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_ENTITLEMENTS = JuiceHelper/JuiceHelper.entitlements; + CODE_SIGN_IDENTITY = "Mac Developer"; + COMBINE_HIDPI_IMAGES = YES; + CURRENT_PROJECT_VERSION = 529; + DEVELOPMENT_TEAM = YN24FFRTC8; + INFOPLIST_FILE = JuiceHelper/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.bsm.macos.JuiceHelper; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -531,6 +682,15 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; + 72DA73661E09FE19003F9262 /* Build configuration list for PBXNativeTarget "JuiceHelper" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 72DA73641E09FE19003F9262 /* Debug */, + 72DA73651E09FE19003F9262 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; /* End XCConfigurationList section */ }; rootObject = 725AA5B41E05BF3A006E5DDE /* Project object */; diff --git a/Juice/AppDelegate.swift b/Juice/AppDelegate.swift index 41cc252..458c53a 100644 --- a/Juice/AppDelegate.swift +++ b/Juice/AppDelegate.swift @@ -12,14 +12,5 @@ import Cocoa class AppDelegate: NSObject, NSApplicationDelegate { @IBOutlet weak var window: NSWindow! - - - func applicationDidFinishLaunching(_ aNotification: Notification) { - // Insert code here to initialize your application - } - - func applicationWillTerminate(_ aNotification: Notification) { - // Insert code here to tear down your application - } } diff --git a/Juice/Classes/GeneralPreferencesViewController.swift b/Juice/Classes/GeneralPreferencesViewController.swift index 6a58a5f..5727301 100644 --- a/Juice/Classes/GeneralPreferencesViewController.swift +++ b/Juice/Classes/GeneralPreferencesViewController.swift @@ -9,6 +9,13 @@ import Cocoa import RxSwift +extension StartOnLaunchController { + static func juiceStartOnLaunchController() -> StartOnLaunchController { + return StartOnLaunchController(bundleIdentifier: "com.bsm.macos.JuiceHelper") + } +} + + class GeneralPreferencesViewController: NSViewController { private let preferences = PreferencesStorage.shared @@ -17,11 +24,13 @@ class GeneralPreferencesViewController: NSViewController { }() private let disposableBag = DisposeBag() + private let startOnLaunchController = StartOnLaunchController.juiceStartOnLaunchController() @IBOutlet weak var statusBarStylePopUp: NSPopUpButton! @IBOutlet weak var addNewScaleButton: NSButton! @IBOutlet weak var triggerRescanButton: NSButton! @IBOutlet weak var scalesFoundLabel: NSTextField! + @IBOutlet weak var launchOnLoginButton: NSButton! override var nibName: String? { return "GeneralPreferencesViewController" @@ -32,6 +41,8 @@ class GeneralPreferencesViewController: NSViewController { statusBarStylePopUp.target = self statusBarStylePopUp.action = #selector(statusBarStyleChanged) + launchOnLoginButton.target = self + launchOnLoginButton.action = #selector(toggleStartOnLaunchButton) updatePreferencePopUp(for: preferences.scales.value) @@ -43,6 +54,8 @@ class GeneralPreferencesViewController: NSViewController { return } }.addDisposableTo(disposableBag) + + launchOnLoginButton.state = startOnLaunchController.startsOnLaunch ? NSOnState : NSOffState } @objc private func statusBarStyleChanged() { @@ -74,4 +87,10 @@ class GeneralPreferencesViewController: NSViewController { @IBAction func triggerRescan(_ sender: Any) { preferences.scanApplicationSupportForFiles() } + + @IBAction func toggleStartOnLaunchButton(_ sender: Any) { + let isSet = launchOnLoginButton.state == NSOnState + _ = startOnLaunchController.toggle(startOnLaunch: isSet) + + } } diff --git a/Juice/Classes/GeneralPreferencesViewController.xib b/Juice/Classes/GeneralPreferencesViewController.xib index 5ced70e..5079fc3 100644 --- a/Juice/Classes/GeneralPreferencesViewController.xib +++ b/Juice/Classes/GeneralPreferencesViewController.xib @@ -11,40 +11,69 @@ + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + - + - @@ -90,10 +119,12 @@ + +