From 2de2155fbefff6a89a0e22e6787a33e462e9efce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sat, 16 Aug 2025 14:40:23 +0200 Subject: [PATCH 1/3] Avoid opening the same windows twice --- QuickDrop/AppDelegate.swift | 36 +++++++++++++++++++++--------- QuickDrop/View/LicenseWindow.swift | 4 +--- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/QuickDrop/AppDelegate.swift b/QuickDrop/AppDelegate.swift index 1ad51a1..b9e989f 100644 --- a/QuickDrop/AppDelegate.swift +++ b/QuickDrop/AppDelegate.swift @@ -221,6 +221,13 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele @objc func openPlusScreen() { + // If window already exists and is visible, just bring it to the front + if let window = plusWindow, window.isVisible { + NSApp.activate(ignoringOtherApps: true) + window.makeKeyAndOrderFront(nil) + return + } + // Create the welcome screen SwiftUI view let plusView = PlusView(closeView: { log("Closing plus screen") @@ -228,26 +235,33 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele }) // Create an NSWindow to host the SwiftUI view - plusWindow = NSWindow( + let window = NSWindow( contentRect: NSRect(x: 0, y: 0, width: plusViewWidth, height: plusViewHeight), styleMask: [.titled, .closable], backing: .buffered, defer: false ) - plusWindow?.styleMask.insert(.fullSizeContentView) - plusWindow?.titleVisibility = .hidden - plusWindow?.titlebarAppearsTransparent = true + window.styleMask.insert(.fullSizeContentView) + window.titleVisibility = .hidden + window.titlebarAppearsTransparent = true - plusWindow?.center() - plusWindow?.isReleasedWhenClosed = false - plusWindow?.setFrameAutosaveName("PlusScreen") - plusWindow?.contentView = NSHostingView(rootView: plusView) + window.center() + window.isReleasedWhenClosed = false + window.setFrameAutosaveName("PlusScreen") + window.contentView = NSHostingView(rootView: plusView) + + // Reset reference when closed by red button + NotificationCenter.default.addObserver(forName: NSWindow.willCloseNotification, object: window, queue: .main) { [weak self] _ in + self?.plusWindow = nil + } + + plusWindow = window // Ensure the window is always on top - NSApp.activate(ignoringOtherApps: true) // Brings the whole app to the front - plusWindow?.makeKeyAndOrderFront(nil) - plusWindow?.level = .normal + NSApp.activate(ignoringOtherApps: true) + window.makeKeyAndOrderFront(nil) + window.level = .normal } diff --git a/QuickDrop/View/LicenseWindow.swift b/QuickDrop/View/LicenseWindow.swift index fe20546..33802cf 100644 --- a/QuickDrop/View/LicenseWindow.swift +++ b/QuickDrop/View/LicenseWindow.swift @@ -31,7 +31,6 @@ struct LicensePage: View { func openLicenseWindow() -> NSWindow { - // Create a new NSWindow and retain it in the `newWindow` property let window = NSWindow( contentRect: NSRect(x: 0, y: 0, width: 500, height: 400), styleMask: [.titled, .closable, .resizable], @@ -44,10 +43,9 @@ func openLicenseWindow() -> NSWindow { window.contentView = NSHostingView(rootView: LicensePage()) // Ensure the window is always on top - NSApp.activate(ignoringOtherApps: true) // Brings the whole app to the front + NSApp.activate(ignoringOtherApps: true) window.makeKeyAndOrderFront(nil) window.level = .normal - // Retain the window to prevent deallocation return window } From f4efd4fb9b6b1df5bcdddd41d1a30de3893f3af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sat, 16 Aug 2025 14:56:23 +0200 Subject: [PATCH 2/3] Bump version number --- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- QuickDrop/Localizable.xcstrings | 3 --- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 1fad6cc..8715531 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -888,8 +888,8 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 61; - SHARED_VERSION = 1.12.2; + SHARED_BUILD = 63; + SHARED_VERSION = 1.12.4; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -950,8 +950,8 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 61; - SHARED_VERSION = 1.12.2; + SHARED_BUILD = 63; + SHARED_VERSION = 1.12.4; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_OPTIMIZATION_LEVEL = "-O"; diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index 1e5ce82..a88b076 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -7157,9 +7157,6 @@ } } } - }, - "Reset UD" : { - }, "SaveFilesLocation" : { "extractionState" : "manual", From 6f4a413768557fc0fdf52639bba2bf64fde0cd49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Sat, 16 Aug 2025 16:04:54 +0200 Subject: [PATCH 3/3] Fix deployment targets --- QuickDrop.xcodeproj/project.pbxproj | 8 ++++---- QuickDrop/Localizable.xcstrings | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 8715531..8562a73 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -883,7 +883,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11.5; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; @@ -946,7 +946,7 @@ GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; LOCALIZATION_PREFERS_STRING_CATALOGS = YES; - MACOSX_DEPLOYMENT_TARGET = 10.15; + MACOSX_DEPLOYMENT_TARGET = 11.5; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; @@ -1053,7 +1053,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 18.5; + IPHONEOS_DEPLOYMENT_TARGET = 16.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1089,7 +1089,7 @@ INFOPLIST_KEY_UILaunchScreen_Generation = YES; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 18.5; + IPHONEOS_DEPLOYMENT_TARGET = 16.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index a88b076..1e5ce82 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -7157,6 +7157,9 @@ } } } + }, + "Reset UD" : { + }, "SaveFilesLocation" : { "extractionState" : "manual",