From 03ba815454d3af6820458a0aaafa8175195944dc Mon Sep 17 00:00:00 2001 From: Alin Date: Tue, 28 May 2024 17:16:22 -0600 Subject: [PATCH] 3.6.4 --- Pearcleaner.xcodeproj/project.pbxproj | 8 +++---- Pearcleaner/Logic/Conditions.swift | 2 +- Pearcleaner/PearcleanerApp.swift | 3 ++- Pearcleaner/Settings/Interface.swift | 2 +- Pearcleaner/Views/AppSearchView.swift | 32 +++++++++++++++++++++------ Pearcleaner/Views/AppsListView.swift | 27 +--------------------- Pearcleaner/Views/FilesView.swift | 12 ++++++++++ Pearcleaner/Views/MiniMode.swift | 3 ++- Pearcleaner/Views/RegularMode.swift | 4 ++-- Pearcleaner/Windows/FeatureView.swift | 2 +- Pearcleaner/Windows/PermView.swift | 2 +- Pearcleaner/Windows/UpdateView.swift | 10 ++++----- PearcleanerSentinel/main.swift | 3 --- 13 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Pearcleaner.xcodeproj/project.pbxproj b/Pearcleaner.xcodeproj/project.pbxproj index fd3bf91..6fd60e5 100644 --- a/Pearcleaner.xcodeproj/project.pbxproj +++ b/Pearcleaner.xcodeproj/project.pbxproj @@ -568,8 +568,8 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - APP_BUILD = 41; - APP_VERSION = 3.6.2; + APP_BUILD = 43; + APP_VERSION = 3.6.4; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; @@ -638,8 +638,8 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; - APP_BUILD = 41; - APP_VERSION = 3.6.2; + APP_BUILD = 43; + APP_VERSION = 3.6.4; ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; diff --git a/Pearcleaner/Logic/Conditions.swift b/Pearcleaner/Logic/Conditions.swift index 90d3aa1..988c490 100644 --- a/Pearcleaner/Logic/Conditions.swift +++ b/Pearcleaner/Logic/Conditions.swift @@ -67,7 +67,7 @@ var conditions: [Condition] = [ ), Condition( bundle_id: "orgmozillafirefox", - include: ["mozilla"], + include: ["mozilla", "firefox"], exclude: [] ), Condition( diff --git a/Pearcleaner/PearcleanerApp.swift b/Pearcleaner/PearcleanerApp.swift index a8cdaf6..27cb510 100644 --- a/Pearcleaner/PearcleanerApp.swift +++ b/Pearcleaner/PearcleanerApp.swift @@ -95,7 +95,7 @@ struct PearcleanerApp: App { // Enable menubar item if menubarEnabled { MenuBarExtraManager.shared.addMenuBarExtra(withView: { - MiniAppView(search: $search, showPopover: $showPopover) + MiniAppView(search: $search, showPopover: $showPopover, isMenuBar: true) .environmentObject(locations) .environmentObject(appState) .environmentObject(fsm) @@ -179,6 +179,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { func applicationDidFinishLaunching(_ notification: Notification) { let menubarEnabled = UserDefaults.standard.bool(forKey: "settings.menubar.enabled") // UserDefaults.standard.register(defaults: ["NSQuitAlwaysKeepsWindows" : false]) + findAndSetWindowFrame(named: ["Pearcleaner"], windowSettings: windowSettings) if UserDefaults.standard.object(forKey: "themeColor") == nil { diff --git a/Pearcleaner/Settings/Interface.swift b/Pearcleaner/Settings/Interface.swift index 1f22bd0..bc58c87 100644 --- a/Pearcleaner/Settings/Interface.swift +++ b/Pearcleaner/Settings/Interface.swift @@ -425,7 +425,7 @@ struct InterfaceSettingsTab: View { .onChange(of: menubarEnabled) { newVal in if newVal { MenuBarExtraManager.shared.addMenuBarExtra(withView: { - MiniAppView(search: $search, showPopover: $showPopover) + MiniAppView(search: $search, showPopover: $showPopover, isMenuBar: true) .environmentObject(locations) .environmentObject(appState) .environmentObject(fsm) diff --git a/Pearcleaner/Views/AppSearchView.swift b/Pearcleaner/Views/AppSearchView.swift index fd8246d..09a8cdd 100644 --- a/Pearcleaner/Views/AppSearchView.swift +++ b/Pearcleaner/Views/AppSearchView.swift @@ -21,12 +21,13 @@ struct AppSearchView: View { @State private var showMenu = false @State private var showSys: Bool = true @State private var showUsr: Bool = true + @Binding var isMenuBar: Bool var body: some View { VStack(alignment: .center, spacing: 0) { Spacer() .frame(height: 10) - .padding(.top, !menubarEnabled ? 25 : 0) + .padding(.top, !isMenuBar ? 25 : 0) if appState.updateAvailable { UpdateNotificationView(appState: appState) @@ -40,13 +41,30 @@ struct AppSearchView: View { Divider() +#if DEBUG + Rectangle() + .fill(.orange) + .frame(height: 2) + +#endif + HStack(spacing: 10) { -#if DEBUG - Image(systemName: "ant.fill") - .foregroundStyle(.orange) - .help("DEBUG") -#endif + if search.isEmpty { + Button("Refresh") { + withAnimation { + // Refresh Apps list + appState.reload.toggle() + showPopover = false + let sortedApps = getSortedApps(paths: fsm.folderPaths, appState: appState) + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + appState.sortedApps = sortedApps + appState.reload.toggle() + } + } + } + .buttonStyle(SimpleButtonStyle(icon: "arrow.uturn.backward.circle", help: "Refresh apps (⌘+R)", size: 16)) + } SearchBar(search: $search, darker: (mini || menubarEnabled) ? false : true, glass: glass) @@ -55,7 +73,7 @@ struct AppSearchView: View { Button("More") { self.showMenu.toggle() } - .buttonStyle(SimpleButtonStyle(icon: "ellipsis.circle", help: "More", rotate: true)) + .buttonStyle(SimpleButtonStyle(icon: "ellipsis.circle", help: "More", size: 16, rotate: true)) .popover(isPresented: $showMenu) { VStack(alignment: .leading) { diff --git a/Pearcleaner/Views/AppsListView.swift b/Pearcleaner/Views/AppsListView.swift index f51f406..4de21ff 100644 --- a/Pearcleaner/Views/AppsListView.swift +++ b/Pearcleaner/Views/AppsListView.swift @@ -62,7 +62,7 @@ struct SectionView: View { struct Header: View { let title: String let count: Int - @State private var hovered = false +// @State private var hovered = false @EnvironmentObject var appState: AppState @EnvironmentObject var locations: Locations @EnvironmentObject var fsm: FolderSettingsManager @@ -84,33 +84,8 @@ struct Header: View { Spacer() - if hovered { - Text("REFRESH") - .font(.system(size: 10)) - .monospaced() - .foregroundStyle(Color("mode").opacity(0.8)) - } - - } - .onHover { hovering in - withAnimation() { - hovered = hovering - } - } - .onTapGesture { - withAnimation { - // Refresh Apps list - appState.reload.toggle() - showPopover = false - let sortedApps = getSortedApps(paths: fsm.folderPaths, appState: appState) - DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - appState.sortedApps = sortedApps - appState.reload.toggle() - } - } } .frame(minHeight: 20) - .help("Click header or ⌘+R to refresh apps list") .padding(5) } } diff --git a/Pearcleaner/Views/FilesView.swift b/Pearcleaner/Views/FilesView.swift index de72fb2..6989089 100644 --- a/Pearcleaner/Views/FilesView.swift +++ b/Pearcleaner/Views/FilesView.swift @@ -303,6 +303,18 @@ struct FilesView: View { // Remove app from app list if main app bundle is removed for regular and wrapped apps if (appState.appInfo.wrapped && selectedItemsArray.contains(where: { $0.absoluteString == appState.appInfo.path.deletingLastPathComponent().deletingLastPathComponent().absoluteString })) || (!appState.appInfo.wrapped && selectedItemsArray.contains(where: { $0.absoluteString == appState.appInfo.path.absoluteString })) { + // Change view back to empty/apps if main app bundle is removed + updateOnMain { + search = "" + withAnimation { + if mini || menubarEnabled { + appState.currentView = .apps + showPopover = false + } else { + appState.currentView = .empty + } + } + } // Match found, remove the app removeApp(appState: appState, withPath: appState.appInfo.path) } else { diff --git a/Pearcleaner/Views/MiniMode.swift b/Pearcleaner/Views/MiniMode.swift index 809c7e0..c55528d 100644 --- a/Pearcleaner/Views/MiniMode.swift +++ b/Pearcleaner/Views/MiniMode.swift @@ -152,6 +152,7 @@ struct MiniAppView: View { @AppStorage("settings.general.sidebarWidth") private var sidebarWidth: Double = 280 @Binding var showPopover: Bool @State private var showMenu = false + @State var isMenuBar: Bool = false var body: some View { @@ -166,7 +167,7 @@ struct MiniAppView: View { } .padding(.vertical) } else { - AppSearchView(glass: glass, sidebarWidth: sidebarWidth, menubarEnabled: menubarEnabled, mini: mini, search: $search, showPopover: $showPopover) + AppSearchView(glass: glass, sidebarWidth: sidebarWidth, menubarEnabled: menubarEnabled, mini: mini, search: $search, showPopover: $showPopover, isMenuBar: $isMenuBar) } } diff --git a/Pearcleaner/Views/RegularMode.swift b/Pearcleaner/Views/RegularMode.swift index 824bafb..2607c9b 100644 --- a/Pearcleaner/Views/RegularMode.swift +++ b/Pearcleaner/Views/RegularMode.swift @@ -21,7 +21,7 @@ struct RegularMode: View { @State private var showUsr: Bool = true @Binding var showPopover: Bool @State private var showMenu = false - + @State var isMenuBar: Bool = false var body: some View { @@ -39,7 +39,7 @@ struct RegularMode: View { .frame(width: sidebarWidth) .padding(.vertical) } else { - AppSearchView(glass: glass, sidebarWidth: sidebarWidth, menubarEnabled: menubarEnabled, mini: mini, search: $search, showPopover: $showPopover) + AppSearchView(glass: glass, sidebarWidth: sidebarWidth, menubarEnabled: menubarEnabled, mini: mini, search: $search, showPopover: $showPopover, isMenuBar: $isMenuBar) .frame(width: sidebarWidth) } diff --git a/Pearcleaner/Windows/FeatureView.swift b/Pearcleaner/Windows/FeatureView.swift index c806291..e2032dc 100644 --- a/Pearcleaner/Windows/FeatureView.swift +++ b/Pearcleaner/Windows/FeatureView.swift @@ -45,7 +45,7 @@ struct FeatureView: View { }) { Text("Okay") } - .buttonStyle(SimpleButtonBrightStyle(icon: "checkmark.circle", label: "Ok", help: "Ok", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "checkmark.circle", label: "Ok", help: "Ok", color: Color("mode"))) } .padding(.bottom) diff --git a/Pearcleaner/Windows/PermView.swift b/Pearcleaner/Windows/PermView.swift index b66e70c..415c526 100644 --- a/Pearcleaner/Windows/PermView.swift +++ b/Pearcleaner/Windows/PermView.swift @@ -97,7 +97,7 @@ struct PermView: View { if #available(macOS 14.0, *) { SettingsLink {} - .buttonStyle(SimpleButtonBrightStyle(icon: "gear", label: "Settings", help: "Check permissions in Settings", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "gear", label: "Settings", help: "Check permissions in Settings", color: Color("mode"))) } else { Button("Settings") { NSApp.sendAction(Selector(("showPreferencesWindow:")), to: NSApp.delegate, from: nil) diff --git a/Pearcleaner/Windows/UpdateView.swift b/Pearcleaner/Windows/UpdateView.swift index c20f055..4de0772 100644 --- a/Pearcleaner/Windows/UpdateView.swift +++ b/Pearcleaner/Windows/UpdateView.swift @@ -56,7 +56,7 @@ struct UpdateView: View { if !isAppInCorrectDirectory { Text("To avoid permission issues, please move Pearcleaner to the \(isUserAdmin ? "/Applications" : "\(home)/Applications") folder before updating!") .font(.callout) - .foregroundStyle(Color.accentColor) + .foregroundStyle(Color("mode")) .padding(.horizontal) .padding(.top, 0) } @@ -81,7 +81,7 @@ struct UpdateView: View { }) { Text("Update") } - .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.down.circle", label: "Update", help: "Update", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.down.circle", label: "Update", help: "Update", color: Color("mode"))) } else { Button(action: { NewWin.close() @@ -89,7 +89,7 @@ struct UpdateView: View { }) { Text("Restart") } - .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.uturn.left.circle", label: "Restart", help: "Restart", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.uturn.left.circle", label: "Restart", help: "Restart", color: Color("mode"))) } } @@ -185,7 +185,7 @@ struct NoUpdateView: View { }) { Text("Okay") } - .buttonStyle(SimpleButtonBrightStyle(icon: "checkmark.circle", label: "Ok", help: "Ok", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "checkmark.circle", label: "Ok", help: "Ok", color: Color("mode"))) } @@ -197,7 +197,7 @@ struct NoUpdateView: View { }) { Text("Restart") } - .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.uturn.left.circle", label: "Restart", help: "Restart", color: .accentColor)) + .buttonStyle(SimpleButtonBrightStyle(icon: "arrow.uturn.left.circle", label: "Restart", help: "Restart", color: Color("mode"))) } } .padding(.bottom) diff --git a/PearcleanerSentinel/main.swift b/PearcleanerSentinel/main.swift index 73d0235..baecdc6 100644 --- a/PearcleanerSentinel/main.swift +++ b/PearcleanerSentinel/main.swift @@ -67,9 +67,6 @@ func checkApp(file: String) { - - - // --- Trash Relationship --- extension FileManager { public func isInTrash(_ file: URL) -> Bool {