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..565044c 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 = ""; }; @@ -282,10 +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 = ""; }; - 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 = ""; }; + 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 = ""; }; @@ -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,12 +1044,22 @@ 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 = ( 169F073C22AF53DE008E8525 /* Base */, - 96F2D372235B456F001F74A5 /* en */, 96F2D378235B48CF001F74A5 /* zh-Hans */, + 961AA898238E9764005A25C9 /* en */, ); name = Preferences.storyboard; sourceTree = ""; @@ -1062,16 +1072,6 @@ name = Main.storyboard; sourceTree = ""; }; - 96F2D36A235B424D001F74A5 /* Main.storyboard */ = { - isa = PBXVariantGroup; - children = ( - 96F2D369235B424D001F74A5 /* Base */, - 96F2D36C235B42A0001F74A5 /* en */, - 96F2D370235B4317001F74A5 /* zh-Hans */, - ); - name = Main.storyboard; - sourceTree = ""; - }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ @@ -1200,10 +1200,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; + 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 = ""; @@ -1230,10 +1230,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = "uPic/Supporting Files/uPic.entitlements"; - CODE_SIGN_IDENTITY = "Mac Developer"; + 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 = ""; @@ -1256,7 +1256,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = W863J6W8DZ; @@ -1279,7 +1279,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = uPicHelper/uPicHelper.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = W863J6W8DZ; @@ -1302,7 +1302,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = W863J6W8DZ; @@ -1327,7 +1327,7 @@ buildSettings = { APPLICATION_EXTENSION_API_ONLY = NO; CODE_SIGN_ENTITLEMENTS = uPicFinderExtension/uPicFinderExtension.entitlements; - CODE_SIGN_IDENTITY = "Mac Developer"; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Manual; COMBINE_HIDPI_IMAGES = YES; DEVELOPMENT_TEAM = W863J6W8DZ; diff --git a/uPic/AppDelegate.swift b/uPic/AppDelegate.swift index ebd549b..4104586 100644 --- a/uPic/AppDelegate.swift +++ b/uPic/AppDelegate.swift @@ -52,7 +52,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { self.setupStatusBar() self.bindShortcuts() - + // 添加 Finder 右键文件上传监听 UploadNotifier.addObserver(observer: self, selector: #selector(uploadFilesFromFinderMenu), notification: .uploadFiles) } 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 8ba5df2..0000000 Binary files a/uPic/Assets.xcassets/uploadIcon.imageset/wait.png and /dev/null differ diff --git a/uPic/Assets.xcassets/uploadIcon.imageset/wait@2x.png b/uPic/Assets.xcassets/uploadIcon.imageset/wait@2x.png index b2886bb..8ba5df2 100644 Binary files a/uPic/Assets.xcassets/uploadIcon.imageset/wait@2x.png and b/uPic/Assets.xcassets/uploadIcon.imageset/wait@2x.png differ 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 0000000..b2886bb Binary files /dev/null and b/uPic/Assets.xcassets/uploadIcon.imageset/wait@3x.png differ 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/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 d999f58..4511967 100644 --- a/uPic/General/Managers/ConfigManager.swift +++ b/uPic/General/Managers/ConfigManager.swift @@ -52,11 +52,24 @@ public class ConfigManager { public func removeAllUserDefaults() { // 提前取出图床配置 let hostItems = self.getHostItems() + let defaultHostId = Defaults[.defaultHostId] + let historyList = self.getHistoryList_New() + let domain = Bundle.main.bundleIdentifier! Defaults.removePersistentDomain(forName: domain) - // 清除所有用户设置后,再重新写入图床配置 - self.setHostItems(items: hostItems) Defaults.synchronize() + + DispatchQueue.main.async { + // 清除所有用户设置后,再重新写入图床配置 + self.setHostItems(items: hostItems) + Defaults[.defaultHostId] = defaultHostId + + let list = historyList.map { (model) -> [String: Any] in + return model.toKeyValue() + } + + self.setHistoryList_New(items: list) + } } } @@ -96,7 +109,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,12 +117,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) }) @@ -117,9 +131,9 @@ extension ConfigManager { } func setHistoryList_New(items: [[String: Any]]) -> Void { - Defaults[.historyList_New] = items + Defaults[.historyList] = items Defaults.synchronize() - ConfigNotifier.postNotification(.changeHistoryList) + ConfigNotifier.postNotification(.updateHistoryList) } func addHistory_New(url: String, previewModel: HistoryThumbnailModel) -> Void { diff --git a/uPic/General/Utils/PreferenceKey.swift b/uPic/General/Utils/PreferenceKey.swift index ba3c7ac..46d9ccb 100644 --- a/uPic/General/Utils/PreferenceKey.swift +++ b/uPic/General/Utils/PreferenceKey.swift @@ -14,11 +14,16 @@ 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" + static let historyRecordPadding = "uPic_HistoryRecordPadding" + static let historyRecordFileNameScrollSpeed = "uPic_HistoryRecordFileNameScrollSpeed" + static let historyRecordFileNameScrollWaitTime = "uPic_HistoryRecordFileNameScrollWaitTime" } class DefaultsKeys { @@ -46,9 +51,15 @@ 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) + 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 +84,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/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/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/PreferencesWindow/AdvancedPreferencesViewController.swift b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift index bd1d316..60772d7 100644 --- a/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift +++ b/uPic/PreferencesWindow/AdvancedPreferencesViewController.swift @@ -15,18 +15,66 @@ 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 override func viewDidLoad() { super.viewDidLoad() - + + resetAllValues() + } + + func resetAllValues() { selectFileShortcut.associatedUserDefaultsKey = Constants.Key.selectFileShortcut pasteboardShortcut.associatedUserDefaultsKey = Constants.Key.pasteboardShortcut screenshotShortcut.associatedUserDefaultsKey = Constants.Key.screenshotShortcut + + setHistoryRecordTextFieldDefaultText() + } + + func setHistoryRecordTextFieldDefaultText() { + historyRecordWidth.stringValue = "\(HistoryRecordWidthGlobal)" + historyRecordColumns.stringValue = "\(HistoryRecordColumnsGlobal)" + historyRecordSpacing.stringValue = "\(HistoryRecordSpacingGlobal)" + historyRecordPadding.stringValue = "\(HistoryRecordPaddingGlobal)" + historyRecordFileNameScrollSpeed.stringValue = "\(HistoryRecordFileNameScrollSpeedGlobal)" + historyRecordFileNameScrollWaitTime.stringValue = "\(HistoryRecordFileNameScrollWaitTimeGlobal)" } + @IBAction func didClickHistoryRecordConfigurationResetButton(_ sender: NSButton) { + + 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) { + 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) { @@ -51,8 +99,12 @@ class AdvancedPreferencesViewController: PreferencesViewController { SMLoginItemSetEnabled(Constants.launcherAppIdentifier as CFString, false) ConfigManager.shared.removeAllUserDefaults() ConfigManager.shared.firstSetup() - _ = NSApplication.shared.delegate as! AppDelegate -// appDelegate.setStatusToggle() + + DispatchQueue.main.async { + ConfigNotifier.postNotification(.changeHistoryList) + self.resetAllValues() + } + default: print("Cancel Resetting User Preferences") } diff --git a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard index 9fabca4..95de6bd 100644 --- a/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard +++ b/uPic/PreferencesWindow/Base.lproj/Preferences.storyboard @@ -1,8 +1,8 @@ - + - + @@ -62,11 +62,11 @@ - + - + + + + + + + + + + + + - + - + @@ -251,9 +551,22 @@ - - - + + + + + + + + + + + + + + + + @@ -263,6 +576,12 @@ + + + + + + @@ -272,6 +591,12 @@ + + + + + + @@ -283,6 +608,12 @@ + + + + + + @@ -291,18 +622,18 @@ - + - + - + @@ -551,7 +882,7 @@ - + @@ -965,7 +1296,7 @@ Gw - + diff --git a/uPic/PreferencesWindow/en.lproj/Preferences.strings b/uPic/PreferencesWindow/en.lproj/Preferences.strings index f803cb5..89dff65 100644 --- a/uPic/PreferencesWindow/en.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/en.lproj/Preferences.strings @@ -17,12 +17,21 @@ /* 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"; /* 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 +71,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 +89,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 +107,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 = "Padding:"; ObjectID = "bp8-mz-gke"; */ +"bp8-mz-gke.title" = "Padding:"; -/* Class = "NSTextFieldCell"; title = "Upload with Pasteboard:"; ObjectID = "bvy-v3-hhf"; */ -"bvy-v3-hhf.title" = "Upload with Pasteboard:"; +/* 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 +137,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 +158,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..5c4b59d 100644 --- a/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings +++ b/uPic/PreferencesWindow/zh-Hans.lproj/Preferences.strings @@ -2,52 +2,61 @@ /* 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 = "NSButtonCell"; title = "Reset"; ObjectID = "8gb-uy-oRd"; */ +"8gb-uy-oRd.title" = "重置"; + +/* 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" = "文件名滚动速度(ms):"; + /* 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 +65,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" = "文件名滚动等待时间(s):"; + +/* 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 +158,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..40e0c89 100644 --- a/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift +++ b/uPic/Views/HistoryRecord/HistoryThumbnailConstant.swift @@ -9,35 +9,58 @@ import Foundation /// 历史记录总宽 -var historyRecordViewWidthGlobal: CGFloat { - return 500 +var HistoryRecordWidthGlobal: CGFloat { + guard let width = Defaults[.historyRecordWidth], width > 0 else { + return 500 + } + return CGFloat(width) } /// 预览图列数 -var previewLineNumberGlobal: Int { - return 3 +var HistoryRecordColumnsGlobal: Int { + guard let columns = Defaults[.historyRecordColumns], columns > 0 else { + return 3 + } + return columns } /// 预览图间距 -var previewLineSpacingGlobal: CGFloat { - return 5 +var HistoryRecordSpacingGlobal: CGFloat { + guard let spacing = Defaults[.historyRecordSpacing], spacing > 0 else { + return 5 + } + return CGFloat(spacing) } /// 历史记录内边距 -var historyRecordLeftRightInsetGlobal: CGFloat { - return 5 +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 0.03 +/// 文件名滚动速率百分比 1s 为基数 +var HistoryRecordFileNameScrollSpeedGlobal: TimeInterval { + guard let speed = Defaults[.historyRecordFileNameScrollSpeed], speed > 0 else { + return 30 + } + return speed } -var fileNameScrollingTime: CGFloat { - return 1 +var HistoryRecordFileNameScrollSpeed: TimeInterval { + return 1 * (HistoryRecordFileNameScrollSpeedGlobal / 1000) +} + +/// 下次滚动等待时间 +var HistoryRecordFileNameScrollWaitTimeGlobal: CGFloat { + guard let time = Defaults[.historyRecordFileNameScrollWaitTime], time > 0 else { + return 1 + } + return CGFloat(time) } 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/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/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/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 f475a48..f021b4d 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.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) @@ -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 @@ -74,7 +84,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) @@ -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,25 @@ 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) + clearHistoryButton.toolTip = "\("Clear history record".localized) \(ConfigManager.shared.getHistoryList_New().count)" + } + + func menuDidClose(_ menu: NSMenu) { + menuIsOpen = false } } diff --git a/uPic/Views/StatusMenuController.swift b/uPic/Views/StatusMenuController.swift index 1601ff3..2b1fe12 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() @@ -214,9 +182,9 @@ 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) + previewView.frame.size = NSSize(width: HistoryRecordWidthGlobal, height: 400) imgMenuItem.view = previewView } @@ -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" = "检查更新..."; 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 0000000..78df440 Binary files /dev/null and b/uPicFinderExtension/Assets.xcassets/upload.imageset/dark@3x.png differ 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 0000000..27efaf3 Binary files /dev/null and b/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x-1.png differ 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 0000000..27efaf3 Binary files /dev/null and b/uPicFinderExtension/Assets.xcassets/upload.imageset/light@3x.png differ