Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Menu icon toggle #121

Merged
merged 29 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0361829
add menu bar icon toggle in storyboard
AlexPerathoner Mar 4, 2023
696321a
update window size based on tab view
AlexPerathoner Mar 4, 2023
227112b
swiftlint --fix --format auto run
AlexPerathoner Mar 4, 2023
35b1377
add menu bar icon toggle functions
AlexPerathoner Mar 4, 2023
7447c21
re-adding menu icon
AlexPerathoner Mar 4, 2023
4a9af4c
hiding menu items for tab switch when window hidden
AlexPerathoner Mar 4, 2023
fab6880
swiftlint --fix --format auto run
AlexPerathoner Mar 4, 2023
ca71939
fix selector
AlexPerathoner Mar 4, 2023
242cf1d
hide / show status item
AlexPerathoner Mar 4, 2023
14da5fc
rename file
AlexPerathoner Mar 4, 2023
a373085
show alert
AlexPerathoner Mar 4, 2023
e141eef
reduce activation delay and prevent call loop
AlexPerathoner Mar 4, 2023
157e489
fix show setting
AlexPerathoner Mar 4, 2023
6679e37
fix swift lint
AlexPerathoner Mar 4, 2023
e3a637b
remove showQuitAlert
AlexPerathoner Mar 4, 2023
34c4519
better close window
AlexPerathoner Mar 4, 2023
2703207
add ui tests for edgeselector
AlexPerathoner Mar 4, 2023
d6e7865
swiftlint --fix --format auto run
AlexPerathoner Mar 4, 2023
ed95585
add ui test hide / show menu bar icon
AlexPerathoner Mar 4, 2023
c415af1
swiftlint --fix --format auto run
AlexPerathoner Mar 4, 2023
c40a464
add quit test
AlexPerathoner Mar 4, 2023
b92d827
Merge remote-tracking branch 'origin/feature/menu-icon-toggle' into f…
AlexPerathoner Mar 4, 2023
55916a9
fix calls to firstResponder
AlexPerathoner Mar 4, 2023
7cc2300
add test switch tabs
AlexPerathoner Mar 4, 2023
6f9f9ac
add ui tests for tab switch in settings
AlexPerathoner Mar 4, 2023
9eb2d0d
fix testTriggerVolumeHud
AlexPerathoner Mar 4, 2023
c56e6b6
better ui close tests
AlexPerathoner Mar 4, 2023
f44cff4
swiftlint --fix --format auto run
AlexPerathoner Mar 4, 2023
e25e478
update release notes
AlexPerathoner Mar 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Release_Notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* Icons change depending on value
* Add multiple in-out animation styles
* New look for the settings window
* Add option to hide the menu bar icon

@kaydenanderson

Expand Down
20 changes: 16 additions & 4 deletions SlimHUD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
FA232B4E2981E6A900F96E51 /* AboutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA232B4D2981E6A900F96E51 /* AboutViewController.swift */; };
FA232B502981E6CA00F96E51 /* DesignViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA232B4F2981E6CA00F96E51 /* DesignViewController.swift */; };
FA232B522981E6D800F96E51 /* StyleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA232B512981E6D800F96E51 /* StyleViewController.swift */; };
FA2D3DE22971EC2B00ABADDE /* MainMenuController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA2D3DE12971EC2B00ABADDE /* MainMenuController.swift */; };
FA322FC4297F485700E8F31A /* StandardLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA322FC3297F485700E8F31A /* StandardLabel.swift */; };
FA322FC6297F506200E8F31A /* EdgeSelector.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA322FC5297F506200E8F31A /* EdgeSelector.swift */; };
FA56F6DE29666815008177B1 /* UITestsUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA56F6DD29666815008177B1 /* UITestsUtils.swift */; };
Expand All @@ -32,7 +33,7 @@
FA8B1A4B296E70D80015AAEB /* UpdaterDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8B1A4A296E70D80015AAEB /* UpdaterDelegate.swift */; };
FA95EDF52956FCBF005B39CD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA95EDF42956FCBF005B39CD /* AppDelegate.swift */; };
FA95EDF92956FCC1005B39CD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FA95EDF82956FCC1005B39CD /* Assets.xcassets */; };
FA95EE212956FCF0005B39CD /* HudsControllerInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */; };
FA95EE212956FCF0005B39CD /* HudsControllerInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */; };
FA95EE242956FD3A005B39CD /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = FA95EE232956FD3A005B39CD /* Sparkle */; };
FA95EE282956FD54005B39CD /* SettingsWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA95EE272956FD54005B39CD /* SettingsWindowController.swift */; };
FA95EE362956FDCD005B39CD /* KeyPressObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA95EE352956FDCD005B39CD /* KeyPressObserver.swift */; };
Expand Down Expand Up @@ -75,6 +76,8 @@
FACDE68F297F105600EDF165 /* TabItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FACDE68E297F105600EDF165 /* TabItemView.swift */; };
FACDE693297F1BD300EDF165 /* TabsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FACDE692297F1BD300EDF165 /* TabsView.swift */; };
FAD154E5296F8CFF00AC8BBB /* MediaKeyTap in Frameworks */ = {isa = PBXBuildFile; productRef = FAD154E4296F8CFF00AC8BBB /* MediaKeyTap */; };
FAD49D0E29B38E680034A8D8 /* StatusItemCreator.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAD49D0D29B38E680034A8D8 /* StatusItemCreator.swift */; };
FAD49D1029B398ED0034A8D8 /* ConfigSettingsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAD49D0F29B398ED0034A8D8 /* ConfigSettingsTest.swift */; };
FAF1A5132970F80E00C8D5DB /* IconManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAF1A5122970F80E00C8D5DB /* IconManager.swift */; };
FAFC579E29675F3E00C32A80 /* AppleScriptRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAFC579D29675F3E00C32A80 /* AppleScriptRunner.swift */; };
FAFC57A029675F7700C32A80 /* AppleScriptError.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAFC579F29675F7700C32A80 /* AppleScriptError.swift */; };
Expand Down Expand Up @@ -107,6 +110,7 @@
FA232B4D2981E6A900F96E51 /* AboutViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutViewController.swift; sourceTree = "<group>"; };
FA232B4F2981E6CA00F96E51 /* DesignViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DesignViewController.swift; sourceTree = "<group>"; };
FA232B512981E6D800F96E51 /* StyleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleViewController.swift; sourceTree = "<group>"; };
FA2D3DE12971EC2B00ABADDE /* MainMenuController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuController.swift; sourceTree = "<group>"; };
FA322FC3297F485700E8F31A /* StandardLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StandardLabel.swift; sourceTree = "<group>"; };
FA322FC5297F506200E8F31A /* EdgeSelector.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EdgeSelector.swift; sourceTree = "<group>"; };
FA56F6DD29666815008177B1 /* UITestsUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UITestsUtils.swift; sourceTree = "<group>"; };
Expand All @@ -127,7 +131,7 @@
FA95EDF82956FCC1005B39CD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
FA95EE022956FCC1005B39CD /* SlimHUDTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlimHUDTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
FA95EE0C2956FCC1005B39CD /* SlimHUDUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SlimHUDUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = " HudsControllerInterface.swift"; sourceTree = "<group>"; };
FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HudsControllerInterface.swift; sourceTree = "<group>"; };
FA95EE272956FD54005B39CD /* SettingsWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsWindowController.swift; sourceTree = "<group>"; };
FA95EE352956FDCD005B39CD /* KeyPressObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyPressObserver.swift; sourceTree = "<group>"; };
FA95EE372956FDD8005B39CD /* DisplayManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -170,6 +174,8 @@
FACDE683297EEC5200EDF165 /* CustomView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomView.swift; sourceTree = "<group>"; };
FACDE68E297F105600EDF165 /* TabItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabItemView.swift; sourceTree = "<group>"; };
FACDE692297F1BD300EDF165 /* TabsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsView.swift; sourceTree = "<group>"; };
FAD49D0D29B38E680034A8D8 /* StatusItemCreator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusItemCreator.swift; sourceTree = "<group>"; };
FAD49D0F29B398ED0034A8D8 /* ConfigSettingsTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigSettingsTest.swift; sourceTree = "<group>"; };
FAF1A5122970F80E00C8D5DB /* IconManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconManager.swift; sourceTree = "<group>"; };
FAFC579D29675F3E00C32A80 /* AppleScriptRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleScriptRunner.swift; sourceTree = "<group>"; };
FAFC579F29675F7700C32A80 /* AppleScriptError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppleScriptError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -276,6 +282,7 @@
children = (
FA95EE832957448E005B39CD /* Utils */,
FA95EE8129574471005B39CD /* SettingsUITest.swift */,
FAD49D0F29B398ED0034A8D8 /* ConfigSettingsTest.swift */,
FA56F6DF29666AB1008177B1 /* HudsUITests.swift */,
);
path = SlimHUDUITests;
Expand All @@ -285,7 +292,8 @@
isa = PBXGroup;
children = (
FA95EE292956FD68005B39CD /* SettingsViewController */,
FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */,
FA95EE202956FCF0005B39CD /* HudsControllerInterface.swift */,
FA2D3DE12971EC2B00ABADDE /* MainMenuController.swift */,
FA95EE272956FD54005B39CD /* SettingsWindowController.swift */,
);
path = Controllers;
Expand Down Expand Up @@ -349,6 +357,7 @@
FAB5AA36295AF0FF00060CB6 /* SensorMethod.swift */,
FA64B59E296638DA00600F85 /* Alert.swift */,
FA7811E22975EFE500FEE1AA /* AnimationStyle.swift */,
FAD49D0D29B38E680034A8D8 /* StatusItemCreator.swift */,
);
path = Support;
sourceTree = "<group>";
Expand Down Expand Up @@ -588,7 +597,7 @@
FA95EE532956FE7C005B39CD /* NSControlExtension.swift in Sources */,
FA95EE7229573F63005B39CD /* DeterminateAnimation.swift in Sources */,
FA95EE3E2956FDFB005B39CD /* ChangesObserver.swift in Sources */,
FA95EE212956FCF0005B39CD /* HudsControllerInterface.swift in Sources */,
FA95EE212956FCF0005B39CD /* HudsControllerInterface.swift in Sources */,
FA95EE6D29573F36005B39CD /* Hud.swift in Sources */,
FA95EE5E2956FEC3005B39CD /* Constants.swift in Sources */,
FA95EE572956FE91005B39CD /* BoolExtension.swift in Sources */,
Expand All @@ -609,6 +618,7 @@
FA95EE482956FE37005B39CD /* Displayer.swift in Sources */,
FA95EE3C2956FDF1005B39CD /* KeyboardManager.swift in Sources */,
FA232B502981E6CA00F96E51 /* DesignViewController.swift in Sources */,
FAD49D0E29B38E680034A8D8 /* StatusItemCreator.swift in Sources */,
FAB5AA39295B031900060CB6 /* UserDefaultsExtension.swift in Sources */,
FA95EE462956FE2A005B39CD /* PositionManager.swift in Sources */,
FA232B522981E6D800F96E51 /* StyleViewController.swift in Sources */,
Expand All @@ -631,6 +641,7 @@
FACDE68F297F105600EDF165 /* TabItemView.swift in Sources */,
FA95EDF52956FCBF005B39CD /* AppDelegate.swift in Sources */,
FA95EE512956FE73005B39CD /* NSButtonExtension.swift in Sources */,
FA2D3DE22971EC2B00ABADDE /* MainMenuController.swift in Sources */,
FACDE693297F1BD300EDF165 /* TabsView.swift in Sources */,
FA232B4E2981E6A900F96E51 /* AboutViewController.swift in Sources */,
FAB5AA37295AF0FF00060CB6 /* SensorMethod.swift in Sources */,
Expand All @@ -655,6 +666,7 @@
FA56F6E029666AB1008177B1 /* HudsUITests.swift in Sources */,
FA56F6ED2966773F008177B1 /* AAAUITestSetup.swift in Sources */,
FAFC57A22967668500C32A80 /* XCUIApplicationExtension.swift in Sources */,
FAD49D1029B398ED0034A8D8 /* ConfigSettingsTest.swift in Sources */,
FA95EE8229574471005B39CD /* SettingsUITest.swift in Sources */,
FA95EE8529574495005B39CD /* SparkleUITests.swift in Sources */,
);
Expand Down
4 changes: 0 additions & 4 deletions SlimHUD.xcodeproj/xcshareddata/xcschemes/SlimHUD.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "showQuitAlert true"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "showSettingsAtLaunch"
isEnabled = "YES">
Expand Down
62 changes: 14 additions & 48 deletions SlimHUD/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import Sparkle

@NSApplicationMain
class AppDelegate: NSWindowController, NSApplicationDelegate {
var statusItem: NSStatusItem?

var settingsManager: SettingsManager = SettingsManager.getInstance()
var settingsWindowController: SettingsWindowController?

var volumeHud = Hud()
var brightnessHud = Hud()
Expand All @@ -28,6 +29,15 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {

override func awakeFromNib() {
super.awakeFromNib()

if !settingsManager.shouldHideMenuBarIcon {
addStatusItem()
}

volumeHud.identifier = NSUserInterfaceItemIdentifier("volumeHud")
brightnessHud.identifier = NSUserInterfaceItemIdentifier("brightnessHud")
volumeHud.window?.title = "volumeTitle"
brightnessHud.window?.title = "brightnesTitle"
displayer.updateAllAttributes()
}

Expand All @@ -46,42 +56,10 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
}

OSDUIManager.stop()

if CommandLine.arguments.contains("showSettingsAtLaunch") {
showSettingsWindow()
}
}

func applicationDidBecomeActive(_ notification: Notification) {
showSettingsWindow()
}

func showSettingsWindow() {
if let settingsWindowController = settingsWindowController {
settingsWindowController.showWindow(self)
} else {
if let windowController = NSStoryboard(name: "Settings", bundle: nil).instantiateInitialController() as? SettingsWindowController {
settingsWindowController = windowController
windowController.showWindow(self)
}
}
NSApplication.shared.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
}

@IBAction func quitCliked(_ sender: Any) {
if isSomeWindowVisible() {
let alertResponse = showAlert(question: "SlimHUD will continue to show HUDs in the background",
text: "If you want to quit, click \"Quit now\"",
buttonsTitle: ["OK", "Quit now"])
if alertResponse == NSApplication.ModalResponse.alertSecondButtonReturn {
quit()
}
closeAllWindows()
NSApplication.shared.setActivationPolicy(.accessory)
} else {
quit()
}
mainMenuController.showSettingsWindow()
}

@IBAction func openGeneralTab(_ sender: Any) {
Expand All @@ -100,18 +78,6 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
settingsViewTabsManager?.selectItem(index: 3)
}

private func closeAllWindows() {
settingsWindowController?.close()
}

private func quit() {
settingsManager.saveAllItems()
OSDUIManager.start()
exit(0)
}

private func isSomeWindowVisible() -> Bool {
return (settingsWindowController?.window?.isVisible ?? false) &&
NSApplication.shared.activationPolicy() != .accessory
}
@IBOutlet weak var statusMenu: NSMenu!
@IBOutlet weak var mainMenuController: MainMenuController!
}
22 changes: 22 additions & 0 deletions SlimHUD/Assets.xcassets/statusIcon.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "Icon16.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "Icon32.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// HudsControllerInterface.swift
// HudsControllerInterface.swift
// SlimHUD
//
// Created by Alex Perathoner on 24/12/22.
Expand Down
89 changes: 89 additions & 0 deletions SlimHUD/Controllers/MainMenuController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
//
// MainMenuController.swift
// SlimHUD
//
// Created by Alex Perathoner on 13/01/23.
//

import Cocoa

class MainMenuController: NSWindowController {
@IBOutlet weak var generalMenuItemOutlet: NSMenuItem!
@IBOutlet weak var designMenuItemOutlet: NSMenuItem!
@IBOutlet weak var styleMenuItemOutlet: NSMenuItem!
@IBOutlet weak var aboutMenuItemOutlet: NSMenuItem!

var settingsWindowController: SettingsWindowController?

var settingsManager: SettingsManager = SettingsManager.getInstance()

@IBAction func quitCliked(_ sender: Any) {
if isSomeWindowVisible() {
let alertResponse = showAlert(question: "SlimHUD will continue to show HUDs",
text: "If you want to quit, click quit again",
buttonsTitle: ["OK", "Quit now"])
if alertResponse == NSApplication.ModalResponse.alertFirstButtonReturn {
closeAllWindows()
NSApplication.shared.setActivationPolicy(.accessory)
}
if alertResponse == NSApplication.ModalResponse.alertSecondButtonReturn {
quit()
}
} else {
quit()
}
}

override func awakeFromNib() {
if CommandLine.arguments.contains("showSettingsAtLaunch") {
showSettingsWindow()
}
}

func showSettingsWindow() {
if isSomeWindowVisible() {
NSApp.activate(ignoringOtherApps: true)
return
}
if settingsWindowController != nil {
settingsWindowController?.showWindow(self)
} else {
if let windowController = NSStoryboard(name: "Settings", bundle: nil).instantiateInitialController() as? SettingsWindowController {
settingsWindowController = windowController
settingsWindowController?.delegate = self
windowController.showWindow(self)
}
}
// Settings window has now been opened, but isn't frontmost
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: false, block: {_ in
NSApplication.shared.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
})
}

@IBAction func settingsClicked(_ sender: Any) {
showSettingsWindow()
}

func closeAllWindows() {
settingsWindowController?.close()
}

private func quit() {
settingsManager.saveAllItems()
OSDUIManager.start()
exit(0)
}

private func isSomeWindowVisible() -> Bool {
return (settingsWindowController?.window?.isVisible ?? false) &&
NSApplication.shared.activationPolicy() != .accessory
}

func toggleTabSwitcherMenuItems(isHidden: Bool) {
generalMenuItemOutlet.isHidden = isHidden
designMenuItemOutlet.isHidden = isHidden
styleMenuItemOutlet.isHidden = isHidden
aboutMenuItemOutlet.isHidden = isHidden
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ConfigViewController: NSViewController {
@IBOutlet weak var launchAtLoginOutlet: NSButton!
@IBOutlet weak var enabledBarsOutlet: NSSegmentedControl!
@IBOutlet weak var marginStepperOutlet: NSStepper!
@IBOutlet weak var hideMenuBarIconOutlet: NSButton!

override func viewDidLoad() {
// swiftlint:disable:next force_cast
Expand All @@ -34,6 +35,7 @@ class ConfigViewController: NSViewController {
marginStepperOutlet.integerValue = settingsManager.marginValue
continuousCheckOutlet.state = settingsManager.shouldContinuouslyCheck.toStateValue()
launchAtLoginOutlet.state = loginItemsList.isLoginItemInList().toStateValue()
hideMenuBarIconOutlet.state = settingsManager.shouldHideMenuBarIcon.toStateValue()
}

func setPosition(edge: Position) {
Expand Down Expand Up @@ -67,4 +69,23 @@ class ConfigViewController: NSViewController {
settingsManager.marginValue = marginValue
marginOutlet.stringValue = String(marginValue) + "%"
}

@IBAction func hideMenuBarIconClicked(_ sender: NSButton) {
let shouldHideMenuBarIcon = sender.boolValue()
settingsManager.shouldHideMenuBarIcon = shouldHideMenuBarIcon
// swiftlint:disable:next force_cast
let appDelegate = (NSApplication.shared.delegate as! AppDelegate)
if shouldHideMenuBarIcon {
appDelegate.removeStatusItem()
displayInfoDialog()
} else {
appDelegate.addStatusItem()
}
}

private func displayInfoDialog() {
_ = showAlert(question: "Menu Bar Icon now hidden",
text: "To access the settings window, launch SlimHUD again",
buttonsTitle: ["OK"])
}
}
Loading