From 7daf76cf040d15e435433ff994b8453ec7203013 Mon Sep 17 00:00:00 2001 From: Claire Date: Sat, 24 Sep 2022 20:06:06 -0700 Subject: [PATCH] last commit with storyboard. fixed duplicate window problem, added changelog. --- LunaMac.xcodeproj/project.pbxproj | 14 +++++- .../xcdebugger/Breakpoints_v2.xcbkptlist | 5 +++ LunaMac/AppDelegate.swift | 43 ++++++++++++++++++- LunaMac/Base.lproj/Main.storyboard | 29 ------------- LunaMac/Changelog.xib | 28 ++++++++++++ LunaMac/Info.plist | 12 ++---- LunaMac/InfoBox.xib | 29 +++++++++---- LunaMac/Main.xib | 12 ++++++ LunaMac/ViewController.swift | 34 ++++++++++++--- LunaMac/changelog.txt | 13 ++++++ 10 files changed, 163 insertions(+), 56 deletions(-) create mode 100644 LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist create mode 100644 LunaMac/Changelog.xib create mode 100644 LunaMac/Main.xib create mode 100644 LunaMac/changelog.txt diff --git a/LunaMac.xcodeproj/project.pbxproj b/LunaMac.xcodeproj/project.pbxproj index df27249..8f14717 100644 --- a/LunaMac.xcodeproj/project.pbxproj +++ b/LunaMac.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 7E0CBEA428DEB998009967CD /* Changelog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E0CBEA328DEB998009967CD /* Changelog.xib */; }; + 7E0CBEA628DEBA80009967CD /* changelog.txt in Resources */ = {isa = PBXBuildFile; fileRef = 7E0CBEA528DEBA80009967CD /* changelog.txt */; }; + 7E7D006A28DFFAD800CD5D80 /* Main.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E7D006928DFFAD800CD5D80 /* Main.xib */; }; 7E8188BB28DD423B0080C707 /* InfoBox.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E8188BA28DD423B0080C707 /* InfoBox.xib */; }; 7E96D61628DD75BE00999EAE /* LunaMac.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7E96D61528DD75BE00999EAE /* LunaMac.icns */; }; 7ECD0D7C28DD2A4100B90958 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7ECD0D7B28DD2A4100B90958 /* AppDelegate.swift */; }; @@ -34,6 +37,9 @@ /* End PBXBuildFile section */ /* Begin PBXFileReference section */ + 7E0CBEA328DEB998009967CD /* Changelog.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Changelog.xib; sourceTree = ""; }; + 7E0CBEA528DEBA80009967CD /* changelog.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = changelog.txt; sourceTree = ""; }; + 7E7D006928DFFAD800CD5D80 /* Main.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = Main.xib; sourceTree = ""; }; 7E8188BA28DD423B0080C707 /* InfoBox.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = InfoBox.xib; sourceTree = ""; }; 7E96D61528DD75BE00999EAE /* LunaMac.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = LunaMac.icns; sourceTree = ""; }; 7ECD0D7828DD2A4100B90958 /* LunaMac.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LunaMac.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -98,10 +104,13 @@ 7ECD0D7D28DD2A4100B90958 /* ViewController.swift */, 7EF79B3228DE1E4D00FF1F49 /* Assets.xcassets */, 7E96D61528DD75BE00999EAE /* LunaMac.icns */, - 7ECD0D8128DD2A4200B90958 /* Main.storyboard */, 7ECD0D8428DD2A4200B90958 /* Info.plist */, 7ECD0D8528DD2A4200B90958 /* LunaMac.entitlements */, + 7ECD0D8128DD2A4200B90958 /* Main.storyboard */, + 7E7D006928DFFAD800CD5D80 /* Main.xib */, 7E8188BA28DD423B0080C707 /* InfoBox.xib */, + 7E0CBEA328DEB998009967CD /* Changelog.xib */, + 7E0CBEA528DEBA80009967CD /* changelog.txt */, ); path = LunaMac; sourceTree = ""; @@ -197,6 +206,7 @@ 7E8188BB28DD423B0080C707 /* InfoBox.xib in Resources */, 7EF79BBD28DE395C00FF1F49 /* waxg.png in Resources */, 7EF79BAF28DE395C00FF1F49 /* firstq.png in Resources */, + 7E0CBEA628DEBA80009967CD /* changelog.txt in Resources */, 7EF79BB428DE395C00FF1F49 /* new-dark.png in Resources */, 7EF79BB828DE395C00FF1F49 /* wang-dark.png in Resources */, 7EF79BC028DE4D2400FF1F49 /* default-dark.png in Resources */, @@ -204,9 +214,11 @@ 7EF79BB628DE395C00FF1F49 /* wanc-dark.png in Resources */, 7EF79BBB28DE395C00FF1F49 /* waxc.png in Resources */, 7EF79BB528DE395C00FF1F49 /* new.png in Resources */, + 7E7D006A28DFFAD800CD5D80 /* Main.xib in Resources */, 7EF79BB228DE395C00FF1F49 /* lastq-dark.png in Resources */, 7EF79BB328DE395C00FF1F49 /* lastq.png in Resources */, 7ECD0D8328DD2A4200B90958 /* Main.storyboard in Resources */, + 7E0CBEA428DEB998009967CD /* Changelog.xib in Resources */, 7EF79BB028DE395C00FF1F49 /* full-dark.png in Resources */, 7EF79BB128DE395C00FF1F49 /* full.png in Resources */, 7EF79BC128DE4D2400FF1F49 /* default.png in Resources */, diff --git a/LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist new file mode 100644 index 0000000..fe2b454 --- /dev/null +++ b/LunaMac.xcodeproj/xcuserdata/claire.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -0,0 +1,5 @@ + + + diff --git a/LunaMac/AppDelegate.swift b/LunaMac/AppDelegate.swift index 17e1a7d..107505e 100644 --- a/LunaMac/AppDelegate.swift +++ b/LunaMac/AppDelegate.swift @@ -81,14 +81,38 @@ class AppDelegate: NSObject, NSApplicationDelegate { ] ] + @IBAction func clickClick(_ sender: NSButtonCell) { + // show changelog + showLog() + } + // make sure applet stays in memory var statusBarItem: NSStatusItem? + // create empty timer for event loop + var lunaTimer = Timer() + // is the info box open? + var infoOpen = false + + // is the changelog open? + var logOpen = false func applicationDidFinishLaunching(_ aNotification: Notification) { + // build the icon and menu updateIcon() + + // listen for theme changes (dark and light) themeListener() + + // start the the timer for keeping the icon updated automatically + startTimer() + } + + // start the timer for auto-updating the icon + func startTimer() { + lunaTimer = Timer.scheduledTimer(timeInterval: 10, target: self, selector: #selector(updateIcon), userInfo: nil, repeats: true) + RunLoop.current.add(lunaTimer, forMode: RunLoop.Mode.common) } @objc func buildMenu(key: String = "default") { @@ -158,8 +182,23 @@ class AppDelegate: NSObject, NSApplicationDelegate { } @objc func showAbout() { - let aboutWin = NSWindowController(windowNibName: "InfoBox") - aboutWin.loadWindow() + if (!infoOpen) { + // create infobox window object + let aboutWin = NSWindowController(windowNibName: "InfoBox") + + aboutWin.loadWindow() + } + NSApp.activate(ignoringOtherApps: true) + } + + @objc func showLog() { + if (!logOpen) { + // create changelog window object + // this creates duplicate windows + let logWin = NSWindowController(windowNibName: "Changelog") + + logWin.loadWindow() + } NSApp.activate(ignoringOtherApps: true) } diff --git a/LunaMac/Base.lproj/Main.storyboard b/LunaMac/Base.lproj/Main.storyboard index 8859d09..23633f3 100644 --- a/LunaMac/Base.lproj/Main.storyboard +++ b/LunaMac/Base.lproj/Main.storyboard @@ -729,32 +729,6 @@ - - - - - - - LunaMac calculates the current moon phase when it launches. If you see a 🌙 instead of a moon phase, try again from the status bar icon's menu. - - - - - - - - - - - - - - - - - - - @@ -762,7 +736,4 @@ - - - diff --git a/LunaMac/Changelog.xib b/LunaMac/Changelog.xib new file mode 100644 index 0000000..5c09ddd --- /dev/null +++ b/LunaMac/Changelog.xib @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/LunaMac/Info.plist b/LunaMac/Info.plist index b02443c..d366299 100644 --- a/LunaMac/Info.plist +++ b/LunaMac/Info.plist @@ -2,6 +2,8 @@ + NSMainNibFile + Main CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -17,22 +19,16 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.1 + 1.2 CFBundleVersion - 1.1 + 1.2 LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) LSUIElement NSHumanReadableCopyright Copyright © 2022 A Better Geek. All rights reserved. - NSMainStoryboardFile - Main NSPrincipalClass NSApplication - NSServices - - - diff --git a/LunaMac/InfoBox.xib b/LunaMac/InfoBox.xib index 7593026..c6edb68 100644 --- a/LunaMac/InfoBox.xib +++ b/LunaMac/InfoBox.xib @@ -11,12 +11,23 @@ - + - + + @@ -27,15 +38,10 @@ - - - - - - + @@ -43,8 +49,13 @@ - + + + + + + diff --git a/LunaMac/Main.xib b/LunaMac/Main.xib new file mode 100644 index 0000000..20f1d6f --- /dev/null +++ b/LunaMac/Main.xib @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/LunaMac/ViewController.swift b/LunaMac/ViewController.swift index babfee2..b23825b 100644 --- a/LunaMac/ViewController.swift +++ b/LunaMac/ViewController.swift @@ -8,20 +8,40 @@ import Cocoa -class ViewController: NSViewController { +class ViewController: NSViewController, NSWindowDelegate { + + let appDelegate = NSApplication.shared.delegate as! AppDelegate override func viewDidLoad() { + print("view did load") super.viewDidLoad() - - // Do any additional setup after loading the view. + + toggleWindow(boolShow: true) + } + + override func viewDidAppear() { + self.view.window?.delegate = self + } + + // triggers when window is closed + override func viewWillDisappear() { + print("view will disappear") + + toggleWindow(boolShow: false) } - override var representedObject: Any? { - didSet { - // Update the view, if already loaded. + func toggleWindow(boolShow: Bool = false) { + // get the window title to set the right bool + // window title is in self.view.window.title + let winTitle = self.view.window?.title + + if (winTitle?.contains("About") ?? false) { + appDelegate.infoOpen = boolShow + } + else if (winTitle?.contains("Changelog") ?? false) { + appDelegate.logOpen = boolShow } } - } diff --git a/LunaMac/changelog.txt b/LunaMac/changelog.txt new file mode 100644 index 0000000..5cb8b3d --- /dev/null +++ b/LunaMac/changelog.txt @@ -0,0 +1,13 @@ +====== Changelog ====== + +v1.2 + - Added automatic icon update as phase changes + - Added changelog + - Fixed window duplication problem + +v1.1 + - Updated icons to use images instead of emoji + - Fixed About window to display on top when opened + +v1.0 + - Initial release