diff --git a/HiddenBar.xcodeproj/project.pbxproj b/Hidden Bar.xcodeproj/project.pbxproj similarity index 92% rename from HiddenBar.xcodeproj/project.pbxproj rename to Hidden Bar.xcodeproj/project.pbxproj index eabaf26..721d285 100644 --- a/HiddenBar.xcodeproj/project.pbxproj +++ b/Hidden Bar.xcodeproj/project.pbxproj @@ -7,6 +7,10 @@ objects = { /* Begin PBXBuildFile section */ + 3CD1E39A221E8F2100294DA5 /* Constant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92C97B8E220147FE0007559C /* Constant.swift */; }; + 3CD1E39C221E915D00294DA5 /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 92C97B87220032ED0007559C /* Util.swift */; }; + 3CF14C82221FA49D0083D42B /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF14C81221FA49D0083D42B /* PreferencesWindowController.swift */; }; + 3CF14C83221FA7860083D42B /* PreferencesWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF14C81221FA49D0083D42B /* PreferencesWindowController.swift */; }; 9220587E2212A7C0008A8B03 /* LauncherApplication.app in Copy Files */ = {isa = PBXBuildFile; fileRef = 92C5054E21FEC03B0084719A /* LauncherApplication.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; }; 929113F521F9D04100173149 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929113F421F9D04100173149 /* AppDelegate.swift */; }; 929113F721F9D04100173149 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 929113F621F9D04100173149 /* ViewController.swift */; }; @@ -41,8 +45,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 3CF14C81221FA49D0083D42B /* PreferencesWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferencesWindowController.swift; sourceTree = ""; }; 9220587D22127050008A8B03 /* Hidden.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Hidden.entitlements; path = Hidden/Hidden.entitlements; sourceTree = ""; }; - 929113F121F9D04100173149 /* HiddenBar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HiddenBar.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 929113F121F9D04100173149 /* Hidden Bar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Hidden Bar.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 929113F421F9D04100173149 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 929113F621F9D04100173149 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 929113F821F9D04200173149 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -89,6 +94,7 @@ children = ( 92C97B9022018C1F0007559C /* StatusBarController.swift */, 929113F621F9D04100173149 /* ViewController.swift */, + 3CF14C81221FA49D0083D42B /* PreferencesWindowController.swift */, ); path = ViewControlllers; sourceTree = ""; @@ -116,7 +122,7 @@ 929113F221F9D04100173149 /* Products */ = { isa = PBXGroup; children = ( - 929113F121F9D04100173149 /* HiddenBar.app */, + 929113F121F9D04100173149 /* Hidden Bar.app */, 92C5054E21FEC03B0084719A /* LauncherApplication.app */, ); name = Products; @@ -170,9 +176,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 929113F021F9D04100173149 /* HiddenBar */ = { + 929113F021F9D04100173149 /* Hidden Bar */ = { isa = PBXNativeTarget; - buildConfigurationList = 9291141721F9D04200173149 /* Build configuration list for PBXNativeTarget "HiddenBar" */; + buildConfigurationList = 9291141721F9D04200173149 /* Build configuration list for PBXNativeTarget "Hidden Bar" */; buildPhases = ( 929113ED21F9D04100173149 /* Sources */, 929113EE21F9D04100173149 /* Frameworks */, @@ -183,9 +189,9 @@ ); dependencies = ( ); - name = HiddenBar; + name = "Hidden Bar"; productName = vanillaClone; - productReference = 929113F121F9D04100173149 /* HiddenBar.app */; + productReference = 929113F121F9D04100173149 /* Hidden Bar.app */; productType = "com.apple.product-type.application"; }; 92C5054D21FEC03B0084719A /* LauncherApplication */ = { @@ -228,7 +234,7 @@ }; }; }; - buildConfigurationList = 929113EC21F9D04100173149 /* Build configuration list for PBXProject "HiddenBar" */; + buildConfigurationList = 929113EC21F9D04100173149 /* Build configuration list for PBXProject "Hidden Bar" */; compatibilityVersion = "Xcode 9.3"; developmentRegion = en; hasScannedForEncodings = 0; @@ -241,7 +247,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 929113F021F9D04100173149 /* HiddenBar */, + 929113F021F9D04100173149 /* Hidden Bar */, 92C5054D21FEC03B0084719A /* LauncherApplication */, ); }; @@ -279,6 +285,7 @@ 929113F721F9D04100173149 /* ViewController.swift in Sources */, 929113F521F9D04100173149 /* AppDelegate.swift in Sources */, 92C97B88220032ED0007559C /* Util.swift in Sources */, + 3CF14C82221FA49D0083D42B /* PreferencesWindowController.swift in Sources */, 92C97B8B220049D20007559C /* NSBarButtonItem+Extension.swift in Sources */, 92C97B8D220058740007559C /* NSView+Extension.swift in Sources */, ); @@ -290,6 +297,9 @@ files = ( 92C5055321FEC03C0084719A /* ViewController.swift in Sources */, 92C5055121FEC03C0084719A /* AppDelegate.swift in Sources */, + 3CF14C83221FA7860083D42B /* PreferencesWindowController.swift in Sources */, + 3CD1E39A221E8F2100294DA5 /* Constant.swift in Sources */, + 3CD1E39C221E915D00294DA5 /* Util.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -444,6 +454,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.minimalbar; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -465,6 +476,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.minimalbar; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -486,6 +498,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.LauncherApplication; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -508,6 +521,7 @@ "$(inherited)", "@executable_path/../Frameworks", ); + MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_BUNDLE_IDENTIFIER = com.dwarvesv.LauncherApplication; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -519,7 +533,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 929113EC21F9D04100173149 /* Build configuration list for PBXProject "HiddenBar" */ = { + 929113EC21F9D04100173149 /* Build configuration list for PBXProject "Hidden Bar" */ = { isa = XCConfigurationList; buildConfigurations = ( 9291141521F9D04200173149 /* Debug */, @@ -528,7 +542,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 9291141721F9D04200173149 /* Build configuration list for PBXNativeTarget "HiddenBar" */ = { + 9291141721F9D04200173149 /* Build configuration list for PBXNativeTarget "Hidden Bar" */ = { isa = XCConfigurationList; buildConfigurations = ( 9291141821F9D04200173149 /* Debug */, diff --git a/HiddenBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Hidden Bar.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 55% rename from HiddenBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Hidden Bar.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1da572e..04cd4fb 100644 --- a/HiddenBar.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/Hidden Bar.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:/Users/dasuperman/Developer/mac-app/hidden/Hidden Bar.xcodeproj"> diff --git a/HiddenBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Hidden Bar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist similarity index 100% rename from HiddenBar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist rename to Hidden Bar.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Hidden Bar.xcodeproj/xcshareddata/xcschemes/Hidden Bar.xcscheme b/Hidden Bar.xcodeproj/xcshareddata/xcschemes/Hidden Bar.xcscheme new file mode 100644 index 0000000..cda7116 --- /dev/null +++ b/Hidden Bar.xcodeproj/xcshareddata/xcschemes/Hidden Bar.xcscheme @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HiddenBar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme b/Hidden Bar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme similarity index 90% rename from HiddenBar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme rename to Hidden Bar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme index 3f4fc9b..0dc6d1d 100644 --- a/HiddenBar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme +++ b/Hidden Bar.xcodeproj/xcshareddata/xcschemes/LauncherApplication.xcscheme @@ -17,7 +17,7 @@ BlueprintIdentifier = "92C5054D21FEC03B0084719A" BuildableName = "LauncherApplication.app" BlueprintName = "LauncherApplication" - ReferencedContainer = "container:HiddenBar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> @@ -35,7 +35,7 @@ BlueprintIdentifier = "92C5055E21FEC03C0084719A" BuildableName = "LauncherApplicationTests.xctest" BlueprintName = "LauncherApplicationTests" - ReferencedContainer = "container:HiddenBar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> @@ -55,7 +55,7 @@ BlueprintIdentifier = "92C5054D21FEC03B0084719A" BuildableName = "LauncherApplication.app" BlueprintName = "LauncherApplication" - ReferencedContainer = "container:HiddenBar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> @@ -78,7 +78,7 @@ BlueprintIdentifier = "92C5054D21FEC03B0084719A" BuildableName = "LauncherApplication.app" BlueprintName = "LauncherApplication" - ReferencedContainer = "container:HiddenBar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> @@ -97,7 +97,7 @@ BlueprintIdentifier = "92C5054D21FEC03B0084719A" BuildableName = "LauncherApplication.app" BlueprintName = "LauncherApplication" - ReferencedContainer = "container:HiddenBar.xcodeproj"> + ReferencedContainer = "container:Hidden Bar.xcodeproj"> diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..15a40c3 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Dwarves Foundation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/LauncherApplication/AppDelegate.swift b/LauncherApplication/AppDelegate.swift index dd20e44..a3eb442 100644 --- a/LauncherApplication/AppDelegate.swift +++ b/LauncherApplication/AppDelegate.swift @@ -9,10 +9,6 @@ import Cocoa -extension Notification.Name { - static let killLauncher = Notification.Name("killLauncher") -} - @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { @@ -35,10 +31,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { var components = path.pathComponents components.removeLast(3) components.append("MacOS") - components.append("Hidden Bar") //main app name - let _ = NSString.path(withComponents: components) - - NSWorkspace.shared.launchApplication("Hidden Bar") + components.append(App_Name) //main app name + let newPath = NSString.path(withComponents: components) + NSWorkspace.shared.launchApplication(newPath) } else { self.terminate() diff --git a/README.md b/README.md index 5a839bd..19aaef7 100644 --- a/README.md +++ b/README.md @@ -12,19 +12,31 @@

-## 🚀 Hidden -Hidden lets you hide menu bar items to give your Mac a cleaner look. +## Hidden Bar +Hidden Bar lets you hide menu bar items to give your Mac a cleaner look. -## ⚙️ Install +## Install -Manual: +[![AppStore](/img/appstore.png)](https://itunes.apple.com/app/hidden-bar/id1452453066) -1. [Download](https://github.com/dwarvesf/hidden/releases/latest), open, and drag the app to the Applications folder. -2. Open Hidden and drag the icon in your menu bar (hold CMD) to the right so it is between some other icons. +#### Manual download + +- [Download latest version](https://github.com/dwarvesf/hidden/releases/latest) +- Open and drag the app to the Applications folder. +- Launch Hidden and drag the icon in your menu bar (hold CMD) to the right so it is between some other icons. ## Usage + * `⌘` + drag to move the Hidden icons around in the menu bar. * Click the Arrow icon to hide menu bar items. +

+ +

+ ## Requirements macOS version >= 10.13 + +## Contribution + +If you \ No newline at end of file diff --git a/hidden/AppDelegate.swift b/hidden/AppDelegate.swift index 1d02385..f2b58ad 100644 --- a/hidden/AppDelegate.swift +++ b/hidden/AppDelegate.swift @@ -26,5 +26,12 @@ class AppDelegate: NSObject, NSApplicationDelegate{ let _ = Util.toggleDockIcon(Util.getIsKeepInDock()) } + func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool { + // Handle open preferences window + Util.showPrefWindow() + + return true + } + } diff --git a/hidden/Assets.xcassets/banner.imageset/Contents.json b/hidden/Assets.xcassets/banner.imageset/Contents.json index 14b10db..5d1655b 100644 --- a/hidden/Assets.xcassets/banner.imageset/Contents.json +++ b/hidden/Assets.xcassets/banner.imageset/Contents.json @@ -6,7 +6,7 @@ }, { "idiom" : "universal", - "filename" : "Hidden-darkmode.png", + "filename" : "Hidden.png", "scale" : "2x" }, { diff --git a/hidden/Assets.xcassets/banner.imageset/Hidden-darkmode.png b/hidden/Assets.xcassets/banner.imageset/Hidden-darkmode.png deleted file mode 100644 index dfbc696..0000000 Binary files a/hidden/Assets.xcassets/banner.imageset/Hidden-darkmode.png and /dev/null differ diff --git a/hidden/Assets.xcassets/banner.imageset/Hidden.png b/hidden/Assets.xcassets/banner.imageset/Hidden.png new file mode 100644 index 0000000..e4385b4 Binary files /dev/null and b/hidden/Assets.xcassets/banner.imageset/Hidden.png differ diff --git a/hidden/Base.lproj/Main.storyboard b/hidden/Base.lproj/Main.storyboard index e5a7f1c..65376bd 100644 --- a/hidden/Base.lproj/Main.storyboard +++ b/hidden/Base.lproj/Main.storyboard @@ -1,6 +1,7 @@ - + + @@ -674,7 +675,7 @@ - + @@ -683,7 +684,7 @@ - + @@ -703,13 +704,13 @@ - + - + - + @@ -723,7 +724,7 @@ - + @@ -734,7 +735,7 @@ + + - + diff --git a/hidden/Common/Constant.swift b/hidden/Common/Constant.swift index b2fad82..a7854bb 100644 --- a/hidden/Common/Constant.swift +++ b/hidden/Common/Constant.swift @@ -8,7 +8,13 @@ import Foundation - let IS_AUTO_START = "isAutoStart" let IS_AUTO_HIDE = "isAutoHide" let IS_KEEP_IN_DOCK = "isKeepInDock" +let IS_SHOW_PREFERENCES = "isShowPreferences" +let App_Name = "Hidden Bar" +let IS_COLLAPSE = "isCollapse" + +extension Notification.Name { + static let killLauncher = Notification.Name("killLauncher") +} diff --git a/hidden/Common/Util.swift b/hidden/Common/Util.swift index a0cda75..428f471 100644 --- a/hidden/Common/Util.swift +++ b/hidden/Common/Util.swift @@ -10,13 +10,8 @@ import AppKit import Foundation import ServiceManagement -extension Notification.Name { - static let killLauncher = Notification.Name("killLauncher") -} - class Util { - static func setUpAutoStart(isAutoStart:Bool) { @@ -37,11 +32,23 @@ class Util { } + static func getIsCollapse()->Bool{ + let savedValue = UserDefaults.standard.bool(forKey: IS_COLLAPSE) + return savedValue + } + + static func setIsCollapse(_ isCollapse:Bool){ + UserDefaults.standard.set(isCollapse, forKey: IS_COLLAPSE) + + } + static func getIsAutoStart()->Bool{ let savedValue = UserDefaults.standard.bool(forKey: IS_AUTO_START) return savedValue } + + static func getStateAutoStart() -> NSControl.StateValue{ if(getIsAutoStart()) { @@ -79,7 +86,7 @@ class Util { return savedValue } - static func getStateKeepInDock() -> NSControl.StateValue{ + static func getStateKeepInDock() -> NSControl.StateValue { if(getIsKeepInDock()) { return .on @@ -87,6 +94,36 @@ class Util { return .off } + static func getShowPreferences() -> Bool { + UserDefaults.standard.register(defaults: [IS_SHOW_PREFERENCES : true]) + return UserDefaults.standard.bool(forKey: IS_SHOW_PREFERENCES) + } + + static func setShowPreferences(_ isShowPreferences: Bool) { + UserDefaults.standard.set(isShowPreferences, forKey: IS_SHOW_PREFERENCES) + } + + static func getStateShowPreferences() -> NSControl.StateValue { + return getShowPreferences() ? .on : .off + } + + static func isMenuOpened() -> Bool { + let options = CGWindowListOption(arrayLiteral: .excludeDesktopElements, .optionOnScreenOnly) + let windowsListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0)) + let infoList = windowsListInfo as! [[String:Any]] + let names = infoList.map { dict in + return dict["kCGWindowOwnerName"] as? String + }.filter({ (name) -> Bool in + name == App_Name + }) + return names.count >= 2 + } + + static func showPrefWindow() { + let prefWindow = PreferencesWindowController.shared.window! + Util.bringToFront(window: prefWindow) + } + static func toggleDockIcon(_ state: Bool) -> Bool { var result: Bool if state { diff --git a/hidden/Info.plist b/hidden/Info.plist index 78f8bf7..6d84eb5 100644 --- a/hidden/Info.plist +++ b/hidden/Info.plist @@ -17,15 +17,15 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleVersion - 2 + 1 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement - + NSHumanReadableCopyright Copyright © 2019 Thanh Nguyen. All rights reserved. NSMainStoryboardFile diff --git a/hidden/ViewControlllers/PreferencesWindowController.swift b/hidden/ViewControlllers/PreferencesWindowController.swift new file mode 100644 index 0000000..4422ccd --- /dev/null +++ b/hidden/ViewControlllers/PreferencesWindowController.swift @@ -0,0 +1,25 @@ +// +// PreferencesWindowController.swift +// Hidden Bar +// +// Created by Phuc Le Dien on 2/22/19. +// Copyright © 2019 Thanh Nguyen. All rights reserved. +// + +import Cocoa + +class PreferencesWindowController: NSWindowController { + + override func windowDidLoad() { + super.windowDidLoad() + + // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. + } + + static let shared: PreferencesWindowController = { + let storyboard = NSStoryboard(name:"Main", bundle: nil) + let controller = storyboard.instantiateController(withIdentifier: "MainWindow") + return controller as! PreferencesWindowController + }() + +} diff --git a/hidden/ViewControlllers/StatusBarController.swift b/hidden/ViewControlllers/StatusBarController.swift index d7aef09..88a3d8f 100644 --- a/hidden/ViewControlllers/StatusBarController.swift +++ b/hidden/ViewControlllers/StatusBarController.swift @@ -13,7 +13,6 @@ import ServiceManagement class StatusBarController{ var isToggle = true - var main: NSWindowController! let expandCollapseStatusBar = NSStatusBar.system.statusItem(withLength:NSStatusItem.squareLength) let seprateStatusBar = NSStatusBar.system.statusItem(withLength:10) @@ -36,18 +35,23 @@ class StatusBarController{ btnDot?.action = #selector(statusBarButtonClicked(_:)) button.addSubview(btnDot!) } + + + if Util.getShowPreferences() { + openPreferenceViewControllerIfNeeded(nil) + } + + checkCollapseWhenOpen() } - func isMenuOpened() -> Bool { - let options = CGWindowListOption(arrayLiteral: .excludeDesktopElements, .optionOnScreenOnly) - let windowsListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0)) - let infoList = windowsListInfo as! [[String:Any]] - let names = infoList.map { dict in - return dict["kCGWindowOwnerName"] as? String - }.filter({ (name) -> Bool in - name == "vanillaClone" - }) - return names.count == 3 + private func checkCollapseWhenOpen(){ + if(Util.getIsCollapse()) + { + if(isToggle && isValidPosition()) + { + setupCollapseMenuBar() + } + } } func isValidPosition() -> Bool { @@ -90,6 +94,7 @@ class StatusBarController{ private func expandMenubar() { + Util.setIsCollapse(false) seprateStatusBar.length = 10 isToggle = !isToggle if let button = expandCollapseStatusBar.button { @@ -116,6 +121,7 @@ class StatusBarController{ } private func setupCollapseMenuBar(){ + Util.setIsCollapse(true) seprateStatusBar.length = 10000 isToggle = !isToggle if let button = expandCollapseStatusBar.button { @@ -137,16 +143,6 @@ class StatusBarController{ } @objc func openPreferenceViewControllerIfNeeded(_ sender: Any?) { - - if(!isMenuOpened()) - { - main = NSStoryboard(name : "Main", bundle: nil).instantiateController(withIdentifier: "MainWindow") as? NSWindowController - - let mainVc = NSStoryboard(name:"Main", bundle: nil).instantiateController(withIdentifier: "prefVC") as! ViewController - main.window?.contentViewController = mainVc - main.window?.makeKeyAndOrderFront(nil) - } - - Util.bringToFront(window: NSApp.mainWindow) + Util.showPrefWindow() } } diff --git a/hidden/ViewControlllers/ViewController.swift b/hidden/ViewControlllers/ViewController.swift index 66fb771..f8982c7 100644 --- a/hidden/ViewControlllers/ViewController.swift +++ b/hidden/ViewControlllers/ViewController.swift @@ -14,9 +14,10 @@ class ViewController: NSViewController { @IBOutlet weak var imageViewTop: NSImageView! @IBOutlet weak var checkBoxAutoHide: NSButton! - @IBOutlet weak var checkBoxKeepInDock: NSButton! @IBOutlet weak var checkBoxLogin: NSButton! + @IBOutlet weak var checkBoxShowPreferences: NSButton! + override func viewDidLoad() { super.viewDidLoad() setUpView() @@ -27,6 +28,7 @@ class ViewController: NSViewController { checkBoxLogin.state = Util.getStateAutoStart() checkBoxAutoHide.state = Util.getStateAutoHide() checkBoxKeepInDock.state = Util.getStateKeepInDock() + checkBoxShowPreferences.state = Util.getStateShowPreferences() } override var representedObject: Any? { @@ -77,5 +79,15 @@ class ViewController: NSViewController { } } + @IBAction func showPreferencesChanged(_ sender: NSButton) { + switch sender.state { + case .on: + Util.setShowPreferences(true) + case .off: + Util.setShowPreferences(false) + default: + break + } + } } diff --git a/img/appstore.png b/img/appstore.png new file mode 100644 index 0000000..97d5a33 Binary files /dev/null and b/img/appstore.png differ diff --git a/img/tutorial.gif b/img/tutorial.gif new file mode 100644 index 0000000..ecfcd83 Binary files /dev/null and b/img/tutorial.gif differ