From 3f2296ea8d993137701ca5419794f3f36b4cd72e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1rady=20Mil=C3=A1n?= <61704770+MilanVarady@users.noreply.github.com> Date: Wed, 1 Jan 2025 23:24:28 +0100 Subject: [PATCH] Close app after last window is closed --- Applite.xcodeproj/project.pbxproj | 8 ++++++-- Applite/AppDelegate.swift | 16 ++++++++++++++++ Applite/AppliteApp.swift | 2 ++ 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 Applite/AppDelegate.swift diff --git a/Applite.xcodeproj/project.pbxproj b/Applite.xcodeproj/project.pbxproj index 1a312ea..b5a3b87 100644 --- a/Applite.xcodeproj/project.pbxproj +++ b/Applite.xcodeproj/project.pbxproj @@ -107,6 +107,7 @@ 419256A82D25D10F00D9EF10 /* ExportFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419256A72D25D10F00D9EF10 /* ExportFile.swift */; }; 419256AB2D25E19B00D9EF10 /* BrewManagementView+ActionsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419256AA2D25E19B00D9EF10 /* BrewManagementView+ActionsView.swift */; }; 419256AD2D25E1F100D9EF10 /* BrewManagementView+InfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419256AC2D25E1F100D9EF10 /* BrewManagementView+InfoView.swift */; }; + 419256AF2D25F68700D9EF10 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419256AE2D25F68700D9EF10 /* AppDelegate.swift */; }; 419506A42964A27F00FE5802 /* SetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419506A32964A27F00FE5802 /* SetupView.swift */; }; 419506A62964A5EF00FE5802 /* BrewPathSelectorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 419506A52964A5EF00FE5802 /* BrewPathSelectorView.swift */; }; 4196C8F528F9CB2600EADDDA /* DiscoverView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4196C8F428F9CB2600EADDDA /* DiscoverView.swift */; }; @@ -218,6 +219,7 @@ 419256A72D25D10F00D9EF10 /* ExportFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExportFile.swift; sourceTree = ""; }; 419256AA2D25E19B00D9EF10 /* BrewManagementView+ActionsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrewManagementView+ActionsView.swift"; sourceTree = ""; }; 419256AC2D25E1F100D9EF10 /* BrewManagementView+InfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BrewManagementView+InfoView.swift"; sourceTree = ""; }; + 419256AE2D25F68700D9EF10 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 419506A32964A27F00FE5802 /* SetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetupView.swift; sourceTree = ""; }; 419506A52964A5EF00FE5802 /* BrewPathSelectorView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BrewPathSelectorView.swift; sourceTree = ""; }; 419506A729696A5300FE5802 /* Applite-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Applite-Info.plist"; sourceTree = SOURCE_ROOT; }; @@ -335,15 +337,16 @@ 414074F328DF53E80073EB22 /* Applite */ = { isa = PBXGroup; children = ( - 419506A729696A5300FE5802 /* Applite-Info.plist */, 414074F428DF53E80073EB22 /* AppliteApp.swift */, - 414074F828DF53EB0073EB22 /* Assets.xcassets */, + 419256AE2D25F68700D9EF10 /* AppDelegate.swift */, 4140750328DF5ED00073EB22 /* Views */, 418F332228EC8B120023D76F /* Model */, 4191393129269FD600F1D75D /* Utilities */, 412635402A77F99F00155034 /* Extensions */, 41483CC9290F047A00BB10C2 /* Resources */, 414074FA28DF53EB0073EB22 /* Preview Content */, + 419506A729696A5300FE5802 /* Applite-Info.plist */, + 414074F828DF53EB0073EB22 /* Assets.xcassets */, 414074FD28DF53EB0073EB22 /* Applite.entitlements */, 4196C90128FAF57A00EADDDA /* AppliteDebug.entitlements */, ); @@ -759,6 +762,7 @@ 419256682D1E18D100D9EF10 /* AlertManagerViewModifier.swift in Sources */, 414074F728DF53E80073EB22 /* ContentView.swift in Sources */, 419256392D1DF35C00D9EF10 /* SettingsView+Uninstaller.swift in Sources */, + 419256AF2D25F68700D9EF10 /* AppDelegate.swift in Sources */, 419256472D1E0B0900D9EF10 /* BrewPathSelectorView+GetPathDescription.swift in Sources */, 41DF006429EAA094004EB7AE /* SendNotification.swift in Sources */, 419256622D1E15EA00D9EF10 /* UpdateView+UpdateUnavailable.swift in Sources */, diff --git a/Applite/AppDelegate.swift b/Applite/AppDelegate.swift new file mode 100644 index 0000000..4426941 --- /dev/null +++ b/Applite/AppDelegate.swift @@ -0,0 +1,16 @@ +// +// AppDelegate.swift +// Applite +// +// Created by Milán Várady on 2025.01.01. +// + +import Foundation +import AppKit + +class ApplicationDelegate: NSObject, NSApplicationDelegate { + // Close app after last window closed + func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { + return true + } +} diff --git a/Applite/AppliteApp.swift b/Applite/AppliteApp.swift index 0c22743..27bd87b 100755 --- a/Applite/AppliteApp.swift +++ b/Applite/AppliteApp.swift @@ -12,6 +12,8 @@ import Kingfisher @main struct AppliteApp: App { + @NSApplicationDelegateAdaptor(ApplicationDelegate.self) var appDelegate + @StateObject var caskManager = CaskManager() @AppStorage(Preferences.colorSchemePreference.rawValue) var colorSchemePreference: ColorSchemePreference = .system