From 3a997b241985f9f1e1ead09d3ec110bfcf64504f Mon Sep 17 00:00:00 2001 From: L1cardo <1014660822@qq.com> Date: Wed, 27 Nov 2019 12:31:27 +0800 Subject: [PATCH 1/9] add history record configuration --- Podfile | 2 +- Podfile.lock | 8 +- uPic.xcodeproj/project.pbxproj | 48 +-- uPic/AppDelegate.swift | 26 +- .../host_icon_6.imageset/Contents.json | 2 +- uPic/Base.lproj/Main.storyboard | 66 ++-- uPic/General/Managers/ConfigManager.swift | 11 +- uPic/General/Utils/PreferenceKey.swift | 21 + .../AdvancedPreferencesViewController.swift | 29 ++ .../Base.lproj/Preferences.storyboard | 359 ++++++++++++++++-- .../en.lproj/Preferences.strings | 39 +- .../zh-Hans.lproj/Preferences.strings | 101 +++-- .../HistoryThumbnailConstant.swift | 13 +- .../HistoryRecord/HistoryThumbnailView.swift | 2 +- uPic/Views/StatusMenuController.swift | 67 ++-- uPic/en.lproj/Localizable.strings | 26 -- uPic/en.lproj/Main.strings | 88 ++--- uPic/zh-Hans.lproj/Localizable.strings | 26 -- uPic/zh-Hans.lproj/Main.strings | 98 ++--- 19 files changed, 688 insertions(+), 344 deletions(-) diff --git a/Podfile b/Podfile index 5631e29..5e81193 100644 --- a/Podfile +++ b/Podfile @@ -8,7 +8,7 @@ target 'uPic' do use_frameworks! pod 'SwiftyJSON' - pod 'Alamofire', '~> 5.0.0-rc.2' + pod 'Alamofire', '~> 5.0.0-rc.3' pod 'MASShortcut' pod 'CryptoSwift', :git => "https://github.com/krzyzanowskim/CryptoSwift", :branch => "master" pod "SwiftyXMLParser", :git => 'https://github.com/yahoojapan/SwiftyXMLParser.git' diff --git a/Podfile.lock b/Podfile.lock index c7845c3..805666c 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,5 +1,5 @@ PODS: - - Alamofire (5.0.0-rc.2) + - Alamofire (5.0.0-rc.3) - CryptoSwift (1.2.0) - Kingfisher (5.9.0): - Kingfisher/Core (= 5.9.0) @@ -11,7 +11,7 @@ PODS: - SwiftyXMLParser (5.1.0) DEPENDENCIES: - - Alamofire (~> 5.0.0-rc.2) + - Alamofire (~> 5.0.0-rc.3) - CryptoSwift (from `https://github.com/krzyzanowskim/CryptoSwift`, branch `master`) - Kingfisher - MASShortcut @@ -45,7 +45,7 @@ CHECKOUT OPTIONS: :git: https://github.com/yahoojapan/SwiftyXMLParser.git SPEC CHECKSUMS: - Alamofire: f9450d3c7f6bea2ad62e7a541c3e9b186c7991d6 + Alamofire: ca8c0de6906873be89d6deec5c8de279e00bf872 CryptoSwift: 40e374e45291d8dceedcb0d6184da94533eaabdf Kingfisher: ff98240aebb7302bdc4f1ecd701761030ce18b16 MASShortcut: d9e4909e878661cc42877cc9d6efbe638273ab57 @@ -54,6 +54,6 @@ SPEC CHECKSUMS: SwiftyJSON: 36413e04c44ee145039d332b4f4e2d3e8d6c4db7 SwiftyXMLParser: 8271497e0a37b5c04b0b167c77b4896e36175a21 -PODFILE CHECKSUM: 3db51175519b196167037cd55cbc3403dd631842 +PODFILE CHECKSUM: 565b96ccb1bd03559a1e77f0afdb53addedee28a COCOAPODS: 1.8.4 diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index 25e6d41..e05429d 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -282,10 +282,10 @@ 68BBB2F5FAEEFFF55935F022 /* AmazonS3Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3Util.swift; sourceTree = ""; }; 68BBB5C4550545707614BE4D /* AmazonS3Uploader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3Uploader.swift; sourceTree = ""; }; 68BBB8CF2838A67CA1AD438F /* AmazonS3HostConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3HostConfig.swift; sourceTree = ""; }; + 96F23538238E2CE800414C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = ""; }; + 96F2353A238E2D1C00414C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = ""; }; + 96F2353C238E2D1D00414C98 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 96F2D369235B424D001F74A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; - 96F2D36C235B42A0001F74A5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = ""; }; - 96F2D370235B4317001F74A5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; - 96F2D372235B456F001F74A5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = ""; }; 96F2D378235B48CF001F74A5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Preferences.strings"; sourceTree = ""; }; A116EF79D38D9092D34EFCF5 /* Pods_uPic.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_uPic.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B31C410193F6C634ECBC8F5F /* Pods-uPic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-uPic.debug.xcconfig"; path = "Target Support Files/Pods-uPic/Pods-uPic.debug.xcconfig"; sourceTree = ""; }; @@ -1048,8 +1048,8 @@ isa = PBXVariantGroup; children = ( 169F073C22AF53DE008E8525 /* Base */, - 96F2D372235B456F001F74A5 /* en */, 96F2D378235B48CF001F74A5 /* zh-Hans */, + 96F23538238E2CE800414C98 /* en */, ); name = Preferences.storyboard; sourceTree = ""; @@ -1066,8 +1066,8 @@ isa = PBXVariantGroup; children = ( 96F2D369235B424D001F74A5 /* Base */, - 96F2D36C235B42A0001F74A5 /* en */, - 96F2D370235B4317001F74A5 /* zh-Hans */, + 96F2353A238E2D1C00414C98 /* en */, + 96F2353C238E2D1D00414C98 /* zh-Hans */, ); name = Main.storyboard; sourceTree = ""; @@ -1200,11 +1200,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1230,11 +1230,11 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1256,10 +1256,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1279,10 +1279,10 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1302,10 +1302,10 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1327,10 +1327,10 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/uPic/AppDelegate.swift b/uPic/AppDelegate.swift index ebd549b..347b27c 100644 --- a/uPic/AppDelegate.swift +++ b/uPic/AppDelegate.swift @@ -52,7 +52,9 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.setupStatusBar() self.bindShortcuts() - + + self.setHistoryRecordConfigurationToDefault() + // 添加 Finder 右键文件上传监听 UploadNotifier.addObserver(observer: self, selector: #selector(uploadFilesFromFinderMenu), notification: .uploadFiles) } @@ -77,6 +79,28 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + // 设定历史记录选项初始值 + func setHistoryRecordConfigurationToDefault() { + if Defaults[.historyRecordWidth] == 0.0 { + Defaults[.historyRecordWidth] = Float(500) + } + if Defaults[.historyRecordColumns] == 0 { + Defaults[.historyRecordColumns] = Int(3) + } + if Defaults[.historyRecordSpacing] == 0.0 { + Defaults[.historyRecordSpacing] = Float(5) + } + if Defaults[.historyRecordPadding] == 0.0 { + Defaults[.historyRecordPadding] = Float(5) + } + if Defaults[.historyRecordFileNameScrollSpeed] == 0.0 { + Defaults[.historyRecordFileNameScrollSpeed] = Double(30) + } + if Defaults[.historyRecordFileNameScrollWaitTime] == 0.0 { + Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) + } + } + // 在 Finder 中选中文件右键上传时调用的方法 @objc func uploadFilesFromFinderMenu(notification: Notification) { diff --git a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json index 166cf96..7893ef1 100644 --- a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json +++ b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "GitHub.png", + "filename" : "github.png", "scale" : "1x" }, { diff --git a/uPic/Base.lproj/Main.storyboard b/uPic/Base.lproj/Main.storyboard index d2d479b..73c61e4 100644 --- a/uPic/Base.lproj/Main.storyboard +++ b/uPic/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -100,62 +100,50 @@ - + - - - - - - - - - - - - - + - + - + - + - + - + - + - + @@ -184,45 +172,45 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -231,9 +219,9 @@ - + - + @@ -241,13 +229,13 @@ - + - + @@ -257,7 +245,7 @@ - + diff --git a/uPic/General/Managers/ConfigManager.swift b/uPic/General/Managers/ConfigManager.swift index d999f58..d7f964b 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -43,7 +43,13 @@ public class ConfigManager { return } Defaults[.launchAtLogin] = BoolType._false.rawValue - Defaults[.compressFactor] = 100 + Defaults[.compressFactor] = Int(100) + Defaults[.historyRecordWidth] = Float(500) + Defaults[.historyRecordColumns] = Int(3) + Defaults[.historyRecordSpacing] = Float(5) + Defaults[.historyRecordPadding] = Float(5) + Defaults[.historyRecordFileNameScrollSpeed] = Double(30) + Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) Defaults.synchronize() self.setHostItems(items: [Host.getDefaultHost()]) @@ -96,7 +102,7 @@ extension ConfigManager { public var historyLimit_New: Int { get { let defaultLimit = 100 - let limit = Defaults[.historyLimit_New] + let limit = Defaults[.historyLimit_New] if (limit == nil || limit == 0) { return defaultLimit } @@ -105,6 +111,7 @@ extension ConfigManager { set { Defaults[.historyLimit_New] = newValue + Defaults.synchronize() } } diff --git a/uPic/General/Utils/PreferenceKey.swift b/uPic/General/Utils/PreferenceKey.swift index ba3c7ac..305abc0 100644 --- a/uPic/General/Utils/PreferenceKey.swift +++ b/uPic/General/Utils/PreferenceKey.swift @@ -19,6 +19,12 @@ struct Keys { static let historyLimit = "uPic_HistoryLimit" static let historyLimit_New = "uPic_HistoryLimit_New" static let compressFactor = "uPic_CompressFactor" + static let historyRecordWidth = "uPic_HistoryRecordWidth" + static let historyRecordColumns = "uPic_HistoryRecordColumns" + static let historyRecordSpacing = "uPic_HistoryRecordSpacing" + static let historyRecordPadding = "uPic_HistoryRecordPadding" + static let historyRecordFileNameScrollSpeed = "uPic_HistoryRecordFileNameScrollSpeed" + static let historyRecordFileNameScrollWaitTime = "uPic_HistoryRecordFileNameScrollWaitTime" } class DefaultsKeys { @@ -49,6 +55,12 @@ extension DefaultsKeys { static let historyList_New = DefaultsKey<[[String: Any]]>(Keys.historyList_New) static let historyLimit_New = DefaultsKey(Keys.historyLimit_New) static let compressFactor = DefaultsKey(Keys.compressFactor) + static let historyRecordWidth = DefaultsKey(Keys.historyRecordWidth) + static let historyRecordColumns = DefaultsKey(Keys.historyRecordColumns) + static let historyRecordSpacing = DefaultsKey(Keys.historyRecordSpacing) + static let historyRecordPadding = DefaultsKey(Keys.historyRecordPadding) + static let historyRecordFileNameScrollSpeed = DefaultsKey(Keys.historyRecordFileNameScrollSpeed) + static let historyRecordFileNameScrollWaitTime = DefaultsKey(Keys.historyRecordFileNameScrollWaitTime) } @@ -73,6 +85,15 @@ extension UserDefaults { } } + subscript(key: DefaultsKey) -> Double? { + get { + return double(forKey: key._key) + } + set { + set(newValue, forKey: key._key) + } + } + subscript(key: DefaultsKey) -> Float? { get { return float(forKey: key._key) diff --git a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index bd1d316..aa67afd 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -15,6 +15,12 @@ class AdvancedPreferencesViewController: PreferencesViewController { @IBOutlet weak var selectFileShortcut: MASShortcutView! @IBOutlet weak var pasteboardShortcut: MASShortcutView! @IBOutlet weak var screenshotShortcut: MASShortcutView! + @IBOutlet weak var historyRecordWidth: NSTextField! + @IBOutlet weak var historyRecordColumns: NSTextField! + @IBOutlet weak var historyRecordSpacing: NSTextField! + @IBOutlet weak var historyRecordPadding: NSTextField! + @IBOutlet weak var historyRecordFileNameScrollSpeed: NSTextField! + @IBOutlet weak var historyRecordFileNameScrollWaitTime: NSTextField! @IBOutlet weak var resetPreferencesButton: NSButton! // MARK: Lifecycle @@ -25,8 +31,31 @@ class AdvancedPreferencesViewController: PreferencesViewController { selectFileShortcut.associatedUserDefaultsKey = Constants.Key.selectFileShortcut pasteboardShortcut.associatedUserDefaultsKey = Constants.Key.pasteboardShortcut screenshotShortcut.associatedUserDefaultsKey = Constants.Key.screenshotShortcut + + setHistoryRecordTextFieldDefaultText() } + + func setHistoryRecordTextFieldDefaultText() { + historyRecordWidth.stringValue = "\(Defaults[.historyRecordWidth]!)" + historyRecordColumns.stringValue = "\(Defaults[.historyRecordColumns]!)" + historyRecordSpacing.stringValue = "\(Defaults[.historyRecordSpacing]!)" + historyRecordPadding.stringValue = "\(Defaults[.historyRecordPadding]!)" + historyRecordFileNameScrollSpeed.stringValue = "\(Defaults[.historyRecordFileNameScrollSpeed]!)" + historyRecordFileNameScrollWaitTime.stringValue = "\(Defaults[.historyRecordFileNameScrollWaitTime]!)" + } + + @IBAction func didClickHistoryRecordConfigurationSaveButton(_ sender: NSButton) { + Defaults[.historyRecordWidth] = Float(historyRecordWidth.stringValue) + Defaults[.historyRecordColumns] = Int(historyRecordColumns.stringValue) + Defaults[.historyRecordSpacing] = Float(historyRecordSpacing.stringValue) + Defaults[.historyRecordPadding] = Float(historyRecordPadding.stringValue) + Defaults[.historyRecordFileNameScrollSpeed] = Double(historyRecordFileNameScrollSpeed.stringValue) + Defaults[.historyRecordFileNameScrollWaitTime] = Float(historyRecordFileNameScrollWaitTime.stringValue) + + ConfigNotifier.postNotification(.changeHistoryList) + } + // MARK: Button Actions @IBAction func resetPreferencesButtonClicked(_ sender: NSButton) { diff --git a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard index 9fabca4..f870bd4 100644 --- a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard +++ b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -62,11 +62,11 @@ - + - + - + - + @@ -244,16 +498,29 @@ - + - - - + + + + + + + + + + + + + + + + @@ -263,6 +530,12 @@ + + + + + + @@ -272,6 +545,12 @@ + + + + + + @@ -283,6 +562,12 @@ + + + + + + @@ -291,18 +576,18 @@ - + - + - + @@ -551,7 +836,7 @@ - + @@ -965,7 +1250,7 @@ Gw - + diff --git a/uPic/PreferencesWindow/en.lproj/Preferences.strings b/uPic/PreferencesWindow/en.lproj/Preferences.strings index f803cb5..fb39a1f 100644 --- a/uPic/PreferencesWindow/en.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/en.lproj/Preferences.strings @@ -23,6 +23,12 @@ /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "8px-ng-UpC"; */ "8px-ng-UpC.title" = "Text Cell"; +/* Class = "NSTextFieldCell"; title = "Spacing:"; ObjectID = "AYG-Uz-MYq"; */ +"AYG-Uz-MYq.title" = "Spacing:"; + +/* Class = "NSTextFieldCell"; title = "File name scroll speed:"; ObjectID = "BBZ-i9-B2g"; */ +"BBZ-i9-B2g.title" = "File name scroll speed:"; + /* Class = "NSButtonCell"; title = "Add Header Field"; ObjectID = "Ckh-A7-mxC"; */ "Ckh-A7-mxC.title" = "Add Header Field"; @@ -62,9 +68,15 @@ /* Class = "NSTextFieldCell"; title = "Open file Selection:"; ObjectID = "Mqt-Fp-Ssl"; */ "Mqt-Fp-Ssl.title" = "Open file Selection:"; +/* Class = "NSTextFieldCell"; title = "Columns:"; ObjectID = "N1b-Cf-tno"; */ +"N1b-Cf-tno.title" = "Columns:"; + /* Class = "NSTextFieldCell"; title = "🐦 Twitter:"; ObjectID = "OKr-1C-5jV"; */ "OKr-1C-5jV.title" = "🐦 Twitter:"; +/* Class = "NSTextFieldCell"; title = "File name scroll wait time:"; ObjectID = "ON0-aF-BNd"; */ +"ON0-aF-BNd.title" = "File name scroll wait time:"; + /* Class = "NSBox"; title = "Header and Body Data"; ObjectID = "OaN-c4-l0X"; */ "OaN-c4-l0X.title" = "Header and Body Data"; @@ -74,14 +86,17 @@ /* Class = "NSButtonCell"; title = "⚠️ Reset"; ObjectID = "TD4-LI-X9U"; */ "TD4-LI-X9U.title" = "⚠️ Reset"; +/* Class = "NSTextFieldCell"; title = "History record"; ObjectID = "UN0-Iq-Cop"; */ +"UN0-Iq-Cop.title" = "History record"; + /* Class = "NSTextFieldCell"; title = "💸 Donate:"; ObjectID = "Vjv-pA-ffP"; */ "Vjv-pA-ffP.title" = "💸 Donate:"; /* Class = "NSTextFieldCell"; title = "✉️ Contact:"; ObjectID = "Vu4-Wz-Agk"; */ "Vu4-Wz-Agk.title" = "✉️ Contact:"; -/* Class = "NSTextFieldCell"; title = "Upload with Screenshot:"; ObjectID = "Xd9-iA-emU"; */ -"Xd9-iA-emU.title" = "Upload with Screenshot:"; +/* Class = "NSTextFieldCell"; title = "Upload from Screenshot:"; ObjectID = "Xd9-iA-emU"; */ +"Xd9-iA-emU.title" = "Upload from Screenshot:"; /* Class = "NSTextFieldCell"; title = "file url:"; ObjectID = "ZK1-y8-8KP"; */ "ZK1-y8-8KP.title" = "file url:"; @@ -89,11 +104,14 @@ /* Class = "NSButtonCell"; title = "Launch uPic at login"; ObjectID = "ZbK-xW-anT"; */ "ZbK-xW-anT.title" = "Launch uPic at login"; -/* Class = "NSTextFieldCell"; placeholderString = "domain: https://"; ObjectID = "b48-7x-KE9"; */ -"b48-7x-KE9.placeholderString" = "domain: https://"; +/* Class = "NSTextFieldCell"; placeholderString = "domain:https://"; ObjectID = "b48-7x-KE9"; */ +"b48-7x-KE9.placeholderString" = "domain:https://"; -/* Class = "NSTextFieldCell"; title = "Upload with Pasteboard:"; ObjectID = "bvy-v3-hhf"; */ -"bvy-v3-hhf.title" = "Upload with Pasteboard:"; +/* Class = "NSTextFieldCell"; title = "Padding:"; ObjectID = "bp8-mz-gke"; */ +"bp8-mz-gke.title" = "Padding:"; + +/* Class = "NSTextFieldCell"; title = "Upload from Pasteboard:"; ObjectID = "bvy-v3-hhf"; */ +"bvy-v3-hhf.title" = "Upload from Pasteboard:"; /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "chO-9j-Fca"; */ "chO-9j-Fca.title" = "Edit"; @@ -116,12 +134,18 @@ /* Class = "NSButtonCell"; title = "@geee1k"; ObjectID = "i90-se-6z8"; */ "i90-se-6z8.title" = "@geee1k"; +/* Class = "NSTextFieldCell"; title = "Width:"; ObjectID = "iRI-j6-BHQ"; */ +"iRI-j6-BHQ.title" = "Width:"; + /* Class = "NSTextFieldCell"; title = "Reset"; ObjectID = "jcs-Ou-OZ2"; */ "jcs-Ou-OZ2.title" = "Reset"; /* Class = "NSButtonCell"; title = "Reset preferences"; ObjectID = "jyI-H7-qN3"; */ "jyI-H7-qN3.title" = "Reset preferences"; +/* Class = "NSButtonCell"; title = "Save"; ObjectID = "k4M-cg-63L"; */ +"k4M-cg-63L.title" = "Save"; + /* Class = "NSViewController"; title = "About"; ObjectID = "k6X-N1-mVu"; */ "k6X-N1-mVu.title" = "About"; @@ -131,9 +155,6 @@ /* Class = "NSTextFieldCell"; title = "uPic"; ObjectID = "mOB-su-ZM1"; */ "mOB-su-ZM1.title" = "uPic"; -/* Class = "NSButtonCell"; title = "Button"; ObjectID = "n0U-xp-8UI"; */ -"n0U-xp-8UI.title" = "Button"; - /* Class = "NSTextFieldCell"; title = "uPic will automatically launch at login."; ObjectID = "ngT-lX-vFA"; */ "ngT-lX-vFA.title" = "uPic will automatically launch at login."; diff --git a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings index d010657..3b5a274 100644 --- a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings @@ -2,52 +2,58 @@ /* Class = "NSButtonCell"; title = "svend.cc"; ObjectID = "0dV-As-mmQ"; */ "0dV-As-mmQ.title" = "svend.cc"; -/* Class = "NSTextFieldCell"; title = "⚠️ 注意这将会重置所有用户偏好设置"; ObjectID = "2Rg-te-FPU"; */ +/* Class = "NSTextFieldCell"; title = "⚠️ Note that this will reset all user preferences"; ObjectID = "2Rg-te-FPU"; */ "2Rg-te-FPU.title" = "⚠️ 注意这将会重置所有用户偏好设置"; -/* Class = "NSButtonCell"; title = "取消"; ObjectID = "4iB-qe-GQY"; */ +/* Class = "NSButtonCell"; title = "Cancel"; ObjectID = "4iB-qe-GQY"; */ "4iB-qe-GQY.title" = "取消"; /* Class = "NSButtonCell"; title = "Paypal"; ObjectID = "59m-hG-lVw"; */ "59m-hG-lVw.title" = "Paypal"; -/* Class = "NSViewController"; title = "图床"; ObjectID = "5Ln-jV-uxk"; */ +/* Class = "NSViewController"; title = "Host"; ObjectID = "5Ln-jV-uxk"; */ "5Ln-jV-uxk.title" = "图床"; -/* Class = "NSWindow"; title = "偏好设置"; ObjectID = "5f3-UK-Rft"; */ +/* Class = "NSWindow"; title = "Preferences"; ObjectID = "5f3-UK-Rft"; */ "5f3-UK-Rft.title" = "偏好设置"; -/* Class = "NSMenuItem"; title = "复制"; ObjectID = "8lH-1K-GR0"; */ +/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "8lH-1K-GR0"; */ "8lH-1K-GR0.title" = "复制"; /* Class = "NSTextFieldCell"; title = "Text Cell"; ObjectID = "8px-ng-UpC"; */ "8px-ng-UpC.title" = "Text Cell"; +/* Class = "NSTextFieldCell"; title = "Spacing:"; ObjectID = "AYG-Uz-MYq"; */ +"AYG-Uz-MYq.title" = "内边距:"; + +/* Class = "NSTextFieldCell"; title = "File name scroll speed:"; ObjectID = "BBZ-i9-B2g"; */ +"BBZ-i9-B2g.title" = "文件名滚动速度:"; + /* Class = "NSButtonCell"; title = "增加 Header 字段"; ObjectID = "Ckh-A7-mxC"; */ "Ckh-A7-mxC.title" = "增加 Header 字段"; -/* Class = "NSButtonCell"; title = "确定"; ObjectID = "Cp0-zp-Dpm"; */ +/* Class = "NSButtonCell"; title = "OK"; ObjectID = "Cp0-zp-Dpm"; */ "Cp0-zp-Dpm.title" = "确定"; -/* Class = "NSTextFieldCell"; placeholderString = "文件夹:uploads/test"; ObjectID = "FDM-4e-Rn3"; */ +/* Class = "NSTextFieldCell"; placeholderString = "folder:uploads/test"; ObjectID = "FDM-4e-Rn3"; */ "FDM-4e-Rn3.placeholderString" = "文件夹:uploads/test"; /* Class = "NSTextFieldCell"; title = "/"; ObjectID = "FO4-fa-ZC2"; */ "FO4-fa-ZC2.title" = "/"; -/* Class = "NSTextFieldCell"; title = "快捷键"; ObjectID = "FpP-Q9-flS"; */ +/* Class = "NSTextFieldCell"; title = "Shortcuts"; ObjectID = "FpP-Q9-flS"; */ "FpP-Q9-flS.title" = "快捷键"; -/* Class = "NSViewController"; title = "一般"; ObjectID = "Gn1-zC-bzB"; */ -"Gn1-zC-bzB.title" = "一般"; +/* Class = "NSViewController"; title = "General"; ObjectID = "Gn1-zC-bzB"; */ +"Gn1-zC-bzB.title" = "通用"; -/* Class = "NSViewController"; title = "高级"; ObjectID = "H3q-JS-Bu4"; */ +/* Class = "NSViewController"; title = "Advanced"; ObjectID = "H3q-JS-Bu4"; */ "H3q-JS-Bu4.title" = "高级"; /* Class = "NSTextFieldCell"; title = "💻 GitHub:"; ObjectID = "How-dP-tcX"; */ "How-dP-tcX.title" = "💻 GitHub:"; -/* Class = "NSTextFieldCell"; placeholderString = "网址后缀"; ObjectID = "IG0-Ld-DT5"; */ +/* Class = "NSTextFieldCell"; placeholderString = "URL suffix"; ObjectID = "IG0-Ld-DT5"; */ "IG0-Ld-DT5.placeholderString" = "网址后缀"; /* Class = "NSButtonCell"; title = "svend.jin@gmail.com"; ObjectID = "IPL-yO-Vkp"; */ @@ -56,73 +62,91 @@ /* Class = "NSTextFieldCell"; title = "0.1.0"; ObjectID = "Jnf-AX-bIr"; */ "Jnf-AX-bIr.title" = "0.1.0"; -/* Class = "NSButtonCell"; title = "确定"; ObjectID = "MYr-0a-uD1"; */ +/* Class = "NSButtonCell"; title = "OK"; ObjectID = "MYr-0a-uD1"; */ "MYr-0a-uD1.title" = "确定"; -/* Class = "NSTextFieldCell"; title = "选择文件上传:"; ObjectID = "Mqt-Fp-Ssl"; */ +/* Class = "NSTextFieldCell"; title = "Open file Selection:"; ObjectID = "Mqt-Fp-Ssl"; */ "Mqt-Fp-Ssl.title" = "选择文件上传:"; -/* Class = "NSTextFieldCell"; title = "🐦 推特:"; ObjectID = "OKr-1C-5jV"; */ +/* Class = "NSTextFieldCell"; title = "Columns:"; ObjectID = "N1b-Cf-tno"; */ +"N1b-Cf-tno.title" = "列数:"; + +/* Class = "NSTextFieldCell"; title = "🐦 Twitter:"; ObjectID = "OKr-1C-5jV"; */ "OKr-1C-5jV.title" = "🐦 推特:"; -/* Class = "NSBox"; title = "Header 和 Body 数据"; ObjectID = "OaN-c4-l0X"; */ +/* Class = "NSTextFieldCell"; title = "File name scroll wait time:"; ObjectID = "ON0-aF-BNd"; */ +"ON0-aF-BNd.title" = "文件名滚动等待时间:"; + +/* Class = "NSBox"; title = "Header and Body Data"; ObjectID = "OaN-c4-l0X"; */ "OaN-c4-l0X.title" = "Header 和 Body 数据"; -/* Class = "NSTextFieldCell"; title = "💡 主页:"; ObjectID = "OjL-Zl-YKD"; */ +/* Class = "NSTextFieldCell"; title = "💡 HomePage:"; ObjectID = "OjL-Zl-YKD"; */ "OjL-Zl-YKD.title" = "💡 主页:"; -/* Class = "NSButtonCell"; title = "⚠️ 撤销"; ObjectID = "TD4-LI-X9U"; */ +/* Class = "NSButtonCell"; title = "⚠️ Reset"; ObjectID = "TD4-LI-X9U"; */ "TD4-LI-X9U.title" = "⚠️ 撤销"; -/* Class = "NSTextFieldCell"; title = "💸 捐赠:"; ObjectID = "Vjv-pA-ffP"; */ +/* Class = "NSTextFieldCell"; title = "History record"; ObjectID = "UN0-Iq-Cop"; */ +"UN0-Iq-Cop.title" = "历史记录"; + +/* Class = "NSTextFieldCell"; title = "💸 Donate:"; ObjectID = "Vjv-pA-ffP"; */ "Vjv-pA-ffP.title" = "💸 捐赠:"; -/* Class = "NSTextFieldCell"; title = "✉️ 联系:"; ObjectID = "Vu4-Wz-Agk"; */ +/* Class = "NSTextFieldCell"; title = "✉️ Contact:"; ObjectID = "Vu4-Wz-Agk"; */ "Vu4-Wz-Agk.title" = "✉️ 联系:"; -/* Class = "NSTextFieldCell"; title = "截图上传"; ObjectID = "Xd9-iA-emU"; */ +/* Class = "NSTextFieldCell"; title = "Upload with Screenshot:"; ObjectID = "Xd9-iA-emU"; */ "Xd9-iA-emU.title" = "截图上传:"; -/* Class = "NSTextFieldCell"; title = "文件网址:"; ObjectID = "ZK1-y8-8KP"; */ +/* Class = "NSTextFieldCell"; title = "file url:"; ObjectID = "ZK1-y8-8KP"; */ "ZK1-y8-8KP.title" = "文件网址:"; -/* Class = "NSButtonCell"; title = "登录时启动 uPic"; ObjectID = "ZbK-xW-anT"; */ +/* Class = "NSButtonCell"; title = "Launch uPic at login"; ObjectID = "ZbK-xW-anT"; */ "ZbK-xW-anT.title" = "登录时启动 uPic"; -/* Class = "NSTextFieldCell"; placeholderString = "访问域名:https://"; ObjectID = "b48-7x-KE9"; */ +/* Class = "NSTextFieldCell"; placeholderString = "domain:https://"; ObjectID = "b48-7x-KE9"; */ "b48-7x-KE9.placeholderString" = "访问域名:https://"; -/* Class = "NSTextFieldCell"; title = "上传剪贴板中的文件:"; ObjectID = "bvy-v3-hhf"; */ +/* Class = "NSTextFieldCell"; title = "Padding:"; ObjectID = "bp8-mz-gke"; */ +"bp8-mz-gke.title" = "外边距:"; + +/* Class = "NSTextFieldCell"; title = "Upload from Pasteboard:"; ObjectID = "bvy-v3-hhf"; */ "bvy-v3-hhf.title" = "上传剪贴板中的文件:"; -/* Class = "NSMenuItem"; title = "编辑"; ObjectID = "chO-9j-Fca"; */ +/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "chO-9j-Fca"; */ "chO-9j-Fca.title" = "编辑"; /* Class = "NSBox"; title = "HostSettings"; ObjectID = "dEW-XT-ogl"; */ "dEW-XT-ogl.title" = "HostSettings"; -/* Class = "NSMenuItem"; title = "更多"; ObjectID = "dZy-kW-0lH"; */ +/* Class = "NSMenuItem"; title = "More"; ObjectID = "dZy-kW-0lH"; */ "dZy-kW-0lH.title" = "更多"; -/* Class = "NSButtonCell"; title = "支付宝"; ObjectID = "eWy-BH-pJy"; */ +/* Class = "NSButtonCell"; title = "Alipay"; ObjectID = "eWy-BH-pJy"; */ "eWy-BH-pJy.title" = "支付宝"; /* Class = "NSButtonCell"; title = "https://github.com/gee1k/uPic"; ObjectID = "f2V-P5-pQI"; */ "f2V-P5-pQI.title" = "https://github.com/gee1k/uPic"; -/* Class = "NSButtonCell"; title = "微信"; ObjectID = "fJL-Ts-QPI"; */ +/* Class = "NSButtonCell"; title = "WeChat"; ObjectID = "fJL-Ts-QPI"; */ "fJL-Ts-QPI.title" = "微信"; /* Class = "NSButtonCell"; title = "@geee1k"; ObjectID = "i90-se-6z8"; */ "i90-se-6z8.title" = "@geee1k"; -/* Class = "NSTextFieldCell"; title = "重置"; ObjectID = "jcs-Ou-OZ2"; */ +/* Class = "NSTextFieldCell"; title = "Width:"; ObjectID = "iRI-j6-BHQ"; */ +"iRI-j6-BHQ.title" = "宽度:"; + +/* Class = "NSTextFieldCell"; title = "Reset"; ObjectID = "jcs-Ou-OZ2"; */ "jcs-Ou-OZ2.title" = "重置"; -/* Class = "NSButtonCell"; title = "重置偏好设置"; ObjectID = "jyI-H7-qN3"; */ +/* Class = "NSButtonCell"; title = "Reset preferences"; ObjectID = "jyI-H7-qN3"; */ "jyI-H7-qN3.title" = "重置偏好设置"; -/* Class = "NSViewController"; title = "关于"; ObjectID = "k6X-N1-mVu"; */ +/* Class = "NSButtonCell"; title = "Save"; ObjectID = "k4M-cg-63L"; */ +"k4M-cg-63L.title" = "保存"; + +/* Class = "NSViewController"; title = "About"; ObjectID = "k6X-N1-mVu"; */ "k6X-N1-mVu.title" = "关于"; /* Class = "NSTextFieldCell"; title = "/"; ObjectID = "kdM-To-7Hl"; */ @@ -131,20 +155,17 @@ /* Class = "NSTextFieldCell"; title = "uPic"; ObjectID = "mOB-su-ZM1"; */ "mOB-su-ZM1.title" = "uPic"; -/* Class = "NSButtonCell"; title = "Button"; ObjectID = "n0U-xp-8UI"; */ -"n0U-xp-8UI.title" = "Button"; - -/* Class = "NSTextFieldCell"; title = "uPic 将在系统登录时自动启动。"; ObjectID = "ngT-lX-vFA"; */ +/* Class = "NSTextFieldCell"; title = "uPic will automatically launch at login."; ObjectID = "ngT-lX-vFA"; */ "ngT-lX-vFA.title" = "uPic 将在系统登录时自动启动。"; -/* Class = "NSButtonCell"; title = "保存"; ObjectID = "nvN-EI-scz"; */ +/* Class = "NSButtonCell"; title = "Save"; ObjectID = "nvN-EI-scz"; */ "nvN-EI-scz.title" = "保存"; -/* Class = "NSButtonCell"; title = "增加 Body 字段"; ObjectID = "osM-Ga-s0H"; */ +/* Class = "NSButtonCell"; title = "Add Body Field"; ObjectID = "osM-Ga-s0H"; */ "osM-Ga-s0H.title" = "增加 Body 字段"; -/* Class = "NSButtonCell"; title = "取消"; ObjectID = "q1H-P0-jix"; */ +/* Class = "NSButtonCell"; title = "Cancel"; ObjectID = "q1H-P0-jix"; */ "q1H-P0-jix.title" = "取消"; -/* Class = "NSTextFieldCell"; title = "示例:"; ObjectID = "t25-le-QEa"; */ +/* Class = "NSTextFieldCell"; title = "eg:"; ObjectID = "t25-le-QEa"; */ "t25-le-QEa.title" = "示例:"; diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift b/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift index 70beeec..d77d159 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift @@ -10,19 +10,19 @@ import Foundation /// 历史记录总宽 var historyRecordViewWidthGlobal: CGFloat { - return 500 + return CGFloat(Defaults[.historyRecordWidth]!) } /// 预览图列数 var previewLineNumberGlobal: Int { - return 3 + return Defaults[.historyRecordColumns]! } /// 预览图间距 var previewLineSpacingGlobal: CGFloat { - return 5 + return CGFloat(Defaults[.historyRecordSpacing]!) } /// 历史记录内边距 var historyRecordLeftRightInsetGlobal: CGFloat { - return 5 + return CGFloat(Defaults[.historyRecordPadding]!) } /// 预览图宽度 var previewWidthGlobal: CGFloat { @@ -35,9 +35,10 @@ var previewDefaulWidthGlobal: CGFloat { /// 文件名滚动时间速度 s 单位 var fileNameScrollAnimationTime: TimeInterval { - return 0.03 + return (1 / Defaults[.historyRecordFileNameScrollSpeed]!) } +/// 下次滚动等待时间 var fileNameScrollingTime: CGFloat { - return 1 + return CGFloat(Defaults[.historyRecordFileNameScrollWaitTime]!) } diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift index f475a48..2180196 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift @@ -74,7 +74,7 @@ class HistoryThumbnailView: NSView { clearHistoryButton = NSButton(image: NSImage(named: "cleanButton")!, target: self, action: #selector(clearHistory)) clearHistoryButton.appearance = NSAppearance(named: NSAppearance.Name.aqua) clearHistoryButton.bezelStyle = .smallSquare - clearHistoryButton.toolTip = "\("Clear upload history".localized) \(ConfigManager.shared.getHistoryList_New().count)" + clearHistoryButton.toolTip = "\("Clear history record".localized) \(ConfigManager.shared.getHistoryList_New().count)" clearHistoryButton.isTransparent = true addSubview(clearHistoryButton) diff --git a/uPic/Views/StatusMenuController.swift b/uPic/Views/StatusMenuController.swift index 1601ff3..61af5f5 100644 --- a/uPic/Views/StatusMenuController.swift +++ b/uPic/Views/StatusMenuController.swift @@ -14,49 +14,17 @@ class StatusMenuController: NSObject, NSMenuDelegate { let previewTypes = ["jpeg", "jpg", "png", "gif", "bmp", "tiff"] @IBOutlet weak var statusMenu: NSMenu! - @IBOutlet weak var historyMenu: NSMenu! - @IBOutlet weak var cancelUploadMenuItem: NSMenuItem! @IBOutlet weak var cancelUploadMenuSeparator: NSMenuItem! - @IBOutlet weak var selectFileMenuItem: NSMenuItem! - @IBOutlet weak var uploadPasteboardMenuItem: NSMenuItem! - @IBOutlet weak var screenshotMenuItem: NSMenuItem! @IBOutlet weak var hostMenuItem: NSMenuItem! @IBOutlet weak var ouputFormatMenuItem: NSMenuItem! @IBOutlet weak var compressFactorMenuItem: NSMenuItem! - @IBOutlet weak var historyMenuItem: NSMenuItem! - @IBOutlet weak var preferenceMenuItem: NSMenuItem! - @IBOutlet weak var helpMenuItem: NSMenuItem! - @IBOutlet weak var checkUpdateMenuItem: NSMenuItem! - @IBOutlet weak var tutorialMenuItem: NSMenuItem! - @IBOutlet weak var importHostsMenuItem: NSMenuItem! - @IBOutlet weak var exportHostsMenuItem: NSMenuItem! - - @IBOutlet weak var sponsorMenuItem: NSMenuItem! - @IBOutlet weak var quitMenuItem: NSMenuItem! override func awakeFromNib() { statusMenu.delegate = self - cancelUploadMenuItem.title = "Cancel upload".localized - selectFileMenuItem.title = "Select File".localized - uploadPasteboardMenuItem.title = "Upload copied file".localized - screenshotMenuItem.title = "Screenshot and upload".localized - hostMenuItem.title = "Hosts".localized - ouputFormatMenuItem.title = "Output format".localized - compressFactorMenuItem.title = "Compress images before uploading".localized - historyMenuItem.title = "Upload history".localized - preferenceMenuItem.title = "Preference".localized - helpMenuItem.title = "Help".localized - checkUpdateMenuItem.title = "Check for updates".localized - tutorialMenuItem.title = "Tutorial".localized - importHostsMenuItem.title = "Import hosts".localized - exportHostsMenuItem.title = "Export hosts".localized - sponsorMenuItem.title = "Sponsor".localized - quitMenuItem.title = "Quit".localized - resetHostMenu() resetUploadHistory() refreshOutputFormat() @@ -204,7 +172,7 @@ class StatusMenuController: NSObject, NSMenuDelegate { self.refreshCompressFactor() } - // reset upload history menu list + // reset history record menu list @objc func resetUploadHistory() { historyMenu.cancelTracking() @@ -264,6 +232,37 @@ class StatusMenuController: NSObject, NSMenuDelegate { item.state = .off } } + + var title = "" + switch Defaults[.ouputFormat] { + case 0: + title = "URL" + case 1: + title = "HTML" + case 2: + title = "Markdown" + case 3: + title = "UBB" + default: + title = "" + } + + self.setOutputFormatMenuTitle(factorTitle: title) + } + + func setOutputFormatMenuTitle(factorTitle: String?) { + let outputFormatTitle = "Output format".localized + + if let subTitle = factorTitle { + + let str = "\(outputFormatTitle) \(subTitle)" + let attributed = NSMutableAttributedString(string: str) + let subTitleAttr = [NSAttributedString.Key.font: NSFont.menuFont(ofSize: 12), NSAttributedString.Key.foregroundColor: NSColor.gray] + attributed.setAttributes(subTitleAttr, range: NSRange(outputFormatTitle.utf16.count + 1 ..< str.utf16.count)) + ouputFormatMenuItem.attributedTitle = attributed + } else { + ouputFormatMenuItem.title = outputFormatTitle + } } // refresh compress factor to select @@ -296,7 +295,7 @@ class StatusMenuController: NSObject, NSMenuDelegate { if let subTitle = hostName { - let str = "\(hostMenuTitle) \(subTitle)" + let str = "\(hostMenuTitle) \(subTitle)" let attributed = NSMutableAttributedString(string: str) let subTitleAttr = [NSAttributedString.Key.font: NSFont.menuFont(ofSize: 12), NSAttributedString.Key.foregroundColor: NSColor.gray] attributed.setAttributes(subTitleAttr, range: NSRange(hostMenuTitle.utf16.count + 1 ..< str.utf16.count)) diff --git a/uPic/en.lproj/Localizable.strings b/uPic/en.lproj/Localizable.strings index 61c69e3..92311e2 100644 --- a/uPic/en.lproj/Localizable.strings +++ b/uPic/en.lproj/Localizable.strings @@ -57,38 +57,12 @@ "Did not get the file URL" = "Did not get the file URL"; -/* 状态栏菜单选择文件 */ -"Select File" = "Select File"; -/* 状态栏菜单屏幕截图 */ -"Screenshot and upload" = "Screenshot and upload"; -/* 状态栏菜单上传剪切板中的文件 */ -"Upload copied file" = "Upload copied file"; /* 状态栏菜单图床 */ "Hosts" = "Hosts"; /* 状态栏菜单输出格式 */ "Output format" = "Output format"; /* 状态栏菜单上传前压缩图片 */ "Compress images before uploading" = "Compress images before uploading"; -/* 状态栏菜单偏好设置 */ -"Preference" = "Preference"; -/* 状态栏菜单退出 */ -"Quit" = "Quit"; -/* 菜单栏检查更新按钮标题:检查更新 */ -"Check for updates" = "Check for updates"; -/* 菜单栏上传历史 */ -"Upload history" = "Upload history"; -/* 菜单栏清空上传历史 */ -"Clear upload history" = "Clear upload history"; -/* 菜单栏没有上传历史 */ -"No upload history" = "No upload history"; -/* 菜单栏帮助 */ -"Help" = "Help"; -"Tutorial" = "Tutorial"; -"Import hosts" = "Import hosts"; -"Export hosts" = "Export hosts"; -"Sponsor" = "Sponsor"; -/* cancel upload */ -"Cancel upload" = "Cancel upload"; "Reset User Preferences?" = "Reset User Preferences?"; "⚠️ Note that this will reset all user preferences" = "⚠️ Note that this will reset all user preferences"; diff --git a/uPic/en.lproj/Main.strings b/uPic/en.lproj/Main.strings index ff5998a..fcee065 100644 --- a/uPic/en.lproj/Main.strings +++ b/uPic/en.lproj/Main.strings @@ -1,21 +1,21 @@ -/* Class = "NSMenuItem"; title = "退出"; ObjectID = "0JF-m2-1iq"; */ -"0JF-m2-1iq.title" = "退出"; +/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "0JF-m2-1iq"; */ +"0JF-m2-1iq.title" = "Quit"; -/* Class = "NSMenuItem"; title = "输出格式"; ObjectID = "1BX-LF-q51"; */ -"1BX-LF-q51.title" = "输出格式"; +/* Class = "NSMenuItem"; title = "Output format"; ObjectID = "1BX-LF-q51"; */ +"1BX-LF-q51.title" = "Output format"; /* Class = "NSMenuItem"; title = "uPic"; ObjectID = "1Xt-HY-uBw"; */ "1Xt-HY-uBw.title" = "uPic"; -/* Class = "NSMenuItem"; title = "帮助"; ObjectID = "2Jw-ET-3eH"; */ -"2Jw-ET-3eH.title" = "帮助"; +/* Class = "NSMenuItem"; title = "Help"; ObjectID = "2Jw-ET-3eH"; */ +"2Jw-ET-3eH.title" = "Help"; /* Class = "NSMenuItem"; title = "Quit uPic"; ObjectID = "4sb-4s-VLi"; */ "4sb-4s-VLi.title" = "Quit uPic"; -/* Class = "NSMenu"; title = "上传前压缩图片"; ObjectID = "4yH-6k-LD0"; */ -"4yH-6k-LD0.title" = "上传前压缩图片"; +/* Class = "NSMenu"; title = "Compress images before uploading"; ObjectID = "4yH-6k-LD0"; */ +"4yH-6k-LD0.title" = "Compress images before uploading"; /* Class = "NSMenuItem"; title = "Edit"; ObjectID = "5QF-Oa-p0T"; */ "5QF-Oa-p0T.title" = "Edit"; @@ -35,26 +35,26 @@ /* Class = "NSMenuItem"; title = "Close"; ObjectID = "DVo-aG-piG"; */ "DVo-aG-piG.title" = "Close"; -/* Class = "NSMenuItem"; title = "上传历史"; ObjectID = "EhO-Zw-XXj"; */ -"EhO-Zw-XXj.title" = "上传历史"; +/* Class = "NSMenuItem"; title = "History record"; ObjectID = "EhO-Zw-XXj"; */ +"EhO-Zw-XXj.title" = "History record"; -/* Class = "NSMenuItem"; title = "取消上传"; ObjectID = "Gxh-8r-tsq"; */ -"Gxh-8r-tsq.title" = "取消上传"; +/* Class = "NSMenuItem"; title = "Cancel upload"; ObjectID = "Gxh-8r-tsq"; */ +"Gxh-8r-tsq.title" = "Cancel upload"; -/* Class = "NSMenuItem"; title = "导入图床配置"; ObjectID = "HNM-7K-zzn"; */ -"HNM-7K-zzn.title" = "导入图床配置"; +/* Class = "NSMenuItem"; title = "Import host configuration"; ObjectID = "HNM-7K-zzn"; */ +"HNM-7K-zzn.title" = "Import host configuration"; /* Class = "NSMenuItem"; title = "UBB"; ObjectID = "Hz2-gj-luo"; */ "Hz2-gj-luo.title" = "UBB"; -/* Class = "NSMenu"; title = "图床"; ObjectID = "J3c-l3-LmQ"; */ -"J3c-l3-LmQ.title" = "图床"; +/* Class = "NSMenu"; title = "Host"; ObjectID = "J3c-l3-LmQ"; */ +"J3c-l3-LmQ.title" = "Host"; -/* Class = "NSMenu"; title = "上传历史"; ObjectID = "MjM-mX-Ci5"; */ -"MjM-mX-Ci5.title" = "上传历史"; +/* Class = "NSMenu"; title = "History record"; ObjectID = "MjM-mX-Ci5"; */ +"MjM-mX-Ci5.title" = "History record"; -/* Class = "NSMenuItem"; title = "使用教程"; ObjectID = "O8o-6e-fZn"; */ -"O8o-6e-fZn.title" = "使用教程"; +/* Class = "NSMenuItem"; title = "Tutorial"; ObjectID = "O8o-6e-fZn"; */ +"O8o-6e-fZn.title" = "Tutorial"; /* Class = "NSMenuItem"; title = "Markdown"; ObjectID = "Opc-aA-hUg"; */ "Opc-aA-hUg.title" = "Markdown"; @@ -68,20 +68,20 @@ /* Class = "NSMenuItem"; title = "URL"; ObjectID = "U1c-9i-q5b"; */ "U1c-9i-q5b.title" = "URL"; -/* Class = "NSMenuItem"; title = "偏好设置"; ObjectID = "VW7-Z2-hXR"; */ -"VW7-Z2-hXR.title" = "偏好设置"; +/* Class = "NSMenuItem"; title = "Preferences..."; ObjectID = "VW7-Z2-hXR"; */ +"VW7-Z2-hXR.title" = "Preferences..."; /* Class = "NSMenu"; title = "Edit"; ObjectID = "W48-6f-4Dl"; */ "W48-6f-4Dl.title" = "Edit"; -/* Class = "NSMenu"; title = "输出格式"; ObjectID = "XmF-iN-Y0V"; */ -"XmF-iN-Y0V.title" = "输出格式"; +/* Class = "NSMenu"; title = "Output format"; ObjectID = "XmF-iN-Y0V"; */ +"XmF-iN-Y0V.title" = "Output format"; -/* Class = "NSMenuItem"; title = "导出图床配置"; ObjectID = "Yuc-Vp-9Pd"; */ -"Yuc-Vp-9Pd.title" = "导出图床配置"; +/* Class = "NSMenuItem"; title = "Export host configuration"; ObjectID = "Yuc-Vp-9Pd"; */ +"Yuc-Vp-9Pd.title" = "Export host configuration"; -/* Class = "NSMenu"; title = "帮助"; ObjectID = "Z6H-TN-83r"; */ -"Z6H-TN-83r.title" = "帮助"; +/* Class = "NSMenu"; title = "Help"; ObjectID = "Z6H-TN-83r"; */ +"Z6H-TN-83r.title" = "Help"; /* Class = "NSMenuItem"; title = "Alipay"; ObjectID = "aHw-Zc-eD7"; */ "aHw-Zc-eD7.title" = "Alipay"; @@ -89,8 +89,8 @@ /* Class = "NSMenu"; title = "File"; ObjectID = "bib-Uj-vzu"; */ "bib-Uj-vzu.title" = "File"; -/* Class = "NSMenuItem"; title = "图床"; ObjectID = "d02-bT-1Lv"; */ -"d02-bT-1Lv.title" = "图床"; +/* Class = "NSMenuItem"; title = "Host"; ObjectID = "d02-bT-1Lv"; */ +"d02-bT-1Lv.title" = "Host"; /* Class = "NSMenuItem"; title = "File"; ObjectID = "dMs-cI-mzQ"; */ "dMs-cI-mzQ.title" = "File"; @@ -98,20 +98,20 @@ /* Class = "NSMenuItem"; title = "Undo"; ObjectID = "dRJ-4n-Yzg"; */ "dRJ-4n-Yzg.title" = "Undo"; -/* Class = "NSMenuItem"; title = "上传前压缩图片"; ObjectID = "eIU-EA-uQZ"; */ -"eIU-EA-uQZ.title" = "上传前压缩图片"; +/* Class = "NSMenuItem"; title = "Compress images before uploading"; ObjectID = "eIU-EA-uQZ"; */ +"eIU-EA-uQZ.title" = "Compress images before uploading"; /* Class = "NSMenuItem"; title = "Paste"; ObjectID = "gVA-U4-sdL"; */ "gVA-U4-sdL.title" = "Paste"; -/* Class = "NSMenu"; title = "赞助"; ObjectID = "iGe-NR-YFa"; */ -"iGe-NR-YFa.title" = "赞助"; +/* Class = "NSMenu"; title = "Donate"; ObjectID = "iGe-NR-YFa"; */ +"iGe-NR-YFa.title" = "Donate"; -/* Class = "NSMenuItem"; title = "上传剪切板中的文件"; ObjectID = "orX-KL-q11"; */ -"orX-KL-q11.title" = "上传剪切板中的文件"; +/* Class = "NSMenuItem"; title = "Upload from clipboard"; ObjectID = "orX-KL-q11"; */ +"orX-KL-q11.title" = "Upload from clipboard"; -/* Class = "NSMenuItem"; title = "选择文件"; ObjectID = "p0A-6d-cAU"; */ -"p0A-6d-cAU.title" = "选择文件"; +/* Class = "NSMenuItem"; title = "Select file"; ObjectID = "p0A-6d-cAU"; */ +"p0A-6d-cAU.title" = "Select file"; /* Class = "NSMenuItem"; title = "Delete"; ObjectID = "pa3-QI-u2k"; */ "pa3-QI-u2k.title" = "Delete"; @@ -122,8 +122,8 @@ /* Class = "NSMenuItem"; title = "Cut"; ObjectID = "uRl-iY-unG"; */ "uRl-iY-unG.title" = "Cut"; -/* Class = "NSMenuItem"; title = "截图上传"; ObjectID = "ueU-fm-1nn"; */ -"ueU-fm-1nn.title" = "截图上传"; +/* Class = "NSMenuItem"; title = "Upload from screenshot"; ObjectID = "ueU-fm-1nn"; */ +"ueU-fm-1nn.title" = "Upload from screenshot"; /* Class = "NSMenuItem"; title = "HTML"; ObjectID = "wCN-Y7-fdU"; */ "wCN-Y7-fdU.title" = "HTML"; @@ -131,8 +131,8 @@ /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "x3v-GG-iWU"; */ "x3v-GG-iWU.title" = "Copy"; -/* Class = "NSMenuItem"; title = "赞助"; ObjectID = "yCF-Ec-Lgz"; */ -"yCF-Ec-Lgz.title" = "赞助"; +/* Class = "NSMenuItem"; title = "Donate"; ObjectID = "yCF-Ec-Lgz"; */ +"yCF-Ec-Lgz.title" = "Donate"; -/* Class = "NSMenuItem"; title = "检查更新"; ObjectID = "yai-4F-Btp"; */ -"yai-4F-Btp.title" = "检查更新"; +/* Class = "NSMenuItem"; title = "Check for updates..."; ObjectID = "yai-4F-Btp"; */ +"yai-4F-Btp.title" = "Check for updates..."; diff --git a/uPic/zh-Hans.lproj/Localizable.strings b/uPic/zh-Hans.lproj/Localizable.strings index deda8ee..57d8aa0 100644 --- a/uPic/zh-Hans.lproj/Localizable.strings +++ b/uPic/zh-Hans.lproj/Localizable.strings @@ -57,38 +57,12 @@ "Did not get the file URL" = "没有获取到文件URL"; -/* 状态栏菜单选择文件 */ -"Select File" = "选择文件"; -/* 状态栏菜单屏幕截图 */ -"Screenshot and upload" = "截图上传"; -/* 状态栏菜单上传剪切板中的文件 */ -"Upload copied file" = "上传已拷贝的文件"; /* 状态栏菜单图床 */ "Hosts" = "图床"; /* 状态栏菜单输出格式 */ "Output format" = "输出格式"; /* 状态栏菜单上传前压缩图片 */ "Compress images before uploading" = "上传前压缩图片"; -/* 状态栏菜单偏好设置 */ -"Preference" = "偏好设置"; -/* 状态栏菜单退出 */ -"Quit" = "退出"; -/* 菜单栏检查更新按钮标题:检查更新 */ -"Check for updates" = "检查更新"; -/* 菜单栏上传历史 */ -"Upload history" = "上传历史"; -/* 菜单栏清空上传历史 */ -"Clear upload history" = "清空上传历史"; -/* 菜单栏没有上传历史 */ -"No upload history" = "暂无上传历史"; -/* 菜单栏帮助 */ -"Help" = "帮助"; -"Tutorial" = "使用教程"; -"Import hosts" = "导入图床配置"; -"Export hosts" = "导出图床配置"; -"Sponsor" = "赞助(打赏)"; -/* cancel upload */ -"Cancel upload" = "取消上传"; "Reset User Preferences?" = "重置用户偏好设置?"; "⚠️ Note that this will reset all user preferences" = "⚠️ 注意这将会重置所有用户偏好设置"; diff --git a/uPic/zh-Hans.lproj/Main.strings b/uPic/zh-Hans.lproj/Main.strings index 7c5412e..5254553 100644 --- a/uPic/zh-Hans.lproj/Main.strings +++ b/uPic/zh-Hans.lproj/Main.strings @@ -1,30 +1,30 @@ -/* Class = "NSMenuItem"; title = "退出"; ObjectID = "0JF-m2-1iq"; */ +/* Class = "NSMenuItem"; title = "Quit"; ObjectID = "0JF-m2-1iq"; */ "0JF-m2-1iq.title" = "退出"; -/* Class = "NSMenuItem"; title = "输出格式"; ObjectID = "1BX-LF-q51"; */ +/* Class = "NSMenuItem"; title = "Output format"; ObjectID = "1BX-LF-q51"; */ "1BX-LF-q51.title" = "输出格式"; /* Class = "NSMenuItem"; title = "uPic"; ObjectID = "1Xt-HY-uBw"; */ "1Xt-HY-uBw.title" = "uPic"; -/* Class = "NSMenuItem"; title = "帮助"; ObjectID = "2Jw-ET-3eH"; */ +/* Class = "NSMenuItem"; title = "Help"; ObjectID = "2Jw-ET-3eH"; */ "2Jw-ET-3eH.title" = "帮助"; -/* Class = "NSMenuItem"; title = "退出 uPic"; ObjectID = "4sb-4s-VLi"; */ +/* Class = "NSMenuItem"; title = "Quit uPic"; ObjectID = "4sb-4s-VLi"; */ "4sb-4s-VLi.title" = "退出 uPic"; -/* Class = "NSMenu"; title = "上传前压缩图片"; ObjectID = "4yH-6k-LD0"; */ +/* Class = "NSMenu"; title = "Compress images before uploading"; ObjectID = "4yH-6k-LD0"; */ "4yH-6k-LD0.title" = "上传前压缩图片"; -/* Class = "NSMenuItem"; title = "编辑"; ObjectID = "5QF-Oa-p0T"; */ +/* Class = "NSMenuItem"; title = "Edit"; ObjectID = "5QF-Oa-p0T"; */ "5QF-Oa-p0T.title" = "编辑"; -/* Class = "NSMenuItem"; title = "关于 uPic"; ObjectID = "5kV-Vb-QxS"; */ +/* Class = "NSMenuItem"; title = "About uPic"; ObjectID = "5kV-Vb-QxS"; */ "5kV-Vb-QxS.title" = "关于 uPic"; -/* Class = "NSMenuItem"; title = "撤销"; ObjectID = "6dh-zS-Vam"; */ -"6dh-zS-Vam.title" = "撤销"; +/* Class = "NSMenuItem"; title = "Redo"; ObjectID = "6dh-zS-Vam"; */ +"6dh-zS-Vam.title" = "重做"; /* Class = "NSMenuItem"; title = "Paypal"; ObjectID = "70g-zL-O4p"; */ "70g-zL-O4p.title" = "Paypal"; @@ -32,107 +32,107 @@ /* Class = "NSMenu"; title = "Main Menu"; ObjectID = "AYu-sK-qS6"; */ "AYu-sK-qS6.title" = "Main Menu"; -/* Class = "NSMenuItem"; title = "关闭"; ObjectID = "DVo-aG-piG"; */ +/* Class = "NSMenuItem"; title = "Close"; ObjectID = "DVo-aG-piG"; */ "DVo-aG-piG.title" = "关闭"; -/* Class = "NSMenuItem"; title = "上传历史"; ObjectID = "EhO-Zw-XXj"; */ -"EhO-Zw-XXj.title" = "上传历史"; +/* Class = "NSMenuItem"; title = "History record"; ObjectID = "EhO-Zw-XXj"; */ +"EhO-Zw-XXj.title" = "历史记录"; -/* Class = "NSMenuItem"; title = "取消上传"; ObjectID = "Gxh-8r-tsq"; */ +/* Class = "NSMenuItem"; title = "Cancel upload"; ObjectID = "Gxh-8r-tsq"; */ "Gxh-8r-tsq.title" = "取消上传"; -/* Class = "NSMenuItem"; title = "导入图床配置"; ObjectID = "HNM-7K-zzn"; */ +/* Class = "NSMenuItem"; title = "Import host configuration"; ObjectID = "HNM-7K-zzn"; */ "HNM-7K-zzn.title" = "导入图床配置"; /* Class = "NSMenuItem"; title = "UBB"; ObjectID = "Hz2-gj-luo"; */ "Hz2-gj-luo.title" = "UBB"; -/* Class = "NSMenu"; title = "图床"; ObjectID = "J3c-l3-LmQ"; */ +/* Class = "NSMenu"; title = "Host"; ObjectID = "J3c-l3-LmQ"; */ "J3c-l3-LmQ.title" = "图床"; -/* Class = "NSMenu"; title = "上传历史"; ObjectID = "MjM-mX-Ci5"; */ -"MjM-mX-Ci5.title" = "上传历史"; +/* Class = "NSMenu"; title = "History record"; ObjectID = "MjM-mX-Ci5"; */ +"MjM-mX-Ci5.title" = "历史记录"; -/* Class = "NSMenuItem"; title = "使用教程"; ObjectID = "O8o-6e-fZn"; */ +/* Class = "NSMenuItem"; title = "Tutorial"; ObjectID = "O8o-6e-fZn"; */ "O8o-6e-fZn.title" = "使用教程"; /* Class = "NSMenuItem"; title = "Markdown"; ObjectID = "Opc-aA-hUg"; */ "Opc-aA-hUg.title" = "Markdown"; -/* Class = "NSMenuItem"; title = "微信"; ObjectID = "Qky-3r-Bgs"; */ +/* Class = "NSMenuItem"; title = "WeChat"; ObjectID = "Qky-3r-Bgs"; */ "Qky-3r-Bgs.title" = "微信"; -/* Class = "NSMenuItem"; title = "选择全部"; ObjectID = "Ruw-6m-B2m"; */ -"Ruw-6m-B2m.title" = "选择全部"; +/* Class = "NSMenuItem"; title = "Select All"; ObjectID = "Ruw-6m-B2m"; */ +"Ruw-6m-B2m.title" = "全选"; /* Class = "NSMenuItem"; title = "URL"; ObjectID = "U1c-9i-q5b"; */ "U1c-9i-q5b.title" = "URL"; -/* Class = "NSMenuItem"; title = "偏好设置"; ObjectID = "VW7-Z2-hXR"; */ -"VW7-Z2-hXR.title" = "偏好设置"; +/* Class = "NSMenuItem"; title = "Preferences..."; ObjectID = "VW7-Z2-hXR"; */ +"VW7-Z2-hXR.title" = "偏好设置..."; -/* Class = "NSMenu"; title = "编辑"; ObjectID = "W48-6f-4Dl"; */ +/* Class = "NSMenu"; title = "Edit"; ObjectID = "W48-6f-4Dl"; */ "W48-6f-4Dl.title" = "编辑"; -/* Class = "NSMenu"; title = "输出格式"; ObjectID = "XmF-iN-Y0V"; */ +/* Class = "NSMenu"; title = "Output format"; ObjectID = "XmF-iN-Y0V"; */ "XmF-iN-Y0V.title" = "输出格式"; -/* Class = "NSMenuItem"; title = "导出图床配置"; ObjectID = "Yuc-Vp-9Pd"; */ +/* Class = "NSMenuItem"; title = "Export host configuration"; ObjectID = "Yuc-Vp-9Pd"; */ "Yuc-Vp-9Pd.title" = "导出图床配置"; -/* Class = "NSMenu"; title = "帮助"; ObjectID = "Z6H-TN-83r"; */ +/* Class = "NSMenu"; title = "Help"; ObjectID = "Z6H-TN-83r"; */ "Z6H-TN-83r.title" = "帮助"; -/* Class = "NSMenuItem"; title = "支付宝"; ObjectID = "aHw-Zc-eD7"; */ +/* Class = "NSMenuItem"; title = "Alipay"; ObjectID = "aHw-Zc-eD7"; */ "aHw-Zc-eD7.title" = "支付宝"; -/* Class = "NSMenu"; title = "文件"; ObjectID = "bib-Uj-vzu"; */ +/* Class = "NSMenu"; title = "File"; ObjectID = "bib-Uj-vzu"; */ "bib-Uj-vzu.title" = "文件"; -/* Class = "NSMenuItem"; title = "图床"; ObjectID = "d02-bT-1Lv"; */ +/* Class = "NSMenuItem"; title = "Host"; ObjectID = "d02-bT-1Lv"; */ "d02-bT-1Lv.title" = "图床"; -/* Class = "NSMenuItem"; title = "文件"; ObjectID = "dMs-cI-mzQ"; */ +/* Class = "NSMenuItem"; title = "File"; ObjectID = "dMs-cI-mzQ"; */ "dMs-cI-mzQ.title" = "文件"; -/* Class = "NSMenuItem"; title = "重做"; ObjectID = "dRJ-4n-Yzg"; */ -"dRJ-4n-Yzg.title" = "重做"; +/* Class = "NSMenuItem"; title = "Undo"; ObjectID = "dRJ-4n-Yzg"; */ +"dRJ-4n-Yzg.title" = "撤销"; -/* Class = "NSMenuItem"; title = "上传前压缩图片"; ObjectID = "eIU-EA-uQZ"; */ +/* Class = "NSMenuItem"; title = "Compress images before uploading"; ObjectID = "eIU-EA-uQZ"; */ "eIU-EA-uQZ.title" = "上传前压缩图片"; -/* Class = "NSMenuItem"; title = "粘贴"; ObjectID = "gVA-U4-sdL"; */ +/* Class = "NSMenuItem"; title = "Paste"; ObjectID = "gVA-U4-sdL"; */ "gVA-U4-sdL.title" = "粘贴"; -/* Class = "NSMenu"; title = "赞助"; ObjectID = "iGe-NR-YFa"; */ -"iGe-NR-YFa.title" = "赞助"; +/* Class = "NSMenu"; title = "Donate"; ObjectID = "iGe-NR-YFa"; */ +"iGe-NR-YFa.title" = "捐赠"; -/* Class = "NSMenuItem"; title = "上传剪切板中的文件"; ObjectID = "orX-KL-q11"; */ -"orX-KL-q11.title" = "上传剪切板中的文件"; +/* Class = "NSMenuItem"; title = "Upload from clipboard"; ObjectID = "orX-KL-q11"; */ +"orX-KL-q11.title" = "剪贴板上传"; -/* Class = "NSMenuItem"; title = "选择文件"; ObjectID = "p0A-6d-cAU"; */ +/* Class = "NSMenuItem"; title = "Select file"; ObjectID = "p0A-6d-cAU"; */ "p0A-6d-cAU.title" = "选择文件"; -/* Class = "NSMenuItem"; title = "删除"; ObjectID = "pa3-QI-u2k"; */ +/* Class = "NSMenuItem"; title = "Delete"; ObjectID = "pa3-QI-u2k"; */ "pa3-QI-u2k.title" = "删除"; /* Class = "NSMenu"; title = "uPic"; ObjectID = "uQy-DD-JDr"; */ "uQy-DD-JDr.title" = "uPic"; -/* Class = "NSMenuItem"; title = "剪切"; ObjectID = "uRl-iY-unG"; */ +/* Class = "NSMenuItem"; title = "Cut"; ObjectID = "uRl-iY-unG"; */ "uRl-iY-unG.title" = "剪切"; -/* Class = "NSMenuItem"; title = "截图上传"; ObjectID = "ueU-fm-1nn"; */ +/* Class = "NSMenuItem"; title = "Upload from screenshot"; ObjectID = "ueU-fm-1nn"; */ "ueU-fm-1nn.title" = "截图上传"; /* Class = "NSMenuItem"; title = "HTML"; ObjectID = "wCN-Y7-fdU"; */ "wCN-Y7-fdU.title" = "HTML"; -/* Class = "NSMenuItem"; title = "复制"; ObjectID = "x3v-GG-iWU"; */ -"x3v-GG-iWU.title" = "复制"; +/* Class = "NSMenuItem"; title = "Copy"; ObjectID = "x3v-GG-iWU"; */ +"x3v-GG-iWU.title" = "拷贝"; -/* Class = "NSMenuItem"; title = "赞助"; ObjectID = "yCF-Ec-Lgz"; */ -"yCF-Ec-Lgz.title" = "赞助"; +/* Class = "NSMenuItem"; title = "Donate"; ObjectID = "yCF-Ec-Lgz"; */ +"yCF-Ec-Lgz.title" = "捐赠"; -/* Class = "NSMenuItem"; title = "检查更新"; ObjectID = "yai-4F-Btp"; */ -"yai-4F-Btp.title" = "检查更新"; +/* Class = "NSMenuItem"; title = "Check for updates..."; ObjectID = "yai-4F-Btp"; */ +"yai-4F-Btp.title" = "检查更新..."; From b2a6b210b92c2073f27047fee27f75eb3f262b34 Mon Sep 17 00:00:00 2001 From: nlnlnull Date: Wed, 27 Nov 2019 14:29:04 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uPic/General/Managers/ConfigManager.swift | 2 +- uPic/Notifier/ConfigNotifier.swift | 1 + .../HistoryThumbnailFlowLayout.swift | 359 +++++++++++++++--- .../HistoryRecord/HistoryThumbnailLabel.swift | 6 + .../HistoryRecord/HistoryThumbnailView.swift | 64 +++- uPic/Views/StatusMenuController.swift | 4 +- 6 files changed, 353 insertions(+), 83 deletions(-) diff --git a/uPic/General/Managers/ConfigManager.swift b/uPic/General/Managers/ConfigManager.swift index d999f58..184535e 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -119,7 +119,7 @@ extension ConfigManager { func setHistoryList_New(items: [[String: Any]]) -> Void { Defaults[.historyList_New] = items Defaults.synchronize() - ConfigNotifier.postNotification(.changeHistoryList) + ConfigNotifier.postNotification(.updateHistoryList) } func addHistory_New(url: String, previewModel: HistoryThumbnailModel) -> Void { diff --git a/uPic/Notifier/ConfigNotifier.swift b/uPic/Notifier/ConfigNotifier.swift index 35073cd..14ee225 100644 --- a/uPic/Notifier/ConfigNotifier.swift +++ b/uPic/Notifier/ConfigNotifier.swift @@ -13,6 +13,7 @@ public class ConfigNotifier: Notifier { public enum Notification: String { case changeHostItems case changeHistoryList + case updateHistoryList } } diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailFlowLayout.swift b/uPic/Views/HistoryRecord/HistoryThumbnailFlowLayout.swift index 862d20a..ce6c6eb 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailFlowLayout.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailFlowLayout.swift @@ -8,104 +8,339 @@ import Cocoa -public protocol HistoryThumbnailFlowLayoutDelegate: NSCollectionViewDelegate { +public let CollectionViewWaterfallElementKindSectionHeader = "CollectionViewWaterfallElementKindSectionHeader" +public let CollectionViewWaterfallElementKindSectionFooter = "CollectionViewWaterfallElementKindSectionFooter" + +@objc public protocol HistoryThumbnailFlowLayoutDelegate: NSCollectionViewDelegate { + @objc func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, heightForHeaderInSection section: Int) -> Float + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, heightForFooterInSection section: Int) -> Float + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, insetForSection section: Int) -> NSEdgeInsets + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, insetForHeaderInSection section: Int) -> NSEdgeInsets + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, insetForFooterInSection section: Int) -> NSEdgeInsets + + @objc optional func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, minimumInteritemSpacingForSection section: Int) -> Float - /// return height for item at indexPath - func collectionView(_ collectionView: NSCollectionView, itemWidth: CGFloat, heightForItemAt indexPath: IndexPath) -> CGFloat } -class HistoryThumbnailFlowLayout: NSCollectionViewFlowLayout { - /// 列 - public var columnCount = 3 - /// 列间距 - public var columnSpacing: CGFloat = 0 - /// 行间距 - public var lineSpacing: CGFloat = 0 - public var edgeInset = NSEdgeInsetsZero - - private var contentHeight:CGFloat = 0.0 - private var columnHeights:[CGFloat] = [] - - private var attrsArray:[NSCollectionViewLayoutAttributes] = [] +public class HistoryThumbnailFlowLayout: NSCollectionViewLayout { + + // MARK: - Private constants + /// How many items to be union into a single rectangle + private let unionSize = 20 + + // MARK: - Public Properties + public var columnCount: Int = 2 { + didSet { + invalidateIfNotEqual(oldValue, newValue: columnCount) + } + } + public var minimumColumnSpacing: Float = 10.0 { + didSet { + invalidateIfNotEqual(oldValue, newValue: minimumColumnSpacing) + } + } + public var minimumInteritemSpacing: Float = 10.0 { + didSet { + invalidateIfNotEqual(oldValue, newValue: minimumInteritemSpacing) + } + } + public var headerHeight: Float = 0.0 { + didSet { + invalidateIfNotEqual(oldValue, newValue: headerHeight) + } + } + public var footerHeight: Float = 0.0 { + didSet { + invalidateIfNotEqual(oldValue, newValue: footerHeight) + } + } + public var headerInset: NSEdgeInsets = NSEdgeInsetsZero { + didSet { + invalidateIfNotEqual_NSEdgeInsets(oldValue, newValue: headerInset) + } + } + public var footerInset:NSEdgeInsets = NSEdgeInsetsZero { + didSet { + invalidateIfNotEqual_NSEdgeInsets(oldValue, newValue: footerInset) + } + } + public var sectionInset:NSEdgeInsets = NSEdgeInsetsZero { + didSet { + invalidateIfNotEqual_NSEdgeInsets(oldValue, newValue: sectionInset) + } + } + + public override var collectionViewContentSize: CGSize { + let numberOfSections = collectionView?.numberOfSections + if numberOfSections == 0 { + return CGSize.zero + } + + var contentSize = collectionView?.bounds.size + contentSize?.height = CGFloat(columnHeights[0]) + + return contentSize! + } + + // MARK: - Private Properties + private weak var delegate: HistoryThumbnailFlowLayoutDelegate? { + get { + return collectionView?.delegate as? HistoryThumbnailFlowLayoutDelegate + } + } + private var columnHeights = [Float]() + private var sectionItemAttributes = [[NSCollectionViewLayoutAttributes]]() + private var allItemAttributes = [NSCollectionViewLayoutAttributes]() + private var headersAttribute = [Int: NSCollectionViewLayoutAttributes]() + private var footersAttribute = [Int: NSCollectionViewLayoutAttributes]() + private var unionRects = [CGRect]() - override func prepare() { + // MARK: - NSCollectionViewLayout Methods + public override func prepare() { super.prepare() - contentHeight = 0 - columnHeights.removeAll() - for _ in 0.. 0, "WaterfallFlowLayout's columnCount should be greater than 0") + + // Initialize variables + headersAttribute.removeAll(keepingCapacity: false) + footersAttribute.removeAll(keepingCapacity: false) + unionRects.removeAll(keepingCapacity: false) + columnHeights.removeAll(keepingCapacity: false) + allItemAttributes.removeAll(keepingCapacity: false) + sectionItemAttributes.removeAll(keepingCapacity: false) + + for _ in 0.. 0 { + attributes = NSCollectionViewLayoutAttributes(forSupplementaryViewOfKind: CollectionViewWaterfallElementKindSectionHeader, with: NSIndexPath(forItem: 0, inSection: section) as IndexPath) + attributes.frame = CGRect(x: headerInset.left, y: CGFloat(top), width: collectionView.frame.size.width - (headerInset.left + headerInset.right), height: CGFloat(headerHeight)) + + headersAttribute[section] = attributes + allItemAttributes.append(attributes) + + top = Float(attributes.frame.maxY) + Float(headerInset.bottom) + } + + top += Float(sectionInset.top) + for idx in 0.. 0 && itemSize.width > 0 { + itemHeight = Float(itemSize.height) * itemWidth / Float(itemSize.width) + } + + attributes = NSCollectionViewLayoutAttributes(forItemWith: indexPath as IndexPath) + attributes.frame = CGRect(x: CGFloat(xOffset), y: CGFloat(yOffset), width: CGFloat(itemWidth), height: CGFloat(itemHeight)) + itemAttributes.append(attributes) + allItemAttributes.append(attributes) + columnHeights[columnIndex] = Float(attributes.frame.maxY) + minimumInteritemSpacing + } + + sectionItemAttributes.append(itemAttributes) + + /* + * 4. Section footer + */ + let columnIndex = longestColumnIndex() + top = columnHeights[columnIndex] - minimumInteritemSpacing + Float(sectionInset.bottom) + + let footerHeight: Float = delegate.collectionView?(collectionView, layout: self, heightForFooterInSection: section) ?? self.footerHeight + + let footerInset: NSEdgeInsets = delegate.collectionView?(collectionView, layout: self, insetForFooterInSection: section) ?? self.footerInset + + top += Float(footerInset.top) + + if footerHeight > 0 { + attributes = NSCollectionViewLayoutAttributes(forSupplementaryViewOfKind: CollectionViewWaterfallElementKindSectionFooter, with: NSIndexPath(forItem: 0, inSection: section) as IndexPath) + attributes.frame = CGRect(x: footerInset.left, y: CGFloat(top), width: collectionView.frame.size.width - (footerInset.left + footerInset.right), height: CGFloat(footerHeight)) + + footersAttribute[section] = attributes + allItemAttributes.append(attributes) + + top = Float(attributes.frame.maxY) + Float(footerInset.bottom) } + for idx in 0.. NSCollectionViewLayoutAttributes? { - let attrs = super.layoutAttributesForItem(at: indexPath) + if indexPath.section >= sectionItemAttributes.count { + return nil + } - let collectionViewW = collectionView?.frame.width ?? 0 - let width = (collectionViewW - edgeInset.left - edgeInset.right - (CGFloat(columnCount) - 1) * columnSpacing) / CGFloat(columnCount) + if indexPath.item >= sectionItemAttributes[indexPath.section].count { + return nil + } - let layoutDelegate = collectionView?.delegate as? HistoryThumbnailFlowLayoutDelegate - let height: CGFloat = layoutDelegate?.collectionView(collectionView!, itemWidth: width, heightForItemAt: indexPath) ?? 44 + return sectionItemAttributes[indexPath.section][indexPath.item] + } + + public override func layoutAttributesForSupplementaryView(ofKind elementKind: String, at indexPath: IndexPath) -> NSCollectionViewLayoutAttributes? { + var attribute: NSCollectionViewLayoutAttributes? + if elementKind == CollectionViewWaterfallElementKindSectionHeader { + attribute = headersAttribute[indexPath.section] + } else if elementKind == CollectionViewWaterfallElementKindSectionFooter { + attribute = footersAttribute[indexPath.section] + } - var destColumn = 0 - var minColumnHeight = columnHeights[destColumn] + return attribute + } + + public override func layoutAttributesForElements(in rect: CGRect) -> [NSCollectionViewLayoutAttributes] { + var begin: Int = 0 + var end: Int = unionRects.count + var attrs = [NSCollectionViewLayoutAttributes]() - for index in 1.. columnHeight { - minColumnHeight = columnHeight - destColumn = index + for i in 0.. Bool { + let oldBounds = collectionView?.bounds + if newBounds.width != oldBounds?.width { + return true + } + return false + } +} + + +// MARK: - Private Methods +private extension HistoryThumbnailFlowLayout { + func shortestColumnIndex() -> Int { + var index: Int = 0 + var shortestHeight = MAXFLOAT - columnHeights[destColumn] = attrs?.frame.maxY ?? 0 - let columnHeight = columnHeights[destColumn] - if contentHeight < columnHeight { - contentHeight = columnHeight + for (idx, height) in columnHeights.enumerated() { + if height < shortestHeight { + shortestHeight = height + index = idx + } } - return attrs + return index } - public override func layoutAttributesForElements(in rect: CGRect) -> [NSCollectionViewLayoutAttributes] { - var rectArray:[NSCollectionViewLayoutAttributes] = [] - for cacheAttr in attrsArray { - if cacheAttr.frame.intersects(rect) { - rectArray.append(cacheAttr) + func longestColumnIndex() -> Int { + var index: Int = 0 + var longestHeight:Float = 0 + + for (idx, height) in columnHeights.enumerated() { + if height > longestHeight { + longestHeight = height + index = idx } } - return rectArray + + return index } - public override var collectionViewContentSize: CGSize { - return CGSize(width: collectionView?.bounds.width ?? 0, height: contentHeight + edgeInset.bottom) + func invalidateIfNotEqual(_ oldValue: T, newValue: T) { + if oldValue != newValue { + invalidateLayout() + } } + func invalidateIfNotEqual_NSEdgeInsets(_ oldValue: NSEdgeInsets, newValue: NSEdgeInsets) { + if oldValue.left != newValue.left || oldValue.top != newValue.top || oldValue.right != newValue.right || oldValue.bottom != newValue.bottom { + invalidateLayout() + } + } } diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailLabel.swift b/uPic/Views/HistoryRecord/HistoryThumbnailLabel.swift index d89ff82..6b872de 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailLabel.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailLabel.swift @@ -12,6 +12,12 @@ class HistoryThumbnailLabel: NSView { private(set) var fileName: NSTextField! + var stringValue: String = "" { + didSet { + fileName.stringValue = stringValue + } + } + override init(frame frameRect: NSRect) { super.init(frame: frameRect) diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift index f475a48..375745a 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift @@ -22,6 +22,8 @@ class HistoryThumbnailView: NSView { private var mainCollectionView: NSCollectionView! + private var mainClipView: NSClipView! + private var mainScrollView: NSScrollView! private var clearHistoryButton: NSButton! @@ -34,8 +36,14 @@ class HistoryThumbnailView: NSView { private var currentCell: HistoryThumbnailItem? + private var lastContentOffset: NSPoint = .zero + + private var reductionSlip: Bool = false + var superMenu: NSMenu! + private var menuIsOpen: Bool = false + required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } @@ -44,13 +52,15 @@ class HistoryThumbnailView: NSView { super.init(frame: frameRect) initializeView() addConstraintCustom() + registrationNotice() } private func initializeView() { let flowLayout = HistoryThumbnailFlowLayout() - flowLayout.edgeInset = NSEdgeInsets(top: historyRecordLeftRightInsetGlobal, left: 5, bottom: 50.0, right: historyRecordLeftRightInsetGlobal) flowLayout.columnCount = previewLineNumberGlobal - flowLayout.lineSpacing = previewLineSpacingGlobal + flowLayout.minimumColumnSpacing = Float(previewLineSpacingGlobal) + flowLayout.minimumInteritemSpacing = Float(previewLineSpacingGlobal) + flowLayout.sectionInset = NSEdgeInsets(top: historyRecordLeftRightInsetGlobal, left: 5, bottom: 50.0, right: historyRecordLeftRightInsetGlobal) mainCollectionView = NSCollectionView(frame: bounds) @@ -60,12 +70,12 @@ class HistoryThumbnailView: NSView { mainCollectionView.delegate = self mainCollectionView.dataSource = self - let clipView = NSClipView() - clipView.documentView = mainCollectionView + mainClipView = NSClipView() + mainClipView.documentView = mainCollectionView mainScrollView = NSScrollView(frame: bounds) mainScrollView.backgroundColor = NSColor.clear - mainScrollView.contentView = clipView + mainScrollView.contentView = mainClipView addSubview(mainScrollView) mainScrollView.contentView.postsBoundsChangedNotifications = true let center = NotificationCenter.default @@ -85,7 +95,6 @@ class HistoryThumbnailView: NSView { } private func addConstraintCustom () { - mainScrollView.snp.makeConstraints { (make) in make.edges.equalToSuperview() } @@ -96,11 +105,23 @@ class HistoryThumbnailView: NSView { make.width.height.equalTo(44) } } + + private func registrationNotice() { + ConfigNotifier.addObserver(observer: self, selector: #selector(updateHistoryList), notification: .updateHistoryList) + } + + @objc private func updateHistoryList() { + if menuIsOpen == true { + mainCollectionView.reloadData() + clearHistoryButton.toolTip = "\("Clear upload history".localized) \(ConfigManager.shared.getHistoryList_New().count)" + } + } @objc private func clearHistory() { ConfigManager.shared.clearHistoryList_New() mainCollectionView.reloadData() + lastContentOffset = .zero } // copy history url @@ -112,6 +133,15 @@ class HistoryThumbnailView: NSView { @objc // 滑动 private func boundsDidChangeNotification(notification: NSNotification) { currentCell?.updateTrackingAreas() + guard reductionSlip == false else { + reductionSlip = false + return + } + lastContentOffset = mainScrollView.documentVisibleRect.origin + } + + deinit { + ConfigNotifier.removeObserver(observer: self, notification: .updateHistoryList) } } @@ -173,24 +203,24 @@ extension HistoryThumbnailView: NSCollectionViewDelegate { } } -extension HistoryThumbnailView: NSCollectionViewDelegateFlowLayout { - func collectionView(_ collectionView: NSCollectionView, layout collectionViewLayout: NSCollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> NSSize { - let historyList = ConfigManager.shared.getHistoryList_New() - let model = historyList[indexPath.item] - return model.thumbnailSize - } -} - extension HistoryThumbnailView: HistoryThumbnailFlowLayoutDelegate { - func collectionView(_ collectionView: NSCollectionView, itemWidth: CGFloat, heightForItemAt indexPath: IndexPath) -> CGFloat { + func collectionView(_ collectionView: NSCollectionView, layout: NSCollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { let historyList = ConfigManager.shared.getHistoryList_New() let model = historyList[indexPath.item] - return model.thumbnailHeight + return model.thumbnailSize } } extension HistoryThumbnailView: NSMenuDelegate { func menuWillOpen(_ menu: NSMenu) { -// mainCollectionView.reloadData() + reductionSlip = true + menuIsOpen = true + mainCollectionView.reloadData() + mainClipView.documentView = mainCollectionView + mainClipView.documentView?.scroll(lastContentOffset) + } + + func menuDidClose(_ menu: NSMenu) { + menuIsOpen = false } } diff --git a/uPic/Views/StatusMenuController.swift b/uPic/Views/StatusMenuController.swift index 1601ff3..bf8e66d 100644 --- a/uPic/Views/StatusMenuController.swift +++ b/uPic/Views/StatusMenuController.swift @@ -214,7 +214,7 @@ class StatusMenuController: NSObject, NSMenuDelegate { historyMenu.addItem(imgMenuItem) let previewView = HistoryThumbnailView() - historyMenu.delegate = self + historyMenu.delegate = previewView previewView.superMenu = historyMenu previewView.frame.size = NSSize(width: historyRecordViewWidthGlobal, height: 400) imgMenuItem.view = previewView @@ -325,11 +325,9 @@ class StatusMenuController: NSObject, NSMenuDelegate { func addObserver() { ConfigNotifier.addObserver(observer: self, selector: #selector(resetHostMenu), notification: .changeHostItems) - ConfigNotifier.addObserver(observer: self, selector: #selector(resetUploadHistory), notification: .changeHistoryList) } func removeObserver() { ConfigNotifier.removeObserver(observer: self, notification: .changeHostItems) - ConfigNotifier.removeObserver(observer: self, notification: .changeHistoryList) } } From bbfa85a512d8ef603eff83ab1de488872d26ad47 Mon Sep 17 00:00:00 2001 From: nlnlnull Date: Wed, 27 Nov 2019 15:54:29 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=88=9D=E6=AC=A1?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=97=AA=E9=80=80=E7=9A=84=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uPic.xcodeproj/project.pbxproj | 24 +++--- uPic/AppDelegate.swift | 24 ------ .../host_icon_6.imageset/Contents.json | 2 +- .../NSTextFieldCell+VerticallyCentered.swift | 1 + uPic/General/Managers/ConfigManager.swift | 8 +- uPic/Models/BaseUploader.swift | 2 +- .../AdvancedPreferencesViewController.swift | 14 ++-- .../Base.lproj/Preferences.storyboard | 82 +++++++++++-------- .../HistoryThumbnailConstant.swift | 56 +++++++++---- .../HistoryRecord/HistoryThumbnailItem.swift | 10 +-- .../HistoryRecord/HistoryThumbnailModel.swift | 2 +- .../HistoryRecord/HistoryThumbnailView.swift | 9 +- uPic/Views/StatusMenuController.swift | 4 +- 13 files changed, 124 insertions(+), 114 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index e05429d..59ab57c 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -1201,10 +1201,10 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1231,10 +1231,10 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1257,9 +1257,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1280,9 +1280,9 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1303,9 +1303,9 @@ APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1328,9 +1328,9 @@ APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; CODE_SIGN_IDENTITY = "Apple Development"; - CODE_SIGN_STYLE = Automatic; + CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = EEH44D56FW; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/uPic/AppDelegate.swift b/uPic/AppDelegate.swift index 347b27c..4104586 100644 --- a/uPic/AppDelegate.swift +++ b/uPic/AppDelegate.swift @@ -53,8 +53,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.bindShortcuts() - self.setHistoryRecordConfigurationToDefault() - // 添加 Finder 右键文件上传监听 UploadNotifier.addObserver(observer: self, selector: #selector(uploadFilesFromFinderMenu), notification: .uploadFiles) } @@ -79,28 +77,6 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } - // 设定历史记录选项初始值 - func setHistoryRecordConfigurationToDefault() { - if Defaults[.historyRecordWidth] == 0.0 { - Defaults[.historyRecordWidth] = Float(500) - } - if Defaults[.historyRecordColumns] == 0 { - Defaults[.historyRecordColumns] = Int(3) - } - if Defaults[.historyRecordSpacing] == 0.0 { - Defaults[.historyRecordSpacing] = Float(5) - } - if Defaults[.historyRecordPadding] == 0.0 { - Defaults[.historyRecordPadding] = Float(5) - } - if Defaults[.historyRecordFileNameScrollSpeed] == 0.0 { - Defaults[.historyRecordFileNameScrollSpeed] = Double(30) - } - if Defaults[.historyRecordFileNameScrollWaitTime] == 0.0 { - Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) - } - } - // 在 Finder 中选中文件右键上传时调用的方法 @objc func uploadFilesFromFinderMenu(notification: Notification) { diff --git a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json index 7893ef1..166cf96 100644 --- a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json +++ b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "github.png", + "filename" : "GitHub.png", "scale" : "1x" }, { diff --git a/uPic/Basic/NSTextFieldCell+VerticallyCentered.swift b/uPic/Basic/NSTextFieldCell+VerticallyCentered.swift index f454367..48330fc 100644 --- a/uPic/Basic/NSTextFieldCell+VerticallyCentered.swift +++ b/uPic/Basic/NSTextFieldCell+VerticallyCentered.swift @@ -21,4 +21,5 @@ class VerticallyCenteredTextFieldCell: NSTextFieldCell { } return newRect } + } diff --git a/uPic/General/Managers/ConfigManager.swift b/uPic/General/Managers/ConfigManager.swift index f96ef9b..e969577 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -43,13 +43,7 @@ public class ConfigManager { return } Defaults[.launchAtLogin] = BoolType._false.rawValue - Defaults[.compressFactor] = Int(100) - Defaults[.historyRecordWidth] = Float(500) - Defaults[.historyRecordColumns] = Int(3) - Defaults[.historyRecordSpacing] = Float(5) - Defaults[.historyRecordPadding] = Float(5) - Defaults[.historyRecordFileNameScrollSpeed] = Double(30) - Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) + Defaults[.compressFactor] = 100 Defaults.synchronize() self.setHostItems(items: [Host.getDefaultHost()]) diff --git a/uPic/Models/BaseUploader.swift b/uPic/Models/BaseUploader.swift index 3fa7e13..5cb7a73 100644 --- a/uPic/Models/BaseUploader.swift +++ b/uPic/Models/BaseUploader.swift @@ -49,7 +49,7 @@ class BaseUploader { previewWidth = bigSize * originalScale } - let imageSize = NSSize(width: previewDefaulWidthGlobal, height: previewDefaulWidthGlobal / originalScale) + let imageSize = NSSize(width: PreviewDefaulWidthGlobal, height: PreviewDefaulWidthGlobal / originalScale) thumbnailData = image.resizeImage(size: imageSize).tiffRepresentation isImage = true } diff --git a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index aa67afd..fe22c4c 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -27,7 +27,7 @@ class AdvancedPreferencesViewController: PreferencesViewController { override func viewDidLoad() { super.viewDidLoad() - + selectFileShortcut.associatedUserDefaultsKey = Constants.Key.selectFileShortcut pasteboardShortcut.associatedUserDefaultsKey = Constants.Key.pasteboardShortcut screenshotShortcut.associatedUserDefaultsKey = Constants.Key.screenshotShortcut @@ -36,12 +36,12 @@ class AdvancedPreferencesViewController: PreferencesViewController { } func setHistoryRecordTextFieldDefaultText() { - historyRecordWidth.stringValue = "\(Defaults[.historyRecordWidth]!)" - historyRecordColumns.stringValue = "\(Defaults[.historyRecordColumns]!)" - historyRecordSpacing.stringValue = "\(Defaults[.historyRecordSpacing]!)" - historyRecordPadding.stringValue = "\(Defaults[.historyRecordPadding]!)" - historyRecordFileNameScrollSpeed.stringValue = "\(Defaults[.historyRecordFileNameScrollSpeed]!)" - historyRecordFileNameScrollWaitTime.stringValue = "\(Defaults[.historyRecordFileNameScrollWaitTime]!)" + historyRecordWidth.stringValue = "\(HistoryRecordWidthGlobal)" + historyRecordColumns.stringValue = "\(HistoryRecordColumnsGlobal)" + historyRecordSpacing.stringValue = "\(HistoryRecordSpacingGlobal)" + historyRecordPadding.stringValue = "\(HistoryRecordPaddingGlobal)" + historyRecordFileNameScrollSpeed.stringValue = "\(HistoryRecordFileNameScrollSpeedGlobal)" + historyRecordFileNameScrollWaitTime.stringValue = "\(HistoryRecordFileNameScrollWaitTimeGlobal)" } diff --git a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard index f870bd4..95ba2ff 100644 --- a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard +++ b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -81,7 +81,7 @@ - + @@ -118,15 +118,15 @@ - - + + - + - + @@ -134,7 +134,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -196,7 +196,7 @@ - + @@ -227,7 +227,7 @@ - + @@ -235,10 +235,10 @@ - + - + @@ -249,7 +249,7 @@ - + @@ -260,6 +260,9 @@ + + + @@ -270,7 +273,7 @@ - + @@ -281,7 +284,7 @@ - + @@ -292,6 +295,9 @@ + + + @@ -303,7 +309,7 @@ - + @@ -315,10 +321,10 @@ - + - + @@ -329,7 +335,7 @@ - + @@ -340,6 +346,9 @@ + + + @@ -350,7 +359,7 @@ - + @@ -361,7 +370,7 @@ - + @@ -372,6 +381,9 @@ + + + @@ -383,7 +395,7 @@ - + @@ -395,7 +407,7 @@ - + @@ -406,7 +418,7 @@ - + @@ -418,7 +430,8 @@ - + + @@ -430,7 +443,7 @@ - + @@ -441,7 +454,7 @@ - + @@ -453,7 +466,8 @@ - + + @@ -498,7 +512,7 @@ - + @@ -855,21 +869,21 @@ - + - + - + - + diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift b/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift index d77d159..40e0c89 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift @@ -9,36 +9,58 @@ import Foundation /// 历史记录总宽 -var historyRecordViewWidthGlobal: CGFloat { - return CGFloat(Defaults[.historyRecordWidth]!) +var HistoryRecordWidthGlobal: CGFloat { + guard let width = Defaults[.historyRecordWidth], width > 0 else { + return 500 + } + return CGFloat(width) } /// 预览图列数 -var previewLineNumberGlobal: Int { - return Defaults[.historyRecordColumns]! +var HistoryRecordColumnsGlobal: Int { + guard let columns = Defaults[.historyRecordColumns], columns > 0 else { + return 3 + } + return columns } /// 预览图间距 -var previewLineSpacingGlobal: CGFloat { - return CGFloat(Defaults[.historyRecordSpacing]!) +var HistoryRecordSpacingGlobal: CGFloat { + guard let spacing = Defaults[.historyRecordSpacing], spacing > 0 else { + return 5 + } + return CGFloat(spacing) } /// 历史记录内边距 -var historyRecordLeftRightInsetGlobal: CGFloat { - return CGFloat(Defaults[.historyRecordPadding]!) +var HistoryRecordPaddingGlobal: CGFloat { + guard let inset = Defaults[.historyRecordPadding], inset > 0 else { + return 5 + } + return CGFloat(inset) } /// 预览图宽度 -var previewWidthGlobal: CGFloat { - return (historyRecordViewWidthGlobal - CGFloat((previewLineNumberGlobal - 1)) * previewLineSpacingGlobal - historyRecordLeftRightInsetGlobal * 2) / CGFloat(previewLineNumberGlobal) +var PreviewWidthGlobal: CGFloat { + return (HistoryRecordWidthGlobal - CGFloat((HistoryRecordColumnsGlobal - 1)) * HistoryRecordSpacingGlobal - HistoryRecordPaddingGlobal * 2) / CGFloat(HistoryRecordColumnsGlobal) } /// 预览图默认宽度 -var previewDefaulWidthGlobal: CGFloat { - return 300 +var PreviewDefaulWidthGlobal: CGFloat { + return HistoryRecordWidthGlobal - HistoryRecordPaddingGlobal * 2 } -/// 文件名滚动时间速度 s 单位 -var fileNameScrollAnimationTime: TimeInterval { - return (1 / Defaults[.historyRecordFileNameScrollSpeed]!) +/// 文件名滚动速率百分比 1s 为基数 +var HistoryRecordFileNameScrollSpeedGlobal: TimeInterval { + guard let speed = Defaults[.historyRecordFileNameScrollSpeed], speed > 0 else { + return 30 + } + return speed +} + +var HistoryRecordFileNameScrollSpeed: TimeInterval { + return 1 * (HistoryRecordFileNameScrollSpeedGlobal / 1000) } /// 下次滚动等待时间 -var fileNameScrollingTime: CGFloat { - return CGFloat(Defaults[.historyRecordFileNameScrollWaitTime]!) +var HistoryRecordFileNameScrollWaitTimeGlobal: CGFloat { + guard let time = Defaults[.historyRecordFileNameScrollWaitTime], time > 0 else { + return 1 + } + return CGFloat(time) } diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailItem.swift b/uPic/Views/HistoryRecord/HistoryThumbnailItem.swift index 22231fa..03310ad 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailItem.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailItem.swift @@ -116,7 +116,7 @@ class HistoryThumbnailItem: NSCollectionViewItem { private func beginScrollFileName() { guard fileName.frame.size.width != fileNameView.frame.size.width else { return } var stayTime: CGFloat = 0 - HistoryThumbnailTimer.shared.dispatchScrollTimer(timeInterval: fileNameScrollAnimationTime) { [weak self] timer in + HistoryThumbnailTimer.shared.dispatchScrollTimer(timeInterval: HistoryRecordFileNameScrollSpeed) { [weak self] timer in guard let self = self else { return } let fileNameWidth = self.fileName.frame.size.width let fileNameMinX = self.fileName.frame.origin.x @@ -128,15 +128,15 @@ class HistoryThumbnailItem: NSCollectionViewItem { } let fileNameMaxX = newLeft + fileNameWidth if fileNameMaxX <= self.fileNameView.bounds.width, self.whetherToScrollSequentially == true { - stayTime += CGFloat(fileNameScrollAnimationTime) - if stayTime >= fileNameScrollingTime { + stayTime += CGFloat(HistoryRecordFileNameScrollSpeed) + if stayTime >= HistoryRecordFileNameScrollWaitTimeGlobal { stayTime = 0 self.whetherToScrollSequentially = false } return } else if fileNameMinX >= 0, self.whetherToScrollSequentially == false { - stayTime += CGFloat(fileNameScrollAnimationTime) - if stayTime >= fileNameScrollingTime { + stayTime += CGFloat(HistoryRecordFileNameScrollSpeed) + if stayTime >= HistoryRecordFileNameScrollWaitTimeGlobal { stayTime = 0 self.whetherToScrollSequentially = true } diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailModel.swift b/uPic/Views/HistoryRecord/HistoryThumbnailModel.swift index 1eab415..2a69aeb 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailModel.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailModel.swift @@ -16,7 +16,7 @@ struct HistoryThumbnailModel { return NSSize(width: thumbnailWidth, height: thumbnailHeight) } var thumbnailWidth: CGFloat { - return previewWidthGlobal + return PreviewWidthGlobal } var thumbnailHeight: CGFloat { var height: CGFloat = 0 diff --git a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift index c68b590..f021b4d 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailView.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailView.swift @@ -57,10 +57,10 @@ class HistoryThumbnailView: NSView { private func initializeView() { let flowLayout = HistoryThumbnailFlowLayout() - flowLayout.columnCount = previewLineNumberGlobal - flowLayout.minimumColumnSpacing = Float(previewLineSpacingGlobal) - flowLayout.minimumInteritemSpacing = Float(previewLineSpacingGlobal) - flowLayout.sectionInset = NSEdgeInsets(top: historyRecordLeftRightInsetGlobal, left: 5, bottom: 50.0, right: historyRecordLeftRightInsetGlobal) + flowLayout.columnCount = HistoryRecordColumnsGlobal + flowLayout.minimumColumnSpacing = Float(HistoryRecordSpacingGlobal) + flowLayout.minimumInteritemSpacing = Float(HistoryRecordSpacingGlobal) + flowLayout.sectionInset = NSEdgeInsets(top: 5, left: HistoryRecordPaddingGlobal, bottom: 50.0, right: HistoryRecordPaddingGlobal) mainCollectionView = NSCollectionView(frame: bounds) @@ -218,6 +218,7 @@ extension HistoryThumbnailView: NSMenuDelegate { mainCollectionView.reloadData() mainClipView.documentView = mainCollectionView mainClipView.documentView?.scroll(lastContentOffset) + clearHistoryButton.toolTip = "\("Clear history record".localized) \(ConfigManager.shared.getHistoryList_New().count)" } func menuDidClose(_ menu: NSMenu) { diff --git a/uPic/Views/StatusMenuController.swift b/uPic/Views/StatusMenuController.swift index 0307c89..2b1fe12 100644 --- a/uPic/Views/StatusMenuController.swift +++ b/uPic/Views/StatusMenuController.swift @@ -184,7 +184,7 @@ class StatusMenuController: NSObject, NSMenuDelegate { let previewView = HistoryThumbnailView() historyMenu.delegate = previewView previewView.superMenu = historyMenu - previewView.frame.size = NSSize(width: historyRecordViewWidthGlobal, height: 400) + previewView.frame.size = NSSize(width: HistoryRecordWidthGlobal, height: 400) imgMenuItem.view = previewView } @@ -324,9 +324,11 @@ class StatusMenuController: NSObject, NSMenuDelegate { func addObserver() { ConfigNotifier.addObserver(observer: self, selector: #selector(resetHostMenu), notification: .changeHostItems) + ConfigNotifier.addObserver(observer: self, selector: #selector(resetUploadHistory), notification: .changeHistoryList) } func removeObserver() { ConfigNotifier.removeObserver(observer: self, notification: .changeHostItems) + ConfigNotifier.removeObserver(observer: self, notification: .changeHistoryList) } } From 176cbb60f62e389e2b440b67b2e7eaf692da8c65 Mon Sep 17 00:00:00 2001 From: Svend Date: Wed, 27 Nov 2019 17:00:57 +0800 Subject: [PATCH 4/9] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E5=9C=A8=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E8=AE=BE=E7=BD=AE=E4=B9=8B=E5=90=8E=EF=BC=8C=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=8E=86=E5=8F=B2=E9=85=8D=E7=BD=AE=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=A1=86=E4=B8=8D=E4=BC=9A=E6=9B=B4=E6=96=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修复在重置设置之后,上传历史配置输入框不会更新信息 2.给所有上传历史配置输入框架上 Number Formater 来限制输入格式 --- uPic.xcodeproj/project.pbxproj | 12 ++++---- .../AdvancedPreferencesViewController.swift | 7 +++++ .../Base.lproj/Preferences.storyboard | 28 +++++++++++-------- .../en.lproj/Preferences.strings | 4 +-- .../zh-Hans.lproj/Preferences.strings | 4 +-- 5 files changed, 34 insertions(+), 21 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index 59ab57c..a1e1819 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -1204,7 +1204,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1234,7 +1234,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1259,7 +1259,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1282,7 +1282,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1305,7 +1305,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1330,7 +1330,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = EEH44D56FW; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index fe22c4c..21f502c 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -28,6 +28,10 @@ class AdvancedPreferencesViewController: PreferencesViewController { override func viewDidLoad() { super.viewDidLoad() + resetAllValues() + } + + func resetAllValues() { selectFileShortcut.associatedUserDefaultsKey = Constants.Key.selectFileShortcut pasteboardShortcut.associatedUserDefaultsKey = Constants.Key.pasteboardShortcut screenshotShortcut.associatedUserDefaultsKey = Constants.Key.screenshotShortcut @@ -82,6 +86,9 @@ class AdvancedPreferencesViewController: PreferencesViewController { ConfigManager.shared.firstSetup() _ = NSApplication.shared.delegate as! AppDelegate // appDelegate.setStatusToggle() + + // reset all values + resetAllValues() default: print("Cancel Resetting User Preferences") } diff --git a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard index 95ba2ff..081070d 100644 --- a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard +++ b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -81,7 +81,7 @@ - + @@ -118,9 +118,9 @@ - - - + + + @@ -254,6 +254,7 @@ + @@ -289,6 +290,7 @@ + @@ -340,6 +342,7 @@ + @@ -375,6 +378,7 @@ + @@ -423,6 +427,7 @@ + @@ -459,6 +464,7 @@ + @@ -512,7 +518,7 @@ - + @@ -869,21 +875,21 @@ - + - + - + - + diff --git a/uPic/PreferencesWindow/en.lproj/Preferences.strings b/uPic/PreferencesWindow/en.lproj/Preferences.strings index fb39a1f..eff66c9 100644 --- a/uPic/PreferencesWindow/en.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/en.lproj/Preferences.strings @@ -27,7 +27,7 @@ "AYG-Uz-MYq.title" = "Spacing:"; /* Class = "NSTextFieldCell"; title = "File name scroll speed:"; ObjectID = "BBZ-i9-B2g"; */ -"BBZ-i9-B2g.title" = "File name scroll speed:"; +"BBZ-i9-B2g.title" = "File name scroll speed(ms):"; /* Class = "NSButtonCell"; title = "Add Header Field"; ObjectID = "Ckh-A7-mxC"; */ "Ckh-A7-mxC.title" = "Add Header Field"; @@ -75,7 +75,7 @@ "OKr-1C-5jV.title" = "🐦 Twitter:"; /* Class = "NSTextFieldCell"; title = "File name scroll wait time:"; ObjectID = "ON0-aF-BNd"; */ -"ON0-aF-BNd.title" = "File name scroll wait time:"; +"ON0-aF-BNd.title" = "File name scroll wait time(s):"; /* Class = "NSBox"; title = "Header and Body Data"; ObjectID = "OaN-c4-l0X"; */ "OaN-c4-l0X.title" = "Header and Body Data"; diff --git a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings index 3b5a274..963c126 100644 --- a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings @@ -27,7 +27,7 @@ "AYG-Uz-MYq.title" = "内边距:"; /* Class = "NSTextFieldCell"; title = "File name scroll speed:"; ObjectID = "BBZ-i9-B2g"; */ -"BBZ-i9-B2g.title" = "文件名滚动速度:"; +"BBZ-i9-B2g.title" = "文件名滚动速度(ms):"; /* Class = "NSButtonCell"; title = "增加 Header 字段"; ObjectID = "Ckh-A7-mxC"; */ "Ckh-A7-mxC.title" = "增加 Header 字段"; @@ -75,7 +75,7 @@ "OKr-1C-5jV.title" = "🐦 推特:"; /* Class = "NSTextFieldCell"; title = "File name scroll wait time:"; ObjectID = "ON0-aF-BNd"; */ -"ON0-aF-BNd.title" = "文件名滚动等待时间:"; +"ON0-aF-BNd.title" = "文件名滚动等待时间(s):"; /* Class = "NSBox"; title = "Header and Body Data"; ObjectID = "OaN-c4-l0X"; */ "OaN-c4-l0X.title" = "Header 和 Body 数据"; From c0065777cebf0d9fd7c2521467d38bdff1141d51 Mon Sep 17 00:00:00 2001 From: Svend Date: Wed, 27 Nov 2019 18:48:08 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E7=BD=AE?= =?UTF-8?q?=E5=81=8F=E5=A5=BD=E8=AE=BE=E7=BD=AE=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uPic.xcodeproj/project.pbxproj | 32 +++++++++++------------ uPic/General/Managers/ConfigManager.swift | 25 +++++++++++------- uPic/General/Utils/PreferenceKey.swift | 11 ++++---- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index a1e1819..e67cd38 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -38,6 +38,7 @@ 164745F022B65FE900F9575D /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 164745EF22B65FE900F9575D /* String+Extension.swift */; }; 1647474322B66ACE00F9575D /* Data+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1647474222B66ACE00F9575D /* Data+Extension.swift */; }; 1647474522B66E3400F9575D /* Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1647474422B66E3400F9575D /* Util.swift */; }; + 1648A216238E742600B99B9D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 1648A214238E742600B99B9D /* Main.storyboard */; }; 164C3A0022B2AA6C003ADE39 /* Notifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 164C39FF22B2AA6C003ADE39 /* Notifier.swift */; }; 164C3A0222B2AB22003ADE39 /* ConfigNotifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 164C3A0122B2AB22003ADE39 /* ConfigNotifier.swift */; }; 1657019922C8922400C57EE9 /* WeiboHostConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1657019822C8920400C57EE9 /* WeiboHostConfig.swift */; }; @@ -123,7 +124,6 @@ 68BBB6E5FFBB050D05107413 /* AmazonS3HostConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68BBB8CF2838A67CA1AD438F /* AmazonS3HostConfig.swift */; }; 68BBB99780D7F4586458D4F5 /* AmazonS3Util.swift in Sources */ = {isa = PBXBuildFile; fileRef = 68BBB2F5FAEEFFF55935F022 /* AmazonS3Util.swift */; }; 8E879700A97E9294450D524F /* Pods_uPic.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A116EF79D38D9092D34EFCF5 /* Pods_uPic.framework */; }; - 96F2D368235B424D001F74A5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96F2D36A235B424D001F74A5 /* Main.storyboard */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -190,6 +190,9 @@ 164745EF22B65FE900F9575D /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = ""; }; 1647474222B66ACE00F9575D /* Data+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Data+Extension.swift"; sourceTree = ""; }; 1647474422B66E3400F9575D /* Util.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Util.swift; sourceTree = ""; }; + 1648A215238E742600B99B9D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 1648A217238E742F00B99B9D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = ""; }; + 1648A218238E743200B99B9D /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; 164C39FF22B2AA6C003ADE39 /* Notifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Notifier.swift; sourceTree = ""; }; 164C3A0122B2AB22003ADE39 /* ConfigNotifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigNotifier.swift; sourceTree = ""; }; 1657019822C8920400C57EE9 /* WeiboHostConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WeiboHostConfig.swift; sourceTree = ""; }; @@ -283,9 +286,6 @@ 68BBB5C4550545707614BE4D /* AmazonS3Uploader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3Uploader.swift; sourceTree = ""; }; 68BBB8CF2838A67CA1AD438F /* AmazonS3HostConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3HostConfig.swift; sourceTree = ""; }; 96F23538238E2CE800414C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = ""; }; - 96F2353A238E2D1C00414C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Main.strings; sourceTree = ""; }; - 96F2353C238E2D1D00414C98 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Main.strings"; sourceTree = ""; }; - 96F2D369235B424D001F74A5 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 96F2D378235B48CF001F74A5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Preferences.strings"; sourceTree = ""; }; A116EF79D38D9092D34EFCF5 /* Pods_uPic.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_uPic.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B31C410193F6C634ECBC8F5F /* Pods-uPic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-uPic.debug.xcconfig"; path = "Target Support Files/Pods-uPic/Pods-uPic.debug.xcconfig"; sourceTree = ""; }; @@ -572,7 +572,7 @@ 16A6DC5622AA375700813706 /* uPic */ = { isa = PBXGroup; children = ( - 96F2D36A235B424D001F74A5 /* Main.storyboard */, + 1648A214238E742600B99B9D /* Main.storyboard */, 16BDDE0222EAA2920080E467 /* Assets.xcassets */, 16A6DC5722AA375700813706 /* AppDelegate.swift */, 1623612522AB951E00E4025C /* Localizable.strings */, @@ -819,8 +819,8 @@ buildActionMask = 2147483647; files = ( 1623612322AB951E00E4025C /* Localizable.strings in Resources */, + 1648A216238E742600B99B9D /* Main.storyboard in Resources */, 1623611B22AB935300E4025C /* InfoPlist.strings in Resources */, - 96F2D368235B424D001F74A5 /* Main.storyboard in Resources */, 169F073B22AF53DE008E8525 /* Preferences.storyboard in Resources */, 16BDDE0322EAA2920080E467 /* Assets.xcassets in Resources */, ); @@ -1044,6 +1044,16 @@ name = Localizable.strings; sourceTree = ""; }; + 1648A214238E742600B99B9D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 1648A215238E742600B99B9D /* Base */, + 1648A217238E742F00B99B9D /* en */, + 1648A218238E743200B99B9D /* zh-Hans */, + ); + name = Main.storyboard; + sourceTree = ""; + }; 169F073D22AF53DE008E8525 /* Preferences.storyboard */ = { isa = PBXVariantGroup; children = ( @@ -1062,16 +1072,6 @@ name = Main.storyboard; sourceTree = ""; }; - 96F2D36A235B424D001F74A5 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 96F2D369235B424D001F74A5 /* Base */, - 96F2353A238E2D1C00414C98 /* en */, - 96F2353C238E2D1D00414C98 /* zh-Hans */, - ); - name = Main.storyboard; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/uPic/General/Managers/ConfigManager.swift b/uPic/General/Managers/ConfigManager.swift index e969577..6bd9334 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -50,13 +50,18 @@ public class ConfigManager { } public func removeAllUserDefaults() { - // 提前取出图床配置 - let hostItems = self.getHostItems() - let domain = Bundle.main.bundleIdentifier! - Defaults.removePersistentDomain(forName: domain) - // 清除所有用户设置后,再重新写入图床配置 - self.setHostItems(items: hostItems) + + let ignoreKeys = [Keys.hostItems, Keys.defaultHostId, Keys.historyList] + + let dics = Defaults.dictionaryRepresentation() + for key in dics { + if ignoreKeys.contains(key.key) { + continue + } + Defaults.removeObject(forKey: key.key) + } Defaults.synchronize() + } } @@ -96,7 +101,7 @@ extension ConfigManager { public var historyLimit_New: Int { get { let defaultLimit = 100 - let limit = Defaults[.historyLimit_New] + let limit = Defaults[.historyLimit] if (limit == nil || limit == 0) { return defaultLimit } @@ -104,13 +109,13 @@ extension ConfigManager { } set { - Defaults[.historyLimit_New] = newValue + Defaults[.historyLimit] = newValue Defaults.synchronize() } } func getHistoryList_New() -> [HistoryThumbnailModel] { - let historyList = Defaults[.historyList_New] ?? [[String: Any]]() + let historyList = Defaults[.historyList] ?? [[String: Any]]() let historyListModel: [HistoryThumbnailModel] = historyList.map({ (item) -> HistoryThumbnailModel in return HistoryThumbnailModel.keyValue(keyValue: item) }) @@ -118,7 +123,7 @@ extension ConfigManager { } func setHistoryList_New(items: [[String: Any]]) -> Void { - Defaults[.historyList_New] = items + Defaults[.historyList] = items Defaults.synchronize() ConfigNotifier.postNotification(.updateHistoryList) } diff --git a/uPic/General/Utils/PreferenceKey.swift b/uPic/General/Utils/PreferenceKey.swift index 305abc0..46d9ccb 100644 --- a/uPic/General/Utils/PreferenceKey.swift +++ b/uPic/General/Utils/PreferenceKey.swift @@ -14,11 +14,10 @@ struct Keys { static let hostItems = "uPic_hostItems" static let defaultHostId = "uPic_DefaultHostId" static let ouputFormat = "uPic_OutputFormat" - static let historyList = "uPic_HistoryList" - static let historyList_New = "uPic_HistoryList_New" - static let historyLimit = "uPic_HistoryLimit" - static let historyLimit_New = "uPic_HistoryLimit_New" + static let historyList = "uPic_HistoryList_New" + static let historyLimit = "uPic_HistoryLimit_New" static let compressFactor = "uPic_CompressFactor" + // historyRecord static let historyRecordWidth = "uPic_HistoryRecordWidth" static let historyRecordColumns = "uPic_HistoryRecordColumns" static let historyRecordSpacing = "uPic_HistoryRecordSpacing" @@ -52,8 +51,8 @@ extension DefaultsKeys { static let hostItems = DefaultsKey<[Host]>(Keys.hostItems) static let defaultHostId = DefaultsKey(Keys.defaultHostId) static let ouputFormat = DefaultsKey(Keys.ouputFormat) - static let historyList_New = DefaultsKey<[[String: Any]]>(Keys.historyList_New) - static let historyLimit_New = DefaultsKey(Keys.historyLimit_New) + static let historyList = DefaultsKey<[[String: Any]]>(Keys.historyList) + static let historyLimit = DefaultsKey(Keys.historyLimit) static let compressFactor = DefaultsKey(Keys.compressFactor) static let historyRecordWidth = DefaultsKey(Keys.historyRecordWidth) static let historyRecordColumns = DefaultsKey(Keys.historyRecordColumns) From 6a16aa27c492c8da1628e2298783972755a8be2e Mon Sep 17 00:00:00 2001 From: L1cardo <1014660822@qq.com> Date: Wed, 27 Nov 2019 20:04:28 +0800 Subject: [PATCH 6/9] add history record configuration reset button --- uPic.xcodeproj/project.pbxproj | 16 +-- .../host_icon_6.imageset/Contents.json | 2 +- .../{GitHub.png => github.png} | Bin .../statusIcon.imageset/Contents.json | 4 +- .../{menubar.png => menubar@2x.png.png} | Bin .../{menubar@2x.png => menubar@3x.png} | Bin .../uploadIcon.imageset/Contents.json | 4 +- .../uploadIcon.imageset/wait.png | Bin 635 -> 0 bytes .../uploadIcon.imageset/wait@2x.png | Bin 1247 -> 635 bytes .../uploadIcon.imageset/wait@3x.png | Bin 0 -> 1247 bytes .../AdvancedPreferencesViewController.swift | 13 +- .../Base.lproj/Preferences.storyboard | 120 +++++++++++------- .../en.lproj/Preferences.strings | 7 +- .../zh-Hans.lproj/Preferences.strings | 3 + 14 files changed, 106 insertions(+), 63 deletions(-) rename uPic/Assets.xcassets/host_icon_6.imageset/{GitHub.png => github.png} (100%) rename uPic/Assets.xcassets/statusIcon.imageset/{menubar.png => menubar@2x.png.png} (100%) rename uPic/Assets.xcassets/statusIcon.imageset/{menubar@2x.png => menubar@3x.png} (100%) delete mode 100644 uPic/Assets.xcassets/uploadIcon.imageset/wait.png create mode 100644 uPic/Assets.xcassets/uploadIcon.imageset/wait@3x.png diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index e67cd38..1d111e3 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -285,7 +285,7 @@ 68BBB2F5FAEEFFF55935F022 /* AmazonS3Util.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3Util.swift; sourceTree = ""; }; 68BBB5C4550545707614BE4D /* AmazonS3Uploader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3Uploader.swift; sourceTree = ""; }; 68BBB8CF2838A67CA1AD438F /* AmazonS3HostConfig.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonS3HostConfig.swift; sourceTree = ""; }; - 96F23538238E2CE800414C98 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = ""; }; + 961AA898238E9764005A25C9 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Preferences.strings; sourceTree = ""; }; 96F2D378235B48CF001F74A5 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Preferences.strings"; sourceTree = ""; }; A116EF79D38D9092D34EFCF5 /* Pods_uPic.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_uPic.framework; sourceTree = BUILT_PRODUCTS_DIR; }; B31C410193F6C634ECBC8F5F /* Pods-uPic.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-uPic.debug.xcconfig"; path = "Target Support Files/Pods-uPic/Pods-uPic.debug.xcconfig"; sourceTree = ""; }; @@ -1059,7 +1059,7 @@ children = ( 169F073C22AF53DE008E8525 /* Base */, 96F2D378235B48CF001F74A5 /* zh-Hans */, - 96F23538238E2CE800414C98 /* en */, + 961AA898238E9764005A25C9 /* en */, ); name = Preferences.storyboard; sourceTree = ""; @@ -1204,7 +1204,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1234,7 +1234,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1259,7 +1259,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1282,7 +1282,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1305,7 +1305,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1330,7 +1330,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = W863J6W8DZ; + DEVELOPMENT_TEAM = 2U23P5CPX2; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json index 166cf96..7893ef1 100644 --- a/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json +++ b/uPic/Assets.xcassets/host_icon_6.imageset/Contents.json @@ -2,7 +2,7 @@ "images" : [ { "idiom" : "universal", - "filename" : "GitHub.png", + "filename" : "github.png", "scale" : "1x" }, { diff --git a/uPic/Assets.xcassets/host_icon_6.imageset/GitHub.png b/uPic/Assets.xcassets/host_icon_6.imageset/github.png similarity index 100% rename from uPic/Assets.xcassets/host_icon_6.imageset/GitHub.png rename to uPic/Assets.xcassets/host_icon_6.imageset/github.png diff --git a/uPic/Assets.xcassets/statusIcon.imageset/Contents.json b/uPic/Assets.xcassets/statusIcon.imageset/Contents.json index cd75e7d..46e755d 100644 --- a/uPic/Assets.xcassets/statusIcon.imageset/Contents.json +++ b/uPic/Assets.xcassets/statusIcon.imageset/Contents.json @@ -6,12 +6,12 @@ }, { "idiom" : "universal", - "filename" : "menubar.png", + "filename" : "menubar@2x.png.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "menubar@2x.png", + "filename" : "menubar@3x.png", "scale" : "3x" } ], diff --git a/uPic/Assets.xcassets/statusIcon.imageset/menubar.png b/uPic/Assets.xcassets/statusIcon.imageset/menubar@2x.png.png similarity index 100% rename from uPic/Assets.xcassets/statusIcon.imageset/menubar.png rename to uPic/Assets.xcassets/statusIcon.imageset/menubar@2x.png.png diff --git a/uPic/Assets.xcassets/statusIcon.imageset/menubar@2x.png b/uPic/Assets.xcassets/statusIcon.imageset/menubar@3x.png similarity index 100% rename from uPic/Assets.xcassets/statusIcon.imageset/menubar@2x.png rename to uPic/Assets.xcassets/statusIcon.imageset/menubar@3x.png diff --git a/uPic/Assets.xcassets/uploadIcon.imageset/Contents.json b/uPic/Assets.xcassets/uploadIcon.imageset/Contents.json index abce027..fa94a50 100644 --- a/uPic/Assets.xcassets/uploadIcon.imageset/Contents.json +++ b/uPic/Assets.xcassets/uploadIcon.imageset/Contents.json @@ -6,12 +6,12 @@ }, { "idiom" : "universal", - "filename" : "wait.png", + "filename" : "wait@2x.png", "scale" : "2x" }, { "idiom" : "universal", - "filename" : "wait@2x.png", + "filename" : "wait@3x.png", "scale" : "3x" } ], diff --git a/uPic/Assets.xcassets/uploadIcon.imageset/wait.png b/uPic/Assets.xcassets/uploadIcon.imageset/wait.png deleted file mode 100644 index 8ba5df2f66713871f496018a5977ec860f2432a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 635 zcmV->0)+jEP)Px%HAzH4R9Fesm^(`(K@^3@7rPk9iY`7t3=9?%H!%SJhP4OfL6< ztR{ihM#hYQVbBHI!8JGmM_>c|2dP>!)tA66c&dP1`UgQOHb&J;P)VfOUx2>~K7p#) z0+k+tDI|{no3UR&3+MygpaBH8Niu4N;)ru`AFLeON?SmCKZx~^#b`A&vNvs}v065LH4Ri*!I@#3;>MZs)9V4NZHA$X4^+$cwc0$s(GD(rpV}7Bd zzMN=XRE{$uG@fj3N(`^!5 zzQoz4n8^*rF>}hFHVdCxMQyU$no-*nGr6HSW={DlDy(x>mt$8E^=HMtNr=Si6!3Y) zO=*B-cFb;zZpZAli({3^eT@RT>G=E-xQC}bsZ|i0)+jEP)Px%HAzH4R9Fesm^(`(K@^3@7rPk9iY`7t3=9?%H!%SJhP4OfL6< ztR{ihM#hYQVbBHI!8JGmM_>c|2dP>!)tA66c&dP1`UgQOHb&J;P)VfOUx2>~K7p#) z0+k+tDI|{no3UR&3+MygpaBH8Niu4N;)ru`AFLeON?SmCKZx~^#b`A&vNvs}v065LH4Ri*!I@#3;>MZs)9V4NZHA$X4^+$cwc0$s(GD(rpV}7Bd zzMN=XRE{$uG@fj3N(`^!5 zzQoz4n8^*rF>}hFHVdCxMQyU$no-*nGr6HSW={DlDy(x>mt$8E^=HMtNr=Si6!3Y) zO=*B-cFb;zZpZAli({3^eT@RT>G=E-xQC}bsZ|iPx(nMp)JRCodHTw91uQ5YUZqTGdH!Ze6nQ{)9@hDjNrl$UuTgh#o&;l;xg#mkfz zJjsjlKolivD3eRMy@)g!9vIhXT)$7Va^~!{*X`_c&f0sgzrI=fthN4s{r`8?S$nOu z*Pfc1Ac282F)*kK&Q3&|i-6fcJum_o4txbZ0o}k8;1SRZ1W_}&#ZEiH)tKAw<5 zHv*l&T%ZBqFi{J<=?ABAZ-G=u6TIYjC+kU-&g+98gsNT6kK2KjKs7r8nva(mD0&B| z0`a-*9(-RHA6|7zxLSG)_)MIsZyY{mRfooCt4A_Isv!RZ;@J=lv$8pLXzmLjoXSed zCG>&HQaP|S&H%DPrYw%F1H-M%r$lD@ANWj!5Mf{}WgMIEl?rQ1$7EQ-tnHTn_JYRktCw$+eLb>urJW zLtXs0A(qdm@+RXDaH~turo?i?f_npbl;ti#n-a^tfviun;`rk>q_vn5JJQ;6b`;7= zY<6g}k7O!Tjsp|yRrMNto|T44eK~#n3=Z}IroVD6tE*9?7bvIGX|jDCTuj!orm3(S zr_!#@)+b0RhmupkGJq>Lg4fKm8D@O5Bm32MAtvQH1)g7(Dca`o z*iRD>CoE$fon7DTsQhh?3zkbam7-}Gdzgw;(LU>_daiGFbn%}Pffc8RkfBpHDd$h! zR9H98rf+uQ{1o}$5z8=H;I|Y(3T2a&;=`4Mu=m3l~;$z2;5I zR9H8z9pCK4`B|91Uj$AZ;0Y>=f6PeU2RR;Df@#v7(e~-=;}P`D4OKWXi=y zFD8nnb$pxHC*_YW{$sLkob=I5_7u)VIc?%lL-3k;EYmqD%6+pV{F0@65m!Vykt3@d z^2~W@5v+=v7e8MVnIUyzfG=3z5SoEl!9?llWtiv_W(tYrTYlUT58}qad6il#3d5Lc z&%s^rrd|Er4CGpOu2rhuD$17Nf@4MKxn>+(5X70J+XJyi9gDA!j*<~tE6YS4Ux(y| zg3X?2jH%3Kzei-vK#y&NB)tO&Lqe1TE|Hho5?Wk;4>H0rqyOY`1~8?VB-hU?pvd7N z&%O5>;%^6xPrjh8k#L^Y2D}9FMDQ=fdlr}mlvTJ|V-MyQ*>fO^B=d>uC13|o2Uv@C zwP0Y8|00BA4nZf<_^tvw2RBi8QzH29PIzAl5*P>!1O`fB;4k5?I;+7*04e|g002ov JPDHLkV1nHiNvr?> diff --git a/uPic/Assets.xcassets/uploadIcon.imageset/wait@3x.png b/uPic/Assets.xcassets/uploadIcon.imageset/wait@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..b2886bbf542a66fafbaf89a648f8cba29b710e80 GIT binary patch literal 1247 zcmV<51R(o~P)Px(nMp)JRCodHTw91uQ5YUZqTGdH!Ze6nQ{)9@hDjNrl$UuTgh#o&;l;xg#mkfz zJjsjlKolivD3eRMy@)g!9vIhXT)$7Va^~!{*X`_c&f0sgzrI=fthN4s{r`8?S$nOu z*Pfc1Ac282F)*kK&Q3&|i-6fcJum_o4txbZ0o}k8;1SRZ1W_}&#ZEiH)tKAw<5 zHv*l&T%ZBqFi{J<=?ABAZ-G=u6TIYjC+kU-&g+98gsNT6kK2KjKs7r8nva(mD0&B| z0`a-*9(-RHA6|7zxLSG)_)MIsZyY{mRfooCt4A_Isv!RZ;@J=lv$8pLXzmLjoXSed zCG>&HQaP|S&H%DPrYw%F1H-M%r$lD@ANWj!5Mf{}WgMIEl?rQ1$7EQ-tnHTn_JYRktCw$+eLb>urJW zLtXs0A(qdm@+RXDaH~turo?i?f_npbl;ti#n-a^tfviun;`rk>q_vn5JJQ;6b`;7= zY<6g}k7O!Tjsp|yRrMNto|T44eK~#n3=Z}IroVD6tE*9?7bvIGX|jDCTuj!orm3(S zr_!#@)+b0RhmupkGJq>Lg4fKm8D@O5Bm32MAtvQH1)g7(Dca`o z*iRD>CoE$fon7DTsQhh?3zkbam7-}Gdzgw;(LU>_daiGFbn%}Pffc8RkfBpHDd$h! zR9H98rf+uQ{1o}$5z8=H;I|Y(3T2a&;=`4Mu=m3l~;$z2;5I zR9H8z9pCK4`B|91Uj$AZ;0Y>=f6PeU2RR;Df@#v7(e~-=;}P`D4OKWXi=y zFD8nnb$pxHC*_YW{$sLkob=I5_7u)VIc?%lL-3k;EYmqD%6+pV{F0@65m!Vykt3@d z^2~W@5v+=v7e8MVnIUyzfG=3z5SoEl!9?llWtiv_W(tYrTYlUT58}qad6il#3d5Lc z&%s^rrd|Er4CGpOu2rhuD$17Nf@4MKxn>+(5X70J+XJyi9gDA!j*<~tE6YS4Ux(y| zg3X?2jH%3Kzei-vK#y&NB)tO&Lqe1TE|Hho5?Wk;4>H0rqyOY`1~8?VB-hU?pvd7N z&%O5>;%^6xPrjh8k#L^Y2D}9FMDQ=fdlr}mlvTJ|V-MyQ*>fO^B=d>uC13|o2Uv@C zwP0Y8|00BA4nZf<_^tvw2RBi8QzH29PIzAl5*P>!1O`fB;4k5?I;+7*04e|g002ov JPDHLkV1nHiNvr?> literal 0 HcmV?d00001 diff --git a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index 21f502c..e4e1f15 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -48,7 +48,18 @@ class AdvancedPreferencesViewController: PreferencesViewController { historyRecordFileNameScrollWaitTime.stringValue = "\(HistoryRecordFileNameScrollWaitTimeGlobal)" } - + @IBAction func didClickHistoryRecordConfigurationResetButton(_ sender: NSButton) { + Defaults[.historyRecordWidth] = Float(500) + Defaults[.historyRecordColumns] = Int(3) + Defaults[.historyRecordSpacing] = Float(5) + Defaults[.historyRecordPadding] = Float(5) + Defaults[.historyRecordFileNameScrollSpeed] = Double(30) + Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) + + setHistoryRecordTextFieldDefaultText() + ConfigNotifier.postNotification(.changeHistoryList) + } + @IBAction func didClickHistoryRecordConfigurationSaveButton(_ sender: NSButton) { Defaults[.historyRecordWidth] = Float(historyRecordWidth.stringValue) Defaults[.historyRecordColumns] = Int(historyRecordColumns.stringValue) diff --git a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard index 081070d..95de6bd 100644 --- a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard +++ b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard @@ -81,7 +81,7 @@ - + @@ -119,14 +119,14 @@ - + - + - + @@ -134,7 +134,7 @@ - + @@ -165,7 +165,7 @@ - + @@ -196,7 +196,7 @@ - + @@ -227,7 +227,7 @@ - + @@ -235,13 +235,13 @@ - + - + - + @@ -249,7 +249,7 @@ - + @@ -274,10 +274,10 @@ - + - + @@ -285,7 +285,7 @@ - + @@ -323,13 +323,13 @@ - + - + - + @@ -337,7 +337,7 @@ - + @@ -362,10 +362,10 @@ - + - + @@ -373,7 +373,7 @@ - + @@ -411,7 +411,7 @@ - + @@ -448,7 +448,7 @@ - + @@ -484,19 +484,45 @@ - + + + + + + + + + + + + + + + @@ -518,28 +544,28 @@ - + - - + + + + - - + + - - - + - + @@ -596,7 +622,7 @@ - + diff --git a/uPic/PreferencesWindow/en.lproj/Preferences.strings b/uPic/PreferencesWindow/en.lproj/Preferences.strings index eff66c9..89dff65 100644 --- a/uPic/PreferencesWindow/en.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/en.lproj/Preferences.strings @@ -17,6 +17,9 @@ /* Class = "NSWindow"; title = "Preferences"; ObjectID = "5f3-UK-Rft"; */ "5f3-UK-Rft.title" = "Preferences"; +/* Class = "NSButtonCell"; title = "Reset"; ObjectID = "8gb-uy-oRd"; */ +"8gb-uy-oRd.title" = "Reset"; + /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "8lH-1K-GR0"; */ "8lH-1K-GR0.title" = "Copy"; @@ -27,7 +30,7 @@ "AYG-Uz-MYq.title" = "Spacing:"; /* Class = "NSTextFieldCell"; title = "File name scroll speed:"; ObjectID = "BBZ-i9-B2g"; */ -"BBZ-i9-B2g.title" = "File name scroll speed(ms):"; +"BBZ-i9-B2g.title" = "File name scroll speed:"; /* Class = "NSButtonCell"; title = "Add Header Field"; ObjectID = "Ckh-A7-mxC"; */ "Ckh-A7-mxC.title" = "Add Header Field"; @@ -75,7 +78,7 @@ "OKr-1C-5jV.title" = "🐦 Twitter:"; /* Class = "NSTextFieldCell"; title = "File name scroll wait time:"; ObjectID = "ON0-aF-BNd"; */ -"ON0-aF-BNd.title" = "File name scroll wait time(s):"; +"ON0-aF-BNd.title" = "File name scroll wait time:"; /* Class = "NSBox"; title = "Header and Body Data"; ObjectID = "OaN-c4-l0X"; */ "OaN-c4-l0X.title" = "Header and Body Data"; diff --git a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings index 963c126..5c4b59d 100644 --- a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings @@ -17,6 +17,9 @@ /* Class = "NSWindow"; title = "Preferences"; ObjectID = "5f3-UK-Rft"; */ "5f3-UK-Rft.title" = "偏好设置"; +/* Class = "NSButtonCell"; title = "Reset"; ObjectID = "8gb-uy-oRd"; */ +"8gb-uy-oRd.title" = "重置"; + /* Class = "NSMenuItem"; title = "Copy"; ObjectID = "8lH-1K-GR0"; */ "8lH-1K-GR0.title" = "复制"; From 9ce76a30fff6b702a2b67772d47c2c09b63e83dd Mon Sep 17 00:00:00 2001 From: Svend Date: Wed, 27 Nov 2019 23:09:26 +0800 Subject: [PATCH 7/9] Fixed the problem that resetting the preferences will cause the chart bed configuration to be lost 1.Fixed the problem that resetting the preferences will cause the chart bed configuration to be lost 2. Optimize the logic of resetting the history configuration --- uPic.xcodeproj/project.pbxproj | 12 ++++---- uPic/General/Managers/ConfigManager.swift | 24 ++++++++++----- .../AdvancedPreferencesViewController.swift | 29 +++++++++++-------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index 1d111e3..c1790eb 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -1204,7 +1204,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1234,7 +1234,7 @@ CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 20191126; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; LD_RUNPATH_SEARCH_PATHS = ( @@ -1259,7 +1259,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1282,7 +1282,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicHelper/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1305,7 +1305,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -1330,7 +1330,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - DEVELOPMENT_TEAM = 2U23P5CPX2; + DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = uPicFinderExtension/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/uPic/General/Managers/ConfigManager.swift b/uPic/General/Managers/ConfigManager.swift index 6bd9334..4511967 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -50,18 +50,26 @@ public class ConfigManager { } public func removeAllUserDefaults() { + // 提前取出图床配置 + let hostItems = self.getHostItems() + let defaultHostId = Defaults[.defaultHostId] + let historyList = self.getHistoryList_New() - let ignoreKeys = [Keys.hostItems, Keys.defaultHostId, Keys.historyList] + let domain = Bundle.main.bundleIdentifier! + Defaults.removePersistentDomain(forName: domain) + Defaults.synchronize() - let dics = Defaults.dictionaryRepresentation() - for key in dics { - if ignoreKeys.contains(key.key) { - continue + DispatchQueue.main.async { + // 清除所有用户设置后,再重新写入图床配置 + self.setHostItems(items: hostItems) + Defaults[.defaultHostId] = defaultHostId + + let list = historyList.map { (model) -> [String: Any] in + return model.toKeyValue() } - Defaults.removeObject(forKey: key.key) + + self.setHistoryList_New(items: list) } - Defaults.synchronize() - } } diff --git a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index e4e1f15..60772d7 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -49,15 +49,19 @@ class AdvancedPreferencesViewController: PreferencesViewController { } @IBAction func didClickHistoryRecordConfigurationResetButton(_ sender: NSButton) { - Defaults[.historyRecordWidth] = Float(500) - Defaults[.historyRecordColumns] = Int(3) - Defaults[.historyRecordSpacing] = Float(5) - Defaults[.historyRecordPadding] = Float(5) - Defaults[.historyRecordFileNameScrollSpeed] = Double(30) - Defaults[.historyRecordFileNameScrollWaitTime] = Float(1) - setHistoryRecordTextFieldDefaultText() - ConfigNotifier.postNotification(.changeHistoryList) + Defaults.removeObject(forKey: Keys.historyRecordWidth) + Defaults.removeObject(forKey: Keys.historyRecordColumns) + Defaults.removeObject(forKey: Keys.historyRecordSpacing) + Defaults.removeObject(forKey: Keys.historyRecordPadding) + Defaults.removeObject(forKey: Keys.historyRecordFileNameScrollSpeed) + Defaults.removeObject(forKey: Keys.historyRecordFileNameScrollWaitTime) + Defaults.synchronize() + + DispatchQueue.main.async { + self.setHistoryRecordTextFieldDefaultText() + ConfigNotifier.postNotification(.changeHistoryList) + } } @IBAction func didClickHistoryRecordConfigurationSaveButton(_ sender: NSButton) { @@ -95,11 +99,12 @@ class AdvancedPreferencesViewController: PreferencesViewController { SMLoginItemSetEnabled(Constants.launcherAppIdentifier as CFString, false) ConfigManager.shared.removeAllUserDefaults() ConfigManager.shared.firstSetup() - _ = NSApplication.shared.delegate as! AppDelegate -// appDelegate.setStatusToggle() - // reset all values - resetAllValues() + DispatchQueue.main.async { + ConfigNotifier.postNotification(.changeHistoryList) + self.resetAllValues() + } + default: print("Cancel Resetting User Preferences") } From b0b6360cc029705e4fabd15197446bce8713e4e1 Mon Sep 17 00:00:00 2001 From: Svend Date: Wed, 27 Nov 2019 23:28:55 +0800 Subject: [PATCH 8/9] update finder icon --- .../upload.imageset/Contents.json | 11 +++++++---- .../Assets.xcassets/upload.imageset/dark@3x.png | Bin 0 -> 2001 bytes .../upload.imageset/light@3x-1.png | Bin 0 -> 1737 bytes .../Assets.xcassets/upload.imageset/light@3x.png | Bin 0 -> 1737 bytes 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 uPicFinderExtension/Assets.xcassets/upload.imageset/dark@3x.png create mode 100644 uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x-1.png create mode 100644 uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x.png diff --git a/uPicFinderExtension/Assets.xcassets/upload.imageset/Contents.json b/uPicFinderExtension/Assets.xcassets/upload.imageset/Contents.json index 5c21fbc..f90549b 100644 --- a/uPicFinderExtension/Assets.xcassets/upload.imageset/Contents.json +++ b/uPicFinderExtension/Assets.xcassets/upload.imageset/Contents.json @@ -56,27 +56,30 @@ }, { "idiom" : "universal", + "filename" : "light@3x-1.png", "scale" : "3x" }, { "idiom" : "universal", - "scale" : "3x", + "filename" : "light@3x.png", "appearances" : [ { "appearance" : "luminosity", "value" : "light" } - ] + ], + "scale" : "3x" }, { "idiom" : "universal", - "scale" : "3x", + "filename" : "dark@3x.png", "appearances" : [ { "appearance" : "luminosity", "value" : "dark" } - ] + ], + "scale" : "3x" } ], "info" : { diff --git a/uPicFinderExtension/Assets.xcassets/upload.imageset/dark@3x.png b/uPicFinderExtension/Assets.xcassets/upload.imageset/dark@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..78df44064a974270e99b001eccdc4149286b9422 GIT binary patch literal 2001 zcmai#Yar7N8^-^eVJ0kM<&nc$p`20;v7FiF7?v=s1HyznMTm{c`Roz3WfU`H9Yhov z(~6K(Dq*Oc61K&3@Vxr+zVD~!`EcF8>%Q;n`<3DD>L>?Og#iE{hr`-=Y>@O@P^pbM zSsH7)0Z@#GqYco|uQt1}*aaQM1-rNayEi-(0HuWjkl&FFscr}WBp4t-VuPUHHwO5> zUlK#&fBtunwJ*>W0Hn=vcGg~Tpaq&=jWS^?591RY7Fv+ejI5eysXQn&vM!5?;uHOhA!@hFv8<|~g#-z1{u-jIN z!_N;*|KJZizwQ%$;qS%2`+V;O2h;bFC}p}NSSh%g@{h=W2;Sb3aB7mlWQHg*LsGZ# zrHnvCkb(3xXK&P&pYlzVz>e13+}t*DU!e|VW{5LSLSVzLvBZj7%P-nKu1`HmC&@j1 z*+2MpH$(m8XAdCy33Zji?dk0wTH=wivuqz@E^9h<;P}0{{F#iTJ#lbT0bG4N@I@H7Fye)*R>szRk-q%*(FvquS1zo1t zk}RiP@994`b^<{1+L;<1#hsPW=3|_RF1~~2L|1i8{1dT_rq;DCNx@G#4h&Bw?W80K zQS+<_jHpejq$vB|^~CBJTW|@rJ=h#NQ}Aa`V*|Za+DdTfLw)E%ZG=<(#kJ${UCS0o z>|X$PILBo%e3|d0I#9+j8r*b( zSe@N7`qp)3)YZ+jRJm_IhOdhiX>UX!3`AzCXosv*5vAJ)eyR%{+<6{%!&#U*rnXv`gXv=_98FelqscO5~3rgv>Z}iEj~J~4KNWq zK14(q1gMCrMt?TSb-M!cZ0WK-@JlK8s9(I7-`xsP1Z0k@kn)k}Qy2v^Se1U{5fOSy-c%y9i4K3zL@+8Y zQ|K{LqhEIHMeT13eL?yBV4hl%jR^HOE$<%TjULA8$Q1j@7djhPK1la<=$#Mg^wVgd zy)gnoqGb-CQ@n&k=5U2)Q1T6`1@_SL;G_id?9`Mc%IG_Rea(yobo%xiOafP9+c5%qmAbsEK4@3-K9VXIU zR*sU1PZ>iFY`zi}vy;!61FNsbv9C0|(m7GxfMGp!!euGXV)C+w3@x?}na789v+XQlnH{3>N| z%ZzYR>Bd(Xdl6*kkFYfbJsMDMGH#o{l=MlO8t#YdEPBne_%e*rOuQfXnQFziVIRDH zOebA%GoE&rt$EbVz2#jAnt5hD+I=4vT{D$%A-oUKt(pQahdvuuh3gA$f9_AkSrwlQ zO$@X;pR*X$n8B_1F(xUiV4WkXwA zttU!W2|uy+Qvt~bWNOrY-Crf2KNtUyY==+K9X5ZRb(H6L=U{}tjQE3eQR$&KPjmyf zHN5F&O|i)IrUpp;iruc-Ysos|pjVxQPls;3H|+gdYgEt*iTXyac##{$0VlJmLm80u zvs%jEBcV35W+lg)TG(%6P=bMA+8jqys^6tlj$&Q&q?`CJys?mmNR~Rz7x;`DGa)?K z`?bQ<-0+p2}Vzen;)tFIvLi(dP6x2ZhS6?e-b z%bobH)K+{kykykFqmi`(88k}iVtHKdvl%8(>)2ga;{%_lAXH25j|3G-fTYZ=-S z?^nbLl;mnHgpK{$A2Mg^Br(NF%KK0RSSvjbuX5z zmXM~fyTiVyx+llYcr?-!P zH|c4eVD1go)OSFy6c25qJd+a4JBNF%2GS;=b0DC znbz>M rCQHS%fU~7#|JF$VUs_h4lIs$_BS)ro`KxUGU8gvESGxuqQp$e-bQFi& literal 0 HcmV?d00001 diff --git a/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x-1.png b/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x-1.png new file mode 100644 index 0000000000000000000000000000000000000000..27efaf3d128d40dc0aab12a7b26b38e580fb51e0 GIT binary patch literal 1737 zcma)-X*}Ec7RG=1Cy}6pqSo5x&S*`Fp?4CbmQ;({VrfxrW8c+Qks)Mp?Ok=Ds%5OP zc0tjm#86AD9d3=bM1_uyqAIO4l;O?2@9yWmc+U4Z=REJ9Y?8CBjFg%b06@mx&c^0E(hasv809t~ibVF0lk*^%0g0Dzak0DOnA z-CGItpRaET{J(xTSZzXf20+5Z-p1O43R^nk!&W+}@+B`g=rrqgzCfp|Nt!)(ROs>b z)(PwAn^WB_R&u(+w^nFZYeQWNRY@@k!*p|HVluRIY%VloKNqwd#@^(OH?>E{zw|Q= z3I0;p{BlsdKD~|Mdq=Ez=dWyUO`0qk#~;7s=8p7$owQOS{ZE8@`d(N%awE}5Ia3R{ z4_afGa{n=NYDO&vhR0|??WlH$0_lN&x*(TrpW&EgT>3qc>}Lsvh1HNN6Gd7M;Cc!< zNuDpJDU1&7W(XPlb|Vp%b5qa%;tI7b2~z-LdrNUxo5!>>`V69qj*<<%zpY17AOc^a zHS3h^ZKs7~$NM#w`!BCJ9B7wZK+VJi+($CIcmk*!XD!k=b6#BvqRSIZmyw!?V7P$U z@UZ{m9Plm5&(lOyJ>!y*Z-!?#rnt2rvu}S`K&M#2DrZ55keZ?OBU7Dm`C&`v;qI{P z1Uk#bC6S2GTp_M5DX`XZv)$mG>aTHUHGxE$gVveay&;CIYblQ}#Bbq5JlA_Fg1|+U z(V^0i6hY00{cgGsDto(eoqu3D%7(P?G+}chDYhnhUbdkZ+2O!lzF`sbL)dWEIY-m# z#VhiFkF1^l$!ulj=kpSY!zp>H6JANHgDolVwt5Cf(V|TVe~f;hNnpTsS-L0lxl0cu z{yG*~#vq~gPS6dS=*1wbNIpaAt@pOY_~KgK>za28;3tJ^a=qWZ43gsv=>dP`O3q1i ztx8koi~^ADEdRq2$|CHMwJ>|k-td^il2|gVZW;qew78YWyGQKhLyoo+POOdEry!Y7 zq)SI=h+zRgUVYn2Kq@~Saq09c)KM~@cl&^0O!?((%Ev5>#5$jlb5465V7kd__fPA9 zA4IflVE6Lzdf%ftxI-r8#IcId87W`sYr1q5jbL+p*JSm-23`bxM9V_Gtuz85eTGup zFq;-WP>x`}`emi`($S#lsVE({x!N3l4%o7jgw_Y!lD#G+NZ;*7+h^57DiD74I&+0_ z2NL8TJP$R~(r;h=tQxrG^g)_0Y#Wn{v*+76;%|w1JSDBE16RZHTf0sMxfYXz*nwnKF{>lldN&fBl(NgR;HPq9k z!4dHteKa{ZJJ2$olY|U42AQK|@+~`fu{(mOZ+l0&vIuyH-MgtL*Rgun=JAmJepAJ)b&ioGTgf)WnIczFC^u1YW&N(o6>PU{C{;D? zeOb1#<>hj(%^`j3?tI0u$mGCUZA*4_4)t@sx|XESk`0{AC&QN!#OyZAr2o^;^^g^=vPB{rkJsy;W`Q(_^$1ze6~@SOl>h z=1M7vB_kZ2xZE4P#mS^Uv7~YGS-!h@vHY6^gHLASh_t!3u-JiwJ+m|_VkpL`+Tda1 zQe3~zE27p&$q$-?Q)#J{u!PCD!-KXqkNlr+Io7kiJp`>{6YZb9$EJguj#%gmHhb`@ zvjuO2>gMxxcTfM@U*kkQ+~2}5No}dVE0@xNRgYHbHj#kX zP|Z=?12ihijobOp)l=={*sx~1Pjr*kj<3etbi@21nsd&A(TM0EL(vE5-iK*`RzzCq zScv%CliplG#k)sAp05}QA1QOna1)T{&np)7>wM&UFT+(3{XMRHB4e`(!(^#j7A&KN lVc|6l{SqlQ^#6fW!`(Kcd7bj~QtsKU5&L7#HVs5y*58M)2!;Rv literal 0 HcmV?d00001 diff --git a/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x.png b/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x.png new file mode 100644 index 0000000000000000000000000000000000000000..27efaf3d128d40dc0aab12a7b26b38e580fb51e0 GIT binary patch literal 1737 zcma)-X*}Ec7RG=1Cy}6pqSo5x&S*`Fp?4CbmQ;({VrfxrW8c+Qks)Mp?Ok=Ds%5OP zc0tjm#86AD9d3=bM1_uyqAIO4l;O?2@9yWmc+U4Z=REJ9Y?8CBjFg%b06@mx&c^0E(hasv809t~ibVF0lk*^%0g0Dzak0DOnA z-CGItpRaET{J(xTSZzXf20+5Z-p1O43R^nk!&W+}@+B`g=rrqgzCfp|Nt!)(ROs>b z)(PwAn^WB_R&u(+w^nFZYeQWNRY@@k!*p|HVluRIY%VloKNqwd#@^(OH?>E{zw|Q= z3I0;p{BlsdKD~|Mdq=Ez=dWyUO`0qk#~;7s=8p7$owQOS{ZE8@`d(N%awE}5Ia3R{ z4_afGa{n=NYDO&vhR0|??WlH$0_lN&x*(TrpW&EgT>3qc>}Lsvh1HNN6Gd7M;Cc!< zNuDpJDU1&7W(XPlb|Vp%b5qa%;tI7b2~z-LdrNUxo5!>>`V69qj*<<%zpY17AOc^a zHS3h^ZKs7~$NM#w`!BCJ9B7wZK+VJi+($CIcmk*!XD!k=b6#BvqRSIZmyw!?V7P$U z@UZ{m9Plm5&(lOyJ>!y*Z-!?#rnt2rvu}S`K&M#2DrZ55keZ?OBU7Dm`C&`v;qI{P z1Uk#bC6S2GTp_M5DX`XZv)$mG>aTHUHGxE$gVveay&;CIYblQ}#Bbq5JlA_Fg1|+U z(V^0i6hY00{cgGsDto(eoqu3D%7(P?G+}chDYhnhUbdkZ+2O!lzF`sbL)dWEIY-m# z#VhiFkF1^l$!ulj=kpSY!zp>H6JANHgDolVwt5Cf(V|TVe~f;hNnpTsS-L0lxl0cu z{yG*~#vq~gPS6dS=*1wbNIpaAt@pOY_~KgK>za28;3tJ^a=qWZ43gsv=>dP`O3q1i ztx8koi~^ADEdRq2$|CHMwJ>|k-td^il2|gVZW;qew78YWyGQKhLyoo+POOdEry!Y7 zq)SI=h+zRgUVYn2Kq@~Saq09c)KM~@cl&^0O!?((%Ev5>#5$jlb5465V7kd__fPA9 zA4IflVE6Lzdf%ftxI-r8#IcId87W`sYr1q5jbL+p*JSm-23`bxM9V_Gtuz85eTGup zFq;-WP>x`}`emi`($S#lsVE({x!N3l4%o7jgw_Y!lD#G+NZ;*7+h^57DiD74I&+0_ z2NL8TJP$R~(r;h=tQxrG^g)_0Y#Wn{v*+76;%|w1JSDBE16RZHTf0sMxfYXz*nwnKF{>lldN&fBl(NgR;HPq9k z!4dHteKa{ZJJ2$olY|U42AQK|@+~`fu{(mOZ+l0&vIuyH-MgtL*Rgun=JAmJepAJ)b&ioGTgf)WnIczFC^u1YW&N(o6>PU{C{;D? zeOb1#<>hj(%^`j3?tI0u$mGCUZA*4_4)t@sx|XESk`0{AC&QN!#OyZAr2o^;^^g^=vPB{rkJsy;W`Q(_^$1ze6~@SOl>h z=1M7vB_kZ2xZE4P#mS^Uv7~YGS-!h@vHY6^gHLASh_t!3u-JiwJ+m|_VkpL`+Tda1 zQe3~zE27p&$q$-?Q)#J{u!PCD!-KXqkNlr+Io7kiJp`>{6YZb9$EJguj#%gmHhb`@ zvjuO2>gMxxcTfM@U*kkQ+~2}5No}dVE0@xNRgYHbHj#kX zP|Z=?12ihijobOp)l=={*sx~1Pjr*kj<3etbi@21nsd&A(TM0EL(vE5-iK*`RzzCq zScv%CliplG#k)sAp05}QA1QOna1)T{&np)7>wM&UFT+(3{XMRHB4e`(!(^#j7A&KN lVc|6l{SqlQ^#6fW!`(Kcd7bj~QtsKU5&L7#HVs5y*58M)2!;Rv literal 0 HcmV?d00001 From ed7e41ea04fc8356a7adb88625764eb17b2f853f Mon Sep 17 00:00:00 2001 From: Svend Date: Mon, 2 Dec 2019 11:14:13 +0800 Subject: [PATCH 9/9] :bookmark: Releasing v0.14.2 --- uPic.xcodeproj/project.pbxproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/uPic.xcodeproj/project.pbxproj b/uPic.xcodeproj/project.pbxproj index c1790eb..565044c 100644 --- a/uPic.xcodeproj/project.pbxproj +++ b/uPic.xcodeproj/project.pbxproj @@ -1203,7 +1203,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20191126; + CURRENT_PROJECT_VERSION = 20191202; DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; @@ -1212,7 +1212,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 0.14.1; + MARKETING_VERSION = 0.14.2; PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -1233,7 +1233,7 @@ CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 20191126; + CURRENT_PROJECT_VERSION = 20191202; DEVELOPMENT_TEAM = W863J6W8DZ; ENABLE_HARDENED_RUNTIME = YES; INFOPLIST_FILE = "$(SRCROOT)/uPic/Supporting Files/Info.plist"; @@ -1242,7 +1242,7 @@ "@executable_path/../Frameworks", ); MACOSX_DEPLOYMENT_TARGET = 10.12; - MARKETING_VERSION = 0.14.1; + MARKETING_VERSION = 0.14.2; PRODUCT_BUNDLE_IDENTIFIER = com.svend.uPic; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = "";