Skip to content
Snippets Groups Projects
Commit c4144ac0 authored by Lakr Aream's avatar Lakr Aream
Browse files

Minor Fix

parent 65e1b38c
No related branches found
Tags 1.1.8
No related merge requests found
......@@ -10,6 +10,7 @@
5005A4812A8BACB900F4C351 /* CryptoKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5005A4802A8BACB900F4C351 /* CryptoKit.swift */; };
5005A4842A8BAE5C00F4C351 /* ZipArchive in Frameworks */ = {isa = PBXBuildFile; productRef = 5005A4832A8BAE5C00F4C351 /* ZipArchive */; };
5005A4862A8BDAE100F4C351 /* Date.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5005A4852A8BDAE100F4C351 /* Date.swift */; };
5031BFED2A8FBED100724DA6 /* ModalSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5031BFEC2A8FBED100724DA6 /* ModalSheet.swift */; };
5031D1C52A864A890089B44F /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5031D1C42A864A890089B44F /* Configuration.swift */; };
5031D1C72A864EAA0089B44F /* DeviceConfigurationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5031D1C62A864EAA0089B44F /* DeviceConfigurationView.swift */; };
5031D1C92A8650020089B44F /* UnpairedDeviceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5031D1C82A8650020089B44F /* UnpairedDeviceView.swift */; };
......@@ -47,6 +48,7 @@
/* Begin PBXFileReference section */
5005A4802A8BACB900F4C351 /* CryptoKit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CryptoKit.swift; sourceTree = "<group>"; };
5005A4852A8BDAE100F4C351 /* Date.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Date.swift; sourceTree = "<group>"; };
5031BFEC2A8FBED100724DA6 /* ModalSheet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ModalSheet.swift; sourceTree = "<group>"; };
5031D1C42A864A890089B44F /* Configuration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Configuration.swift; sourceTree = "<group>"; };
5031D1C62A864EAA0089B44F /* DeviceConfigurationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceConfigurationView.swift; sourceTree = "<group>"; };
5031D1C82A8650020089B44F /* UnpairedDeviceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnpairedDeviceView.swift; sourceTree = "<group>"; };
......@@ -151,6 +153,7 @@
50680FFB2A8553F700367607 /* Extension */ = {
isa = PBXGroup;
children = (
5031BFEC2A8FBED100724DA6 /* ModalSheet.swift */,
50680FFC2A85540800367607 /* PublishedStorage.swift */,
5005A4852A8BDAE100F4C351 /* Date.swift */,
5031D1CE2A86796E0089B44F /* UITemplate.swift */,
......@@ -296,6 +299,7 @@
50FF936C2A88C90E0031843C /* FileManager.swift in Sources */,
50680FF52A854A5A00367607 /* SidebarView.swift in Sources */,
50FF93782A890CF90031843C /* Backup.swift in Sources */,
5031BFED2A8FBED100724DA6 /* ModalSheet.swift in Sources */,
50680FF32A8548E800367607 /* WelcomeView.swift in Sources */,
50FF936E2A88D6F70031843C /* String.swift in Sources */,
504558462A869458006A450C /* BackupProgressListView.swift in Sources */,
......@@ -443,7 +447,7 @@
CODE_SIGN_ENTITLEMENTS = BBackupp/BBackupp.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 8;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 6CMYQQFFT8;
......@@ -475,7 +479,7 @@
CODE_SIGN_ENTITLEMENTS = BBackupp/BBackupp.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 6;
CURRENT_PROJECT_VERSION = 8;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = 6CMYQQFFT8;
......
......@@ -62,7 +62,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
alert.messageText = "Quit the app will cancel all backup and disable scheduled backup"
alert.addButton(withTitle: "Exit")
alert.addButton(withTitle: "Cancel")
let resp = alert.runModal()
let resp: NSApplication.ModalResponse
if let window = NSApp.mainWindow {
resp = alert.runSheetModal(for: window)
} else {
resp = alert.runModal()
}
return resp == .alertFirstButtonReturn ? .terminateNow : .terminateCancel
}
......
......@@ -19,11 +19,14 @@ struct BBackuppApp: App {
init() {
_ = appConfiguration
checkAllStorageLocation()
_ = appleDevice
_ = deviceManager
_ = backupManager
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
Self.checkAllStorageLocation()
deviceManager.startTimer()
}
}
var body: some Scene {
......@@ -35,7 +38,7 @@ struct BBackuppApp: App {
.commands { SidebarCommands() }
}
func checkAllStorageLocation() {
static func checkAllStorageLocation() {
appConfiguration.deviceConfiguration.values.forEach { config in
let dir = config.storeLocationURL
let signalFile = dir.appendingPathComponent(".PermissionCheck")
......@@ -48,16 +51,21 @@ struct BBackuppApp: App {
}
}
func requestPermission(atLocation: URL, error: Error?) {
static func requestPermission(atLocation: URL, error: Error?) {
while true {
let alert = NSAlert()
alert.alertStyle = .critical
alert.messageText = "We are unable to write to storage location for your backup, please select storage directory in the up coming panel to grant us the permission."
alert.informativeText = error?.localizedDescription ?? atLocation.path
alert.addButton(withTitle: "Continue")
alert.addButton(withTitle: "Ignore")
alert.addButton(withTitle: "Exit")
let resp = alert.runModal()
alert.messageText = "Please choose the storage directory in the next panel to grant us permission to store your backup."
alert.informativeText = "Write error happens at \(atLocation.path): \(error?.localizedDescription ?? "unknown")"
alert.addButton(withTitle: "Grant Permission")
alert.addButton(withTitle: "Ignore Temporary")
alert.addButton(withTitle: "Exit Application")
let resp: NSApplication.ModalResponse
if let window = NSApp.mainWindow {
resp = alert.runSheetModal(for: window)
} else {
resp = alert.runModal()
}
switch resp {
case .alertFirstButtonReturn: break
case .alertSecondButtonReturn: return
......@@ -69,7 +77,14 @@ struct BBackuppApp: App {
let savePanel = NSSavePanel()
savePanel.directoryURL = atLocation.deletingLastPathComponent()
savePanel.nameFieldStringValue = atLocation.lastPathComponent
savePanel.runModal()
savePanel.title = "Please select \(atLocation.path) and click Done"
savePanel.prompt = "Grant Permission"
if let window = NSApp.mainWindow {
savePanel.runSheetModal(for: window)
} else {
savePanel.runModal()
}
if savePanel.url == atLocation { return }
}
}
......
......@@ -37,6 +37,9 @@ class DeviceManager: NSObject, ObservableObject {
override private init() {
super.init()
}
func startTimer() {
let timer = Timer(
timeInterval: 1,
target: self,
......
//
// ModalSheet.swift
// BBackupp
//
// Created by QAQ on 2023/8/18.
//
import Cocoa
extension NSAlert {
func runSheetModal(for sheetWindow: NSWindow) -> NSApplication.ModalResponse {
beginSheetModal(for: sheetWindow, completionHandler: NSApp.stopModal(withCode:))
return NSApp.runModal(for: sheetWindow)
}
}
extension NSSavePanel {
@discardableResult
func runSheetModal(for sheetWindow: NSWindow) -> NSApplication.ModalResponse {
beginSheetModal(for: sheetWindow, completionHandler: NSApp.stopModal(withCode:))
return NSApp.runModal(for: sheetWindow)
}
}
//
// NoConfirmSavePanel.swift
// BBackupp
//
// Created by QAQ on 2023/8/18.
//
import Cocoa
class NoConfirmSavePanel: NSSavePanel {
@objc func _overwriteExistingFileCheck(filename: NSString) -> Bool {
_ = filename
return false
}
}
Subproject commit 3bca352fbff6ef5d91b6560dc06af184c8ad180e
Subproject commit 1851d9767a33e4ec38c694ea41c85b4275520aab
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment