|
@@ -6,6 +6,7 @@
|
|
|
//
|
|
|
|
|
|
import Cocoa
|
|
|
+import KMComponentLibrary
|
|
|
|
|
|
class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoadable {
|
|
|
|
|
@@ -39,7 +40,7 @@ class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoada
|
|
|
guard let model = model else { return }
|
|
|
|
|
|
for button in self.buttonConetntView.subviews {
|
|
|
- (button as? NSButton)?.state = .off // 重置所有按钮状态为 .off
|
|
|
+ (button as? ComponentCheckBox)?.properties.checkboxType = .normal // 重置所有按钮状态
|
|
|
}
|
|
|
|
|
|
// 定义选项与按钮标签的映射关系
|
|
@@ -69,8 +70,9 @@ class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoada
|
|
|
// 更新按钮状态
|
|
|
if let options = optionsMap[model.type] {
|
|
|
for (tag, isSelected) in options where isSelected as? Bool == true {
|
|
|
- if let button = self.buttonConetntView.viewWithTag(tag) as? NSButton {
|
|
|
- button.state = .on
|
|
|
+ if let button = self.buttonConetntView.viewWithTag(tag) as? ComponentCheckBox {
|
|
|
+ button.properties.checkboxType = .selected
|
|
|
+ button.reloadData()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -83,25 +85,39 @@ class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoada
|
|
|
let array = model.content as? Array<String>
|
|
|
if array?.count != 0 {
|
|
|
for (index, string) in array!.enumerated() {
|
|
|
- let radioButton = NSButton(checkboxWithTitle: KMLocalizedString(string, comment: ""), target: self, action: #selector(buttonAction))
|
|
|
- radioButton.frame = CGRectMake(16,
|
|
|
- self.buttonConetntView.bounds.height - (CGFloat(index * (12 + 16)) + 12) - 16,
|
|
|
- self.bounds.width,
|
|
|
- 16)
|
|
|
- radioButton.tag = index
|
|
|
- radioButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
- self.buttonConetntView.addSubview(radioButton)
|
|
|
+ let button = ComponentCheckBox()
|
|
|
+ button.properties = ComponentCheckBoxProperty(size: .s,
|
|
|
+ state: .normal,
|
|
|
+ isDisabled: false,
|
|
|
+ showhelp: false,
|
|
|
+ text: KMLocalizedString(string, comment: ""),
|
|
|
+ checkboxType: .normal)
|
|
|
+ button.setTarget(self, action: #selector(buttonAction(_:)))
|
|
|
+ button.viewTag = index
|
|
|
+ button.frame = CGRectMake(0,
|
|
|
+ self.buttonConetntView.bounds.height - CGFloat(index * 32) - 32,
|
|
|
+ self.bounds.width,
|
|
|
+ 32)
|
|
|
+ self.buttonConetntView.addSubview(button)
|
|
|
+// let radioButton = NSButton(checkboxWithTitle: KMLocalizedString(string, comment: ""), target: self, action: #selector(buttonAction))
|
|
|
+// radioButton.frame = CGRectMake(16,
|
|
|
+// self.buttonConetntView.bounds.height - (CGFloat(index * (12 + 16)) + 12) - 16,
|
|
|
+// self.bounds.width,
|
|
|
+// 16)
|
|
|
+// radioButton.tag = index
|
|
|
+// radioButton.translatesAutoresizingMaskIntoConstraints = false
|
|
|
+// self.buttonConetntView.addSubview(radioButton)
|
|
|
}
|
|
|
}
|
|
|
self.reloadData()
|
|
|
}
|
|
|
|
|
|
- @objc func buttonAction(sender: NSButton) {
|
|
|
+ @objc func buttonAction(_ sender: ComponentCheckBox) {
|
|
|
guard let data = data else { return }
|
|
|
guard let model = model else { return }
|
|
|
|
|
|
if model.type == .discardObject {
|
|
|
- switch sender.tag {
|
|
|
+ switch sender.viewTag {
|
|
|
case 0: toggleOption(.formAndAction, in: &data.objectOptions)
|
|
|
case 1: toggleOption(.javaScript, in: &data.objectOptions)
|
|
|
case 2: toggleOption(.thumbnails, in: &data.objectOptions)
|
|
@@ -111,7 +127,7 @@ class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoada
|
|
|
}
|
|
|
}
|
|
|
if model.type == .discardUserData {
|
|
|
- switch sender.tag {
|
|
|
+ switch sender.viewTag {
|
|
|
case 0: toggleOption(.commentsFormAndMultimedia, in: &data.userDataOptions)
|
|
|
case 1: toggleOption(.documentInfomationAndMetadata, in: &data.userDataOptions)
|
|
|
case 2: toggleOption(.allObject, in: &data.userDataOptions)
|
|
@@ -122,7 +138,7 @@ class KMCompressDiscardPanelTableCellView: KMBaseCompressTableCellView, NibLoada
|
|
|
}
|
|
|
|
|
|
if model.type == .discardOtherData {
|
|
|
- switch sender.tag {
|
|
|
+ switch sender.viewTag {
|
|
|
case 0: toggleOption(.invalidBookmarks, in: &data.otherDataOptions)
|
|
|
case 1: toggleOption(.invalidLinks, in: &data.otherDataOptions)
|
|
|
case 2: toggleOption(.unrefrencedNamedDestinations, in: &data.otherDataOptions)
|