mirror of
https://github.com/qvacua/vimr.git
synced 2024-09-11 17:15:34 +03:00
Remove warnings and bump deployment target to 10.15
This commit is contained in:
parent
0ac4aca507
commit
9d9d8947b9
@ -63,8 +63,10 @@ public extension NSColor {
|
||||
}
|
||||
|
||||
convenience init?(hex: String) {
|
||||
var result: UInt32 = 0
|
||||
guard hex.count == 6, Scanner(string: hex).scanHexInt32(&result) else { return nil }
|
||||
guard hex.count == 6,
|
||||
let uint64 = Scanner(string: hex).scanUInt64(representation: .hexadecimal)
|
||||
else { return nil }
|
||||
let result = UInt32(uint64)
|
||||
|
||||
let r = (result & 0xFF0000) >> 16
|
||||
let g = (result & 0x00FF00) >> 8
|
||||
@ -126,7 +128,7 @@ public extension NSView {
|
||||
/// - Warning: Call only in drawRect()
|
||||
func rectsBeingDrawn() -> [CGRect] {
|
||||
var rectsPtr: UnsafePointer<CGRect>?
|
||||
var count: Int = 0
|
||||
var count = 0
|
||||
self.getRectsBeingDrawn(&rectsPtr, count: &count)
|
||||
|
||||
return Array(UnsafeBufferPointer(start: rectsPtr, count: count))
|
||||
@ -134,7 +136,8 @@ public extension NSView {
|
||||
}
|
||||
|
||||
public extension NSEvent.ModifierFlags {
|
||||
// Values are from https://github.com/SFML/SFML/blob/master/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
|
||||
// Values are from
|
||||
// https://github.com/SFML/SFML/blob/master/src/SFML/Window/OSX/SFKeyboardModifiersHelper.mm
|
||||
static let rightShift = NSEvent.ModifierFlags(rawValue: 0x020004)
|
||||
static let leftShift = NSEvent.ModifierFlags(rawValue: 0x020002)
|
||||
static let rightCommand = NSEvent.ModifierFlags(rawValue: 0x100010)
|
||||
|
@ -134,9 +134,4 @@ public extension URL {
|
||||
var isPackage: Bool { (try? self.resourceValues(forKeys: [.isPackageKey]))?.isPackage ?? false }
|
||||
}
|
||||
|
||||
public extension ValueTransformer {
|
||||
static var keyedUnarchiveFromDataTransformer
|
||||
= ValueTransformer(forName: .keyedUnarchiveFromDataTransformerName)!
|
||||
}
|
||||
|
||||
private let log = OSLog(subsystem: "com.qvacua.vimr.commons", category: "general")
|
||||
|
@ -202,7 +202,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
@ -257,7 +257,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
|
@ -564,7 +564,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
@ -623,7 +623,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.15;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_DISABLE_SAFETY_CHECKS = YES;
|
||||
|
@ -3,7 +3,7 @@
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 52;
|
||||
objectVersion = 54;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
@ -933,6 +933,7 @@
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
4B19BEFF1E110208007E823C /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
|
@ -8,6 +8,24 @@ import PureLayout
|
||||
import RxSwift
|
||||
import ShortcutRecorder
|
||||
|
||||
final class ShortcutValueTransformer: ValueTransformer {
|
||||
static let shared = ShortcutValueTransformer()
|
||||
|
||||
override class func allowsReverseTransformation() -> Bool { true }
|
||||
|
||||
/// Data to Shortcut
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
guard let value, let data = value as? Data else { return nil }
|
||||
return try? NSKeyedUnarchiver.unarchivedObject(ofClass: Shortcut.self, from: data)
|
||||
}
|
||||
|
||||
/// Shortcut to Data
|
||||
override func reverseTransformedValue(_ value: Any?) -> Any? {
|
||||
guard let value, let shortcut = value as? Shortcut else { return nil }
|
||||
return try? NSKeyedArchiver.archivedData(withRootObject: shortcut, requiringSecureCoding: true)
|
||||
}
|
||||
}
|
||||
|
||||
final class ShortcutsPref: PrefPane,
|
||||
UiComponent,
|
||||
NSOutlineViewDelegate,
|
||||
@ -93,9 +111,7 @@ final class ShortcutsPref: PrefPane,
|
||||
shortcut = defaultShortcuts[id] ?? nil
|
||||
}
|
||||
|
||||
let data = ValueTransformer
|
||||
.keyedUnarchiveFromDataTransformer
|
||||
.reverseTransformedValue(shortcut) as? NSData
|
||||
let data = ShortcutValueTransformer.shared.reverseTransformedValue(shortcut) as? NSData
|
||||
self.shortcutsUserDefaults?.set(data, forKey: id)
|
||||
}
|
||||
|
||||
@ -103,7 +119,7 @@ final class ShortcutsPref: PrefPane,
|
||||
}
|
||||
|
||||
private func initShortcutUserDefaults() {
|
||||
let transformer = ValueTransformer.keyedUnarchiveFromDataTransformer
|
||||
let transformer = ShortcutValueTransformer.shared
|
||||
defaultShortcuts.forEach { id, shortcut in
|
||||
if self.shortcutsUserDefaults?.value(forKey: id) == nil {
|
||||
let shortcutData = transformer.reverseTransformedValue(shortcut) as? NSData
|
||||
@ -206,7 +222,7 @@ final class ShortcutsPref: PrefPane,
|
||||
}
|
||||
|
||||
private func updateShortcutService() {
|
||||
let transformer = ValueTransformer.keyedUnarchiveFromDataTransformer
|
||||
let transformer = ShortcutValueTransformer.shared
|
||||
let shortcuts = defaultShortcuts.compactMap { id, shortcut -> Shortcut? in
|
||||
if self.shortcutsUserDefaults?.value(forKey: id) == nil { return shortcut }
|
||||
|
||||
@ -269,9 +285,7 @@ extension ShortcutsPref {
|
||||
guard response == .alertSecondButtonReturn else { return }
|
||||
self.traverseMenuItems { identifier, _ in
|
||||
let shortcut = defaultShortcuts[identifier] ?? Shortcut(keyEquivalent: "")
|
||||
let valueToWrite = ValueTransformer
|
||||
.keyedUnarchiveFromDataTransformer
|
||||
.reverseTransformedValue(shortcut)
|
||||
let valueToWrite = ShortcutValueTransformer.shared.reverseTransformedValue(shortcut)
|
||||
|
||||
self.shortcutsDefaultsController.setValue(valueToWrite, forKeyPath: "values.\(identifier)")
|
||||
|
||||
@ -329,8 +343,7 @@ extension ShortcutsPref {
|
||||
forKeyPath: "values.\(identifier)"
|
||||
) as? NSData else { return true }
|
||||
|
||||
guard let shortcutFromDefaults = ValueTransformer
|
||||
.keyedUnarchiveFromDataTransformer
|
||||
guard let shortcutFromDefaults = ShortcutValueTransformer.shared
|
||||
.transformedValue(dataFromDefaults) as? Shortcut else { return true }
|
||||
|
||||
let defaultShortcut = defaultShortcuts[identifier] ?? nil
|
||||
@ -353,9 +366,9 @@ private let defaultsVersion = 337
|
||||
|
||||
private class DataToKeyEquivalentTransformer: ValueTransformer {
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
guard let shortcut = ValueTransformer
|
||||
.keyedUnarchiveFromDataTransformer
|
||||
.transformedValue(value) as? Shortcut else { return "" }
|
||||
guard let shortcut = ShortcutValueTransformer.shared.transformedValue(value) as? Shortcut else {
|
||||
return ""
|
||||
}
|
||||
|
||||
return KeyEquivalentTransformer.shared.transformedValue(shortcut)
|
||||
}
|
||||
@ -363,8 +376,7 @@ private class DataToKeyEquivalentTransformer: ValueTransformer {
|
||||
|
||||
private class DataToKeyEquivalentModifierMaskTransformer: ValueTransformer {
|
||||
override func transformedValue(_ value: Any?) -> Any? {
|
||||
guard let shortcut = ValueTransformer
|
||||
.keyedUnarchiveFromDataTransformer
|
||||
guard let shortcut = ShortcutValueTransformer.shared
|
||||
.transformedValue(value) as? Shortcut else { return NSNumber(value: 0) }
|
||||
|
||||
return KeyEquivalentModifierMaskTransformer.shared.transformedValue(shortcut)
|
||||
|
@ -40,7 +40,7 @@ final class ShortcutTableCell: NSTableCellView {
|
||||
.value,
|
||||
to: content,
|
||||
withKeyPath: keypath,
|
||||
options: [.valueTransformer: ValueTransformer.keyedUnarchiveFromDataTransformer]
|
||||
options: [.valueTransformer: ShortcutValueTransformer.shared]
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user