-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from AlexPerathoner/feature/menu-icon-toggle
Menu icon toggle
- Loading branch information
Showing
22 changed files
with
511 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
2 changes: 1 addition & 1 deletion
2
...ontrollers/ HudsControllerInterface.swift → ...Controllers/HudsControllerInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.