|
@@ -30,6 +30,10 @@ class KMGeneralPreferences: NSViewController {
|
|
|
|
|
|
@IBOutlet weak var openFilesLabelField: NSTextField!
|
|
|
@IBOutlet weak var openFilesMatrix: NSMatrix!
|
|
|
+ @IBOutlet weak var openFileForDefaultButton: NSButtonCell!
|
|
|
+ @IBOutlet weak var openFileForMaximButton: NSButtonCell!
|
|
|
+ @IBOutlet weak var openFileForFitButton: NSButtonCell!
|
|
|
+
|
|
|
@IBOutlet weak var showLeftSideButton: NSButton!
|
|
|
@IBOutlet weak var rememberSnapshotButton: NSButton!
|
|
|
@IBOutlet weak var normalButton: NSButton!
|
|
@@ -40,6 +44,9 @@ class KMGeneralPreferences: NSViewController {
|
|
|
@IBOutlet weak var keepSnapshotOnTopButton: NSButton!
|
|
|
|
|
|
@IBOutlet var savePasswordsMatrix: NSMatrix!
|
|
|
+ @IBOutlet weak var savePwdForAlwaysButton: NSButtonCell!
|
|
|
+ @IBOutlet weak var savePwdForNeverButton: NSButtonCell!
|
|
|
+ @IBOutlet weak var savePwdForAskButton: NSButtonCell!
|
|
|
|
|
|
@IBOutlet var updateIntervalPopUpButton: NSPopUpButton!
|
|
|
@IBOutlet var updateIntervalLabelField: NSTextField!
|
|
@@ -136,10 +143,12 @@ class KMGeneralPreferences: NSViewController {
|
|
|
}
|
|
|
self.autoSaveLbl.stringValue = String(format: "%.0f %@", AutoSaveManager.manager.timeInterval, KMLocalizedString("minute(s)", nil))
|
|
|
|
|
|
+ self._selectOpenFileType(KMPreference.shared.openFileType)
|
|
|
self.showLeftSideButton.state = KMPreference.shared.showLeftSideBar ? .on : .off
|
|
|
self.rememberSnapshotButton.state = KMPreference.shared.rememberSnapshot ? .on : .off
|
|
|
self.autoSaveNotesBackupButton.state = KMPreference.shared.autoSaveNoteBackup ? .on : .off
|
|
|
self.keepSnapshotOnTopButton.state = KMPreference.shared.keepSnapshotWindowToTop ? .on : .off
|
|
|
+ self._selectSavePasswordType(KMPreference.shared.savePasswordType)
|
|
|
|
|
|
self.authorLabel.sizeToFit()
|
|
|
var frame = self.authorTextField.frame
|
|
@@ -165,16 +174,12 @@ class KMGeneralPreferences: NSViewController {
|
|
|
|
|
|
@IBAction func revertPDFViewSettings(_ sender: AnyObject?) {
|
|
|
// [[NSUserDefaultsController sharedUserDefaultsController] revertToInitialValueForKey:SKStringConstants.defaultPDFDisplaySettingsKey];
|
|
|
+ KMPreference.shared.revertInitPDFViewSettingType = .normal
|
|
|
}
|
|
|
|
|
|
@IBAction func revertFullScreenPDFViewSettings(_ sender: AnyObject?) {
|
|
|
// [[NSUserDefaultsController sharedUserDefaultsController] revertToInitialValueForKey:SKStringConstants.defaultFullScreenPDFDisplaySettingsKey];
|
|
|
- }
|
|
|
-
|
|
|
- @IBAction func authorTextFieldAction(_ sender: AnyObject?) {
|
|
|
-// NSString *userName = self.authorTextField.stringValue.length > 0 ? self.authorTextField.stringValue : @"";
|
|
|
-// [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"SKUserName"];
|
|
|
-// [[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
+ KMPreference.shared.revertInitPDFViewSettingType = .fullScreen
|
|
|
}
|
|
|
|
|
|
@IBAction func defaultOpenButtonAction(_ sender: AnyObject?) {
|
|
@@ -182,28 +187,28 @@ class KMGeneralPreferences: NSViewController {
|
|
|
}
|
|
|
|
|
|
@IBAction func openTabButtonAction(_ sender: AnyObject?) {
|
|
|
-// if (@available(macOS 10.12, *)) {
|
|
|
-// NSWindowTabbingMode tabbingMode = NSWindowTabbingModeAutomatic;
|
|
|
-// if (self.openTabButton.indexOfSelectedItem == 0) {
|
|
|
-// #if VERSION_FREE
|
|
|
-// // if (![IAPProductsManager defaultManager].isAvailableAllFunction) {
|
|
|
-// // [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"KMOpenDocumentInTab"];
|
|
|
-// // [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
|
|
|
-// // return;
|
|
|
-// // }
|
|
|
-// #endif
|
|
|
-// tabbingMode = NSWindowTabbingModePreferred;
|
|
|
-// } else if (self.openTabButton.indexOfSelectedItem == 1) {
|
|
|
-// tabbingMode = NSWindowTabbingModeDisallowed;
|
|
|
-// }
|
|
|
-// for (NSDocument *document in [[NSDocumentController sharedDocumentController] documents]) {
|
|
|
-// // if ([document isKindOfClass:[SKMainDocument class]]) {
|
|
|
-// // for (NSWindowController *windowController in document.windowControllers) {
|
|
|
-// // windowController.window.tabbingMode = tabbingMode;
|
|
|
-// // }
|
|
|
-// // }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ var tabbingMode = NSWindow.TabbingMode.automatic
|
|
|
+ if (self.openTabButton.indexOfSelectedItem == 0) {
|
|
|
+#if VERSION_FREE
|
|
|
+ if IAPProductsManager.default().isAvailableAllFunction() == false {
|
|
|
+ // // [[NSUserDefaults standardUserDefaults] setInteger:1 forKey:@"KMOpenDocumentInTab"];
|
|
|
+ KMPreference.shared.openDocumentType = .newWindow
|
|
|
+ KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
|
|
|
+ return
|
|
|
+ }
|
|
|
+#endif
|
|
|
+ tabbingMode = .preferred
|
|
|
+ } else if (self.openTabButton.indexOfSelectedItem == 1) {
|
|
|
+ tabbingMode = .disallowed
|
|
|
+ }
|
|
|
+ for document in NSDocumentController.shared.documents {
|
|
|
+ guard let _doc = document as? KMMainDocument else {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ for windowController in _doc.windowControllers {
|
|
|
+ windowController.window?.tabbingMode = tabbingMode
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@IBAction func showConvertMenuButtonAction(_ sender: AnyObject?) {
|
|
@@ -219,6 +224,18 @@ class KMGeneralPreferences: NSViewController {
|
|
|
KMPreference.shared.openLastUnclosedDocumentWhenAppStart = sender.state == .on
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @IBAction func openFileForDefaultAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.openFileType = .default
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func openFileForMaximAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.openFileType = .maxim
|
|
|
+ }
|
|
|
+ @IBAction func openFileForFitAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.openFileType = .fit
|
|
|
+ }
|
|
|
+
|
|
|
@IBAction func showLeftSideAction(_ sender: Any) {
|
|
|
KMPreference.shared.showLeftSideBar = self.showLeftSideButton.state == .on
|
|
|
}
|
|
@@ -252,7 +269,18 @@ class KMGeneralPreferences: NSViewController {
|
|
|
@objc func autoSaveSliderFinish() {
|
|
|
NotificationCenter.default.post(name: NSNotification.Name(rawValue: KAutoSaveTimeValueChangedNoti), object: nil)
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @IBAction func savePwdForAlwaysAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.savePasswordType = .always
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func savePwdForNeverAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.savePasswordType = .never
|
|
|
+ }
|
|
|
+ @IBAction func savePwdForAskAction(_ sender: Any) {
|
|
|
+ KMPreference.shared.savePasswordType = .ask
|
|
|
+ }
|
|
|
+
|
|
|
/*
|
|
|
#pragma mark Accessors
|
|
|
|
|
@@ -324,6 +352,38 @@ extension KMGeneralPreferences {
|
|
|
self.fullScreenButton.isEnabled = true
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private func _selectOpenFileType(_ type: KMPreferenceOpenFileType) {
|
|
|
+ if type == .default {
|
|
|
+ self.openFileForDefaultButton.state = .on
|
|
|
+ self.openFileForMaximButton.state = .off
|
|
|
+ self.openFileForFitButton.state = .off
|
|
|
+ } else if type == .maxim {
|
|
|
+ self.openFileForDefaultButton.state = .off
|
|
|
+ self.openFileForMaximButton.state = .on
|
|
|
+ self.openFileForFitButton.state = .off
|
|
|
+ } else if type == .fit {
|
|
|
+ self.openFileForDefaultButton.state = .off
|
|
|
+ self.openFileForMaximButton.state = .off
|
|
|
+ self.openFileForFitButton.state = .on
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private func _selectSavePasswordType(_ type: KMPreferenceSavePasswordType) {
|
|
|
+ if type == .always {
|
|
|
+ self.savePwdForAlwaysButton.state = .on
|
|
|
+ self.savePwdForNeverButton.state = .off
|
|
|
+ self.savePwdForAskButton.state = .off
|
|
|
+ } else if type == .never {
|
|
|
+ self.savePwdForAlwaysButton.state = .off
|
|
|
+ self.savePwdForNeverButton.state = .on
|
|
|
+ self.savePwdForAskButton.state = .off
|
|
|
+ } else if type == .ask {
|
|
|
+ self.savePwdForAlwaysButton.state = .off
|
|
|
+ self.savePwdForNeverButton.state = .off
|
|
|
+ self.savePwdForAskButton.state = .on
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
extension KMGeneralPreferences: KMPreferencePane {
|