|
@@ -11,19 +11,8 @@ import KMComponentLibrary
|
|
|
class KMBatchSecurityView: KMBatchSettingItemView {
|
|
|
@IBOutlet weak var titleLabel: NSTextField!
|
|
|
@IBOutlet weak var titleContentView: NSView!
|
|
|
- // @IBOutlet weak var titleLabel: NSTextField!
|
|
|
-// @IBOutlet weak var openPasswordButton: KMImageTitleButton!
|
|
|
-//
|
|
|
-// @IBOutlet weak var openPasswordTextFieldContentView: NSView!
|
|
|
-//// @IBOutlet weak var openPasswordTextField: FocusAwareSecureTextField!
|
|
|
-// @IBOutlet weak var permissionButton: KMImageTitleButton!
|
|
|
-//
|
|
|
-// @IBOutlet weak var permissionTextFieldContentView: NSView!
|
|
|
-//// @IBOutlet weak var permissionTextfield: FocusAwareSecureTextField!
|
|
|
-// @IBOutlet weak var documentPrintButton: KMImageTitleButton!
|
|
|
-// @IBOutlet weak var contentCopyButton: KMImageTitleButton!
|
|
|
-
|
|
|
- @IBOutlet weak var encryptButton: NSButton!
|
|
|
+ @IBOutlet weak var encryptButton: ComponentButton!
|
|
|
+ @IBOutlet weak var securityContentView: KMSecurityContentView!
|
|
|
|
|
|
var data: KMBatchSecurityViewModel = KMBatchSecurityViewModel()
|
|
|
var presenter: KMBatchSecurityViewPresenter = KMBatchSecurityViewPresenter()
|
|
@@ -39,129 +28,61 @@ class KMBatchSecurityView: KMBatchSettingItemView {
|
|
|
|
|
|
self.titleContentView.border(ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider"), 0.5, 0)
|
|
|
|
|
|
- self.presenter.initPresenter(view: self)
|
|
|
-
|
|
|
-// self.openPasswordButton.title = NSLocalizedString("Document Open Password", comment: "")
|
|
|
-// self.openPasswordButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// self.openPasswordButton.action = { [unowned self] (view, button) in
|
|
|
-// self.presenter.openPasswordButtonAction(sender: button)
|
|
|
-// }
|
|
|
-//
|
|
|
-// self.permissionButton.title = NSLocalizedString("Document Permission Password", comment: "")
|
|
|
-// self.permissionButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// self.permissionButton.action = { [unowned self] (view, button) in
|
|
|
-// self.presenter.permissionButtonAction(sender: button)
|
|
|
-// }
|
|
|
-//
|
|
|
-// //
|
|
|
-// self.openPasswordTextFieldContentView.border()
|
|
|
-// self.openPasswordTextFieldContentView.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
|
|
|
-// //
|
|
|
-//// self.openPasswordTextField.placeholderAttributedString = NSAttributedString.init(string: "Open Password", attributes: [NSAttributedString.Key.font: NSFont.SFProTextRegularFont(14), NSAttributedString.Key.foregroundColor: NSColor.km_init(hex: "#94989C")])
|
|
|
-//// self.openPasswordTextField.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-//// self.openPasswordTextField.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
-// //
|
|
|
-// self.permissionTextFieldContentView.border()
|
|
|
-// self.permissionTextFieldContentView.backgroundColor(NSColor.km_init(hex: "#FFFFFF"))
|
|
|
-// //
|
|
|
-//// self.permissionTextfield.placeholderAttributedString = NSAttributedString.init(string: "Permission Password", attributes: [NSAttributedString.Key.font: NSFont.SFProTextRegularFont(14), NSAttributedString.Key.foregroundColor: NSColor.km_init(hex: "#94989C")])
|
|
|
-//// self.permissionTextfield.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-//// self.permissionTextfield.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
-// //
|
|
|
-// self.documentPrintButton.title = NSLocalizedString("Restrict document printing", comment: "")
|
|
|
-// self.documentPrintButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// self.documentPrintButton.action = { [unowned self] (view, button) in
|
|
|
-// self.presenter.documentPrintButtonAction(sender: button)
|
|
|
-// }
|
|
|
-//
|
|
|
-// self.contentCopyButton.title = NSLocalizedString("Restrict content copying", comment: "")
|
|
|
-// self.contentCopyButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// self.contentCopyButton.action = { [unowned self] (view, button) in
|
|
|
-// self.presenter.contentCopyButtonAction(sender: button)
|
|
|
-// }
|
|
|
-
|
|
|
-// self.titleLabel.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-// self.titleLabel.stringValue = NSLocalizedString("Settings", comment: "")
|
|
|
-// self.titleLabel.font = NSFont.SFProTextRegularFont(16.0)
|
|
|
-
|
|
|
- self.encryptButton.wantsLayer = true
|
|
|
- self.encryptButton.layer?.cornerRadius = 4
|
|
|
- self.encryptButton.contentTintColor = NSColor.km_init(hex: "#FFFFFF")
|
|
|
- self.encryptButton.stringValue = NSLocalizedString("Compress", comment: "")
|
|
|
- self.encryptButton.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
- self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
|
|
|
+ self.titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2")
|
|
|
+ self.titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-bold")
|
|
|
|
|
|
-// self.openPasswordButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-// self.openPasswordButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+ self.presenter.initPresenter(view: self)
|
|
|
|
|
|
-// self.permissionButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-// self.permissionButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
-//
|
|
|
-// self.documentPrintButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-// self.documentPrintButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
-//
|
|
|
-// self.contentCopyButton.titleLabel.textColor = NSColor.km_init(hex: "#252629")
|
|
|
-// self.contentCopyButton.titleLabel.font = NSFont.SFProTextRegularFont(14.0)
|
|
|
+ self.encryptButton.properties = ComponentButtonProperty(type: .primary,
|
|
|
+ size: .m,
|
|
|
+ state: .normal,
|
|
|
+ buttonText: KMLocalizedString("Apply"),
|
|
|
+ keepPressState: false)
|
|
|
+ self.encryptButton.setTarget(self, action: #selector(encryptButtonAction(_:)))
|
|
|
+ self.encryptButton.reloadData()
|
|
|
}
|
|
|
|
|
|
override func reloadData() {
|
|
|
-
|
|
|
-// if data.isOpenPassword {
|
|
|
-// self.openPasswordButton.imageName = "btn_checkbox_sel_on"
|
|
|
-//// self.openPasswordTextField.isEnabled = true
|
|
|
-// } else {
|
|
|
-// self.openPasswordButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-//// self.openPasswordTextField.isEnabled = false
|
|
|
-// }
|
|
|
-//
|
|
|
-// if data.isPermission {
|
|
|
-// self.permissionButton.imageName = "btn_checkbox_sel_on"
|
|
|
-//// self.permissionTextfield.isEnabled = true
|
|
|
-// self.documentPrintButton.isEnabled = true
|
|
|
-// self.contentCopyButton.isEnabled = true
|
|
|
-// } else {
|
|
|
-// self.permissionButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-//// self.permissionTextfield.isEnabled = false
|
|
|
-// self.documentPrintButton.isEnabled = false
|
|
|
-// self.contentCopyButton.isEnabled = false
|
|
|
-// }
|
|
|
-//
|
|
|
-// if data.restrictOptions.contains(.print) {
|
|
|
-// self.documentPrintButton.imageName = "btn_checkbox_sel_on"
|
|
|
-// } else {
|
|
|
-// self.documentPrintButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// }
|
|
|
-//
|
|
|
-// if data.restrictOptions.contains(.copy) {
|
|
|
-// self.contentCopyButton.imageName = "btn_checkbox_sel_on"
|
|
|
-// } else {
|
|
|
-// self.contentCopyButton.imageName = "btn_checkbox_unsel_on"
|
|
|
-// }
|
|
|
-
|
|
|
if (self.filesData.count != 0) {
|
|
|
- self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#1770F4").cgColor
|
|
|
- self.encryptButton.isEnabled = true
|
|
|
+ self.encryptButton.properties.isDisabled = false
|
|
|
} else {
|
|
|
- self.encryptButton.layer?.backgroundColor = NSColor.km_init(hex: "#BDDFFD").cgColor
|
|
|
- self.encryptButton.isEnabled = false
|
|
|
+ self.encryptButton.properties.isDisabled = true
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
protocol KMBatchSecurityViewAction { }
|
|
|
extension KMBatchSecurityView: KMBatchCompressViewAction {
|
|
|
- @IBAction func encryptButtonAction(_ sender: NSButton) {
|
|
|
-// guard self.presenter.changePermissionString(self.permissionTextfield.stringValue) else {
|
|
|
-// return
|
|
|
-// }
|
|
|
+ func encryptButtonAction(_ sender: ComponentButton) {
|
|
|
+ self.securityContentView.updatePasswordState()
|
|
|
+
|
|
|
+ self.data.openPasswordString = self.securityContentView.model.openPassword
|
|
|
+ self.data.isOpenPassword = self.securityContentView.model.openPasswordOn
|
|
|
+
|
|
|
+ self.data.permissionString = self.securityContentView.model.ownerPassword
|
|
|
+ self.data.isPermission = self.securityContentView.model.ownerPasswordOn
|
|
|
|
|
|
-// guard self.presenter.changeOpenPasswordString(self.openPasswordTextField.stringValue) else {
|
|
|
-// return
|
|
|
-// }
|
|
|
+ if self.securityContentView.model.printAllowed {
|
|
|
+ self.data.restrictOptions.insert(.print)
|
|
|
+ } else {
|
|
|
+ self.data.restrictOptions.remove(.print)
|
|
|
+ }
|
|
|
+
|
|
|
+ if self.securityContentView.model.editAllowed {
|
|
|
+ self.data.restrictOptions.insert(.copy)
|
|
|
+ } else {
|
|
|
+ self.data.restrictOptions.remove(.copy)
|
|
|
+ }
|
|
|
|
|
|
- if self.batchExport != nil {
|
|
|
- self.batchExport!(self, self.data)
|
|
|
+ if self.data.openPasswordString == self.data.permissionString {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = KMLocalizedString("The Open and Owner passwords cannot be the same. Please change either the Open or the Owner Password.", comment: "")
|
|
|
+ alert.runModal()
|
|
|
+ return
|
|
|
}
|
|
|
+
|
|
|
+ self.batchExport?(self, self.data)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -171,21 +92,3 @@ extension KMBatchSecurityView: KMBatchSecurityViewPresenterDelegate {
|
|
|
self.reloadData()
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-//class FocusAwareSecureTextField: NSSecureTextField {
|
|
|
-// var onFocus: () -> Void = {}
|
|
|
-// var onUnfocus: () -> Void = {}
|
|
|
-//
|
|
|
-// override func becomeFirstResponder() -> Bool {
|
|
|
-// onFocus()
|
|
|
-// let textView = window?.fieldEditor(true, for: nil) as? NSTextView
|
|
|
-// textView?.insertionPointColor = NSColor.km_init(hex: "#252629")
|
|
|
-// return super.becomeFirstResponder()
|
|
|
-// }
|
|
|
-//
|
|
|
-// override func resignFirstResponder() -> Bool {
|
|
|
-// onUnfocus()
|
|
|
-// return super.resignFirstResponder()
|
|
|
-// }
|
|
|
-//}
|