mirror of
https://github.com/exituser/Pearcleaner.git
synced 2026-09-17 08:29:07 +00:00
v2.2
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
C77B901E2AF1A9DB009CC655 /* SettingsWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77B901D2AF1A9DB009CC655 /* SettingsWindow.swift */; };
|
C77B901E2AF1A9DB009CC655 /* SettingsWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77B901D2AF1A9DB009CC655 /* SettingsWindow.swift */; };
|
||||||
C77B90232AF2D616009CC655 /* FilesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77B90222AF2D616009CC655 /* FilesView.swift */; };
|
C77B90232AF2D616009CC655 /* FilesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77B90222AF2D616009CC655 /* FilesView.swift */; };
|
||||||
C7A27E812AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist in Resources */ = {isa = PBXBuildFile; fileRef = C7A27E802AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist */; };
|
C7A27E812AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist in Resources */ = {isa = PBXBuildFile; fileRef = C7A27E802AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist */; };
|
||||||
|
C7CF47242B3B3F1700979C5F /* WindowSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7CF47232B3B3F1700979C5F /* WindowSettings.swift */; };
|
||||||
C7D31D462AFDA90C00C7ED9E /* Sentinel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D452AFDA90C00C7ED9E /* Sentinel.swift */; };
|
C7D31D462AFDA90C00C7ED9E /* Sentinel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D452AFDA90C00C7ED9E /* Sentinel.swift */; };
|
||||||
C7D31D482AFEB23700C7ED9E /* TopBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D472AFEB23700C7ED9E /* TopBar.swift */; };
|
C7D31D482AFEB23700C7ED9E /* TopBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D472AFEB23700C7ED9E /* TopBar.swift */; };
|
||||||
C7D31D4A2AFEB26700C7ED9E /* AppListItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D492AFEB26700C7ED9E /* AppListItems.swift */; };
|
C7D31D4A2AFEB26700C7ED9E /* AppListItems.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7D31D492AFEB26700C7ED9E /* AppListItems.swift */; };
|
||||||
@@ -88,6 +89,7 @@
|
|||||||
C77B90242AF2D796009CC655 /* Pearcleaner.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Pearcleaner.entitlements; sourceTree = "<group>"; };
|
C77B90242AF2D796009CC655 /* Pearcleaner.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Pearcleaner.entitlements; sourceTree = "<group>"; };
|
||||||
C7A27E7F2AFD70DD00166168 /* PearcleanerSentinel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PearcleanerSentinel.entitlements; sourceTree = "<group>"; };
|
C7A27E7F2AFD70DD00166168 /* PearcleanerSentinel.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PearcleanerSentinel.entitlements; sourceTree = "<group>"; };
|
||||||
C7A27E802AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.alienator88.PearcleanerSentinel.plist; sourceTree = "<group>"; };
|
C7A27E802AFD7C4600166168 /* com.alienator88.PearcleanerSentinel.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = com.alienator88.PearcleanerSentinel.plist; sourceTree = "<group>"; };
|
||||||
|
C7CF47232B3B3F1700979C5F /* WindowSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WindowSettings.swift; sourceTree = "<group>"; };
|
||||||
C7D31D452AFDA90C00C7ED9E /* Sentinel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sentinel.swift; sourceTree = "<group>"; };
|
C7D31D452AFDA90C00C7ED9E /* Sentinel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Sentinel.swift; sourceTree = "<group>"; };
|
||||||
C7D31D472AFEB23700C7ED9E /* TopBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBar.swift; sourceTree = "<group>"; };
|
C7D31D472AFEB23700C7ED9E /* TopBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopBar.swift; sourceTree = "<group>"; };
|
||||||
C7D31D492AFEB26700C7ED9E /* AppListItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListItems.swift; sourceTree = "<group>"; };
|
C7D31D492AFEB26700C7ED9E /* AppListItems.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppListItems.swift; sourceTree = "<group>"; };
|
||||||
@@ -137,6 +139,7 @@
|
|||||||
C77B901B2AF193A3009CC655 /* Styles.swift */,
|
C77B901B2AF193A3009CC655 /* Styles.swift */,
|
||||||
C7D31D502AFF00F300C7ED9E /* Locations.swift */,
|
C7D31D502AFF00F300C7ED9E /* Locations.swift */,
|
||||||
C7D31D542B008CB900C7ED9E /* Shapes.swift */,
|
C7D31D542B008CB900C7ED9E /* Shapes.swift */,
|
||||||
|
C7CF47232B3B3F1700979C5F /* WindowSettings.swift */,
|
||||||
);
|
);
|
||||||
path = Logic;
|
path = Logic;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -367,6 +370,7 @@
|
|||||||
C7D31D482AFEB23700C7ED9E /* TopBar.swift in Sources */,
|
C7D31D482AFEB23700C7ED9E /* TopBar.swift in Sources */,
|
||||||
C7F539382AF60865007DF1B2 /* Utilities.swift in Sources */,
|
C7F539382AF60865007DF1B2 /* Utilities.swift in Sources */,
|
||||||
C76D08552AF89CDE00D07867 /* AppListView.swift in Sources */,
|
C76D08552AF89CDE00D07867 /* AppListView.swift in Sources */,
|
||||||
|
C7CF47242B3B3F1700979C5F /* WindowSettings.swift in Sources */,
|
||||||
C77B90232AF2D616009CC655 /* FilesView.swift in Sources */,
|
C77B90232AF2D616009CC655 /* FilesView.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@@ -539,7 +543,7 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 12;
|
CURRENT_PROJECT_VERSION = 13;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = BK8443AXLU;
|
DEVELOPMENT_TEAM = BK8443AXLU;
|
||||||
@@ -557,7 +561,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 2.1;
|
MARKETING_VERSION = 2.2;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
|
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -574,7 +578,7 @@
|
|||||||
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
CURRENT_PROJECT_VERSION = 12;
|
CURRENT_PROJECT_VERSION = 13;
|
||||||
DEAD_CODE_STRIPPING = YES;
|
DEAD_CODE_STRIPPING = YES;
|
||||||
DEVELOPMENT_ASSET_PATHS = "";
|
DEVELOPMENT_ASSET_PATHS = "";
|
||||||
DEVELOPMENT_TEAM = BK8443AXLU;
|
DEVELOPMENT_TEAM = BK8443AXLU;
|
||||||
@@ -592,7 +596,7 @@
|
|||||||
"@executable_path/../Frameworks",
|
"@executable_path/../Frameworks",
|
||||||
);
|
);
|
||||||
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
MACOSX_DEPLOYMENT_TARGET = 13.0;
|
||||||
MARKETING_VERSION = 2.1;
|
MARKETING_VERSION = 2.2;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
|
PRODUCT_BUNDLE_IDENTIFIER = com.alienator88.Pearcleaner;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
@@ -279,15 +279,17 @@ func findPathsForApp(appState: AppState, appInfo: AppInfo) {
|
|||||||
|
|
||||||
let fileManager = FileManager.default
|
let fileManager = FileManager.default
|
||||||
let dispatchGroup = DispatchGroup()
|
let dispatchGroup = DispatchGroup()
|
||||||
let bundleComponents = appInfo.bundleIdentifier.components(separatedBy: ".")
|
var bundleComponents = appInfo.bundleIdentifier.components(separatedBy: ".")
|
||||||
|
if let lastComponent = bundleComponents.last, let rangeOfDash = lastComponent.range(of: "-") {
|
||||||
|
// Remove the dash and everything after it
|
||||||
|
let updatedLastComponent = String(lastComponent[..<rangeOfDash.lowerBound])
|
||||||
|
bundleComponents[bundleComponents.count - 1] = updatedLastComponent
|
||||||
|
}
|
||||||
var bundle: String = ""
|
var bundle: String = ""
|
||||||
// var weirdFormatBundle: Bool = false
|
|
||||||
if bundleComponents.count >= 3 { // get last 2 or middle 2 components
|
if bundleComponents.count >= 3 { // get last 2 or middle 2 components
|
||||||
bundle = bundleComponents[1...2].joined(separator: "").lowercased()
|
bundle = bundleComponents[1...2].joined(separator: "").lowercased()
|
||||||
}
|
}
|
||||||
// if bundleComponents[0] != "com" {
|
|
||||||
// weirdFormatBundle = true
|
|
||||||
// }
|
|
||||||
let nameL = appInfo.appName.pearFormat()
|
let nameL = appInfo.appName.pearFormat()
|
||||||
let bundleIdentifierL = appInfo.bundleIdentifier.pearFormat()
|
let bundleIdentifierL = appInfo.bundleIdentifier.pearFormat()
|
||||||
let locations = Locations()
|
let locations = Locations()
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// WindowSettings.swift
|
||||||
|
// Pearcleaner
|
||||||
|
//
|
||||||
|
// Created by Alin Lupascu on 12/26/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
class WindowSettings {
|
||||||
|
private let windowWidthKey = "windowWidthKey"
|
||||||
|
private let windowHeightKey = "windowHeightKey"
|
||||||
|
private let windowXKey = "windowXKey"
|
||||||
|
private let windowYKey = "windowYKey"
|
||||||
|
|
||||||
|
func saveWindowSettings(frame: NSRect) {
|
||||||
|
UserDefaults.standard.set(Float(frame.size.width), forKey: windowWidthKey)
|
||||||
|
UserDefaults.standard.set(Float(frame.size.height), forKey: windowHeightKey)
|
||||||
|
UserDefaults.standard.set(Float(frame.origin.x), forKey: windowXKey)
|
||||||
|
UserDefaults.standard.set(Float(frame.origin.y), forKey: windowYKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadWindowSettings() -> NSRect {
|
||||||
|
let width = CGFloat(UserDefaults.standard.float(forKey: windowWidthKey))
|
||||||
|
let height = CGFloat(UserDefaults.standard.float(forKey: windowHeightKey))
|
||||||
|
let x = CGFloat(UserDefaults.standard.float(forKey: windowXKey))
|
||||||
|
let y = CGFloat(UserDefaults.standard.float(forKey: windowYKey))
|
||||||
|
|
||||||
|
return NSRect(x: x, y: y, width: width, height: height)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import AppKit
|
|||||||
struct PearcleanerApp: App {
|
struct PearcleanerApp: App {
|
||||||
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
||||||
@StateObject var appState = AppState()
|
@StateObject var appState = AppState()
|
||||||
|
@State private var windowSettings = WindowSettings()
|
||||||
@AppStorage("settings.updater.updateTimeframe") private var updateTimeframe: Int = 1
|
@AppStorage("settings.updater.updateTimeframe") private var updateTimeframe: Int = 1
|
||||||
@AppStorage("settings.permissions.disk") private var diskP: Bool = false
|
@AppStorage("settings.permissions.disk") private var diskP: Bool = false
|
||||||
@AppStorage("settings.permissions.events") private var diskE: Bool = false
|
@AppStorage("settings.permissions.events") private var diskE: Bool = false
|
||||||
@@ -54,10 +55,20 @@ struct PearcleanerApp: App {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
// Save window size on window dimension change
|
||||||
|
.onChange(of: NSApplication.shared.windows.first?.frame) { newFrame in
|
||||||
|
if let newFrame = newFrame {
|
||||||
|
windowSettings.saveWindowSettings(frame: newFrame)
|
||||||
|
}
|
||||||
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
// Disable tabbing
|
// Disable tabbing
|
||||||
NSWindow.allowsAutomaticWindowTabbing = false
|
NSWindow.allowsAutomaticWindowTabbing = false
|
||||||
|
|
||||||
|
// Set window size on load
|
||||||
|
let frame = windowSettings.loadWindowSettings()
|
||||||
|
NSApplication.shared.windows.first?.setFrame(frame, display: true)
|
||||||
|
|
||||||
// Get Apps
|
// Get Apps
|
||||||
let sortedApps = getSortedApps()
|
let sortedApps = getSortedApps()
|
||||||
appState.sortedApps.userApps = sortedApps.userApps
|
appState.sortedApps.userApps = sortedApps.userApps
|
||||||
@@ -121,20 +132,7 @@ struct PearcleanerApp: App {
|
|||||||
|
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||||
#if DEBUG
|
|
||||||
return true
|
return true
|
||||||
#else
|
|
||||||
return false
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
// func application(_ sender: NSApplication, open urls: [URL]) {
|
|
||||||
// for url in urls {
|
|
||||||
// if url.pathExtension == "app" {
|
|
||||||
// writeLog(string: url.path)
|
|
||||||
// print("Dropped app path:", url.path)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user