|
@@ -451,6 +451,15 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
|
|
|
self._itemSetPromptFlag(itemIdentifier: KMToolbarToolSecureItemIdentifier)
|
|
|
}
|
|
|
|
|
|
+ @objc private func _compressAction(sender: NSMenuItem) {
|
|
|
+ if let data = self._currentItemView {
|
|
|
+ self.delegate?.toolbarViewController?(self, menuItemDidClick: data, index: sender.tag, info: nil)
|
|
|
+ } else {
|
|
|
+ self.delegate?.toolbarViewController?(self, menuItemDidClick: self.toolbarItemFindItemIdentifiers(value: KMToolbarToolCompressItemIdentifier), index: sender.tag, info: nil)
|
|
|
+ }
|
|
|
+ self._itemSetPromptFlag(itemIdentifier: KMToolbarToolCompressItemIdentifier)
|
|
|
+ }
|
|
|
+
|
|
|
@objc func measureMenuAction(sender: KMToolbarClickButton) {
|
|
|
self.delegate?.toolbarViewController?(self, clickChaildToolType: .measure, toolbar: sender.clickObject as! KMToolbarItemView)
|
|
|
self._itemSetPromptFlag(item: sender.clickObject as? KMToolbarItemView)
|
|
@@ -2548,11 +2557,17 @@ extension KMToolbarViewController {
|
|
|
item?.image = NSImage(named: "KMImageNameUXIconBatchOptimizeNor")
|
|
|
item?.target = self
|
|
|
item?.btnTag = KMToolbarType.compress.rawValue
|
|
|
- item?.boxImagePosition = .imageLeft
|
|
|
+ item?.boxImagePosition = .imageExpandLeft
|
|
|
item?.toolTip = NSLocalizedString("Reduce file size", comment: "")
|
|
|
item?.titleName = NSLocalizedString("Compress", comment: "")
|
|
|
- item?.btnAction = #selector(compressMenuAction)
|
|
|
- let menuItem = NSMenuItem.init(title: NSLocalizedString("Compress", comment: ""), action: #selector(_menuItemAction), target: self)
|
|
|
+ item?.needExpandAction = true
|
|
|
+// item?.btnAction = #selector(compressMenuAction)
|
|
|
+ let menuItem = NSMenuItem.init(title: NSLocalizedString("Compress", comment: ""), action: nil, target: self)
|
|
|
+ let subMenu = NSMenu()
|
|
|
+ subMenu.addItem(title: NSLocalizedString("压缩当前文件", comment: ""), action: #selector(_compressAction), target: self, tag: 1)
|
|
|
+ subMenu.addItem(title: NSLocalizedString("压缩多个文件", comment: ""), action: #selector(_compressAction), target: self, tag: 2)
|
|
|
+ subMenu.addItem(title: NSLocalizedString("压缩高级优化", comment: ""), action: #selector(_compressAction), target: self, tag: 3)
|
|
|
+ menuItem.submenu = subMenu
|
|
|
item?.menuFormRepresentation = menuItem
|
|
|
menuItem.representedObject = identifier
|
|
|
} else if identifier == KMToolbarToolSecureItemIdentifier {
|