From af9391a4371be6c500800f3d1118bcdc49a9fc95 Mon Sep 17 00:00:00 2001 From: foamzou Date: Sat, 3 Jun 2023 14:38:14 +0800 Subject: [PATCH] fix: window hide the menu bar --- ITrafficMonitorForMac.xcodeproj/project.pbxproj | 12 +++++++----- ITrafficMonitorForMac/AppDelegate.swift | 12 ++++++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ITrafficMonitorForMac.xcodeproj/project.pbxproj b/ITrafficMonitorForMac.xcodeproj/project.pbxproj index e12f4c4..14f12df 100644 --- a/ITrafficMonitorForMac.xcodeproj/project.pbxproj +++ b/ITrafficMonitorForMac.xcodeproj/project.pbxproj @@ -158,7 +158,7 @@ New, ); LastSwiftUpdateCheck = 1210; - LastUpgradeCheck = 1210; + LastUpgradeCheck = 1340; TargetAttributes = { C4C9974926555B3A003ADDC2 = { CreatedOnToolsVersion = 12.1.1; @@ -353,9 +353,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = ITrafficMonitorForMac/ITrafficMonitorForMac.entitlements; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEVELOPMENT_ASSET_PATHS = "\"ITrafficMonitorForMac/Preview Content\""; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = ITrafficMonitorForMac/Info.plist; @@ -364,7 +365,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 0.1.5; + MARKETING_VERSION = 0.1.6; PRODUCT_BUNDLE_IDENTIFIER = com.foamzou.ITrafficMonitorForMac; PRODUCT_NAME = ITraffic; SWIFT_VERSION = 5.0; @@ -377,9 +378,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_ENTITLEMENTS = ITrafficMonitorForMac/ITrafficMonitorForMac.entitlements; + CODE_SIGN_IDENTITY = "-"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 6; + CURRENT_PROJECT_VERSION = 7; DEVELOPMENT_ASSET_PATHS = "\"ITrafficMonitorForMac/Preview Content\""; ENABLE_PREVIEWS = YES; INFOPLIST_FILE = ITrafficMonitorForMac/Info.plist; @@ -388,7 +390,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.15; - MARKETING_VERSION = 0.1.5; + MARKETING_VERSION = 0.1.6; PRODUCT_BUNDLE_IDENTIFIER = com.foamzou.ITrafficMonitorForMac; PRODUCT_NAME = ITraffic; SWIFT_VERSION = 5.0; diff --git a/ITrafficMonitorForMac/AppDelegate.swift b/ITrafficMonitorForMac/AppDelegate.swift index fc67d44..d61d8d3 100644 --- a/ITrafficMonitorForMac/AppDelegate.swift +++ b/ITrafficMonitorForMac/AppDelegate.swift @@ -64,8 +64,20 @@ class AppDelegate: NSObject, NSApplicationDelegate { if globalModel.controllerHaveBeenReleased == true { print("new controller") AppDelegate.popover.contentViewController = NSHostingController(rootView: self.contentView.withGlobalEnvironmentObjects()) + AppDelegate.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY) // to avoid the child windows could not be create in the first time } + if let parentWindow = NSApp.windows.first, + let popoverVCWindow = AppDelegate.popover.contentViewController?.view.window, + let childWindows = parentWindow.childWindows { + if !childWindows.contains(popoverVCWindow) { + parentWindow.addChildWindow(popoverVCWindow, ordered: .above) + } + } else { + print("Failed to add child window") + } + + AppDelegate.popover.show(relativeTo: button.bounds, of: button, preferredEdge: NSRectEdge.minY) AppDelegate.popover.contentViewController?.view.viewDidMoveToWindow() AppDelegate.popover.contentViewController?.view.window?.becomeKey()