|
@@ -87,20 +87,17 @@ class KMMergeWindowController: KMBaseWindowController {
|
|
|
|
|
|
extension KMMergeWindowController {
|
|
|
func addFile() {
|
|
|
+ var size = 0.0
|
|
|
+ let files = self.mergeView.files
|
|
|
+ for file in files {
|
|
|
+ size = size + file.fileSize
|
|
|
+ }
|
|
|
+
|
|
|
+ if !IAPProductsManager.default().isAvailableAllFunction() && (files.count >= 2 || size > 20 * 1024 * 1024) {
|
|
|
+ KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
-// if (![IAPProductsManager defaultManager].isAvailableAllFunction) {
|
|
|
-// //免費版只支援2個檔案做合併小于20M的文件合并
|
|
|
-// if (_files.count >= 2 || self.allFileSize > (20 * 1024 * 1024)) {
|
|
|
-// #if VERSION_DMG
|
|
|
-// [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
|
|
|
-// #else
|
|
|
-// KMToolCompareWindowController * vc = [KMToolCompareWindowController toolCompareWithType:KMCompareWithToolType_PageEdit setSelectIndex:1];
|
|
|
-// [vc showWindow:nil];
|
|
|
-// #endif
|
|
|
-// return;
|
|
|
-// }
|
|
|
-//
|
|
|
-// }
|
|
|
let openPanel = NSOpenPanel()
|
|
|
openPanel.allowedFileTypes = ["pdf"]
|
|
|
|
|
@@ -117,32 +114,23 @@ extension KMMergeWindowController {
|
|
|
var array: [URL] = []
|
|
|
for fileURL in openPanel.urls {
|
|
|
array.append(fileURL)
|
|
|
-// if let filePath = fileURL.path {
|
|
|
-// if !FileManager.default.isExecutableFile(atPath: filePath) {
|
|
|
-// continue
|
|
|
-// }
|
|
|
-//
|
|
|
-// do {
|
|
|
-// let attrib = try FileManager.default.attributesOfItem(atPath: filePath)
|
|
|
-//// if let fileSize = attrib[FileAttributeKey.size] as? NSNumber {
|
|
|
-//// self.allFileSize += fileSize.floatValue
|
|
|
-//// }
|
|
|
-////
|
|
|
-//// if !IAPProductsManager.defaultManager.isAvailableAllFunction {
|
|
|
-//// if self.allFileSize > (20 * 1024 * 1024) || self.files.count >= 2 {
|
|
|
-//// let vc = KMToolCompareWindowController.toolCompare(withType: .pageEdit, setSelectIndex: 1)
|
|
|
-//// vc?.showWindow(nil)
|
|
|
-//// self.allFileSize -= fileSize.floatValue
|
|
|
-//// self.addFiles(array)
|
|
|
-//// return
|
|
|
-//// }
|
|
|
-//// }
|
|
|
-// array.append(fileURL)
|
|
|
-// } catch {
|
|
|
-// print("Error getting file attributes: \(error)")
|
|
|
-// }
|
|
|
-// }
|
|
|
}
|
|
|
+
|
|
|
+ var size = 0.0
|
|
|
+ var files = self.mergeView.files
|
|
|
+ let file = KMFileAttribute()
|
|
|
+ file.filePath = openPanel.urls.first!.path
|
|
|
+ files.append(file)
|
|
|
+
|
|
|
+ for file in files {
|
|
|
+ size = size + file.fileSize
|
|
|
+ }
|
|
|
+
|
|
|
+ if !IAPProductsManager.default().isAvailableAllFunction() && (files.count >= 2 || size > 20 * 1024 * 1024) {
|
|
|
+ KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
self.mergeView.addFilePaths(urls: array)
|
|
|
}
|
|
|
}
|
|
@@ -155,7 +143,7 @@ extension KMMergeWindowController {
|
|
|
size = size + file.fileSize
|
|
|
}
|
|
|
|
|
|
- if !IAPProductsManager.default().isAvailableAllFunction() && (files.count > 2 || size > 20 * 1024 * 1024) {
|
|
|
+ if !IAPProductsManager.default().isAvailableAllFunction() && (files.count >= 2 || size > 20 * 1024 * 1024) {
|
|
|
KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
return
|
|
|
}
|