Repo // Compatibility with Xcode 15.

This commit is contained in:
ShikiSuen 2023-06-06 20:42:08 +08:00
parent 0bb6a26b3a
commit 3f0f308c81
47 changed files with 124 additions and 62 deletions

View File

@ -8,7 +8,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import IMKUtils
import InputMethodKit
import SwiftExtension
@ -111,7 +111,7 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
window.center()
window.orderFront(self)
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
@IBAction func agreeAndInstallAction(_: AnyObject) {
@ -179,3 +179,21 @@ class AppDelegate: NSWindowController, NSApplicationDelegate {
return output
}
}
// MARK: - NSApp Activation Helper
// This is to deal with changes brought by macOS 14.
private extension NSApplication {
func popup() {
#if compiler(>=5.9) && canImport(AppKit, _version: "14.0")
if #available(macOS 14.0, *) {
NSApp.activate()
} else {
NSApp.activate(ignoringOtherApps: true)
}
#else
NSApp.activate(ignoringOtherApps: true)
#endif
}
}

View File

@ -8,7 +8,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import InputMethodKit
extension AppDelegate {

View File

@ -5,7 +5,7 @@
// Ref: https://qiita.com/fuziki/items/b31055a69330a3ce55a5
// Modified by The vChewing Project in order to use it with AppKit.
import Cocoa
import AppKit
import CocoaExtension
import SwiftUI

View File

@ -1,7 +1,7 @@
// Ref: https://stackoverflow.com/a/61695824
// License: https://creativecommons.org/licenses/by-sa/4.0/
import Cocoa
import AppKit
public class BookmarkManager {
public static let shared = BookmarkManager()

View File

@ -2,8 +2,8 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import AppKit
import Carbon
import Cocoa
private extension Date {
static func - (lhs: Date, rhs: Date) -> TimeInterval {

View File

@ -99,8 +99,8 @@ private extension EnvironmentValues {
@available(macOS 10.15, *)
@propertyWrapper
internal struct StringlyTypedEnvironment<Value> {
final class Store<Value>: ObservableObject {
var value: Value?
final class Store<StoredValue>: ObservableObject {
var value: StoredValue?
}
@Environment(\.self) private var env

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
extension NSToolbarItem.Identifier {
static let toolbarSegmentedControlItem = Self("toolbarSegmentedControlItem")

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
public extension Settings {
struct PaneIdentifier: Hashable, RawRepresentable, Codable {

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
protocol SettingsStyleController: AnyObject {
var delegate: SettingsStyleControllerDelegate? { get set }

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
final class SettingsTabViewController: NSViewController, SettingsStyleControllerDelegate {
private var activeTab: Int?

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
extension NSWindow.FrameAutosaveName {
static let settings: NSWindow.FrameAutosaveName = "com.sindresorhus.Preferences.FrameAutosaveName"
@ -100,7 +100,15 @@ public final class SettingsWindowController: NSWindowController {
showWindow(self)
restoreWindowPosition()
NSApp.activate(ignoringOtherApps: true)
#if compiler(>=5.9) && canImport(AppKit, _version: "14.0")
if #available(macOS 14.0, *) {
NSApp.activate()
} else {
NSApp.activate(ignoringOtherApps: true)
}
#else
NSApp.activate(ignoringOtherApps: true)
#endif
}
private func restoreWindowPosition() {

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
public extension Settings {
enum Style {

View File

@ -2,7 +2,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
final class ToolbarItemStyleViewController: NSObject, SettingsStyleController {
let toolbar: NSToolbar

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
import SwiftUI
import SwiftUIBackports

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
// MARK: - Using One Single NSAttributedString.

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
open class CtlCandidate: NSWindowController, CtlCandidateProtocol {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
import Shared
import SwiftExtension

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
/// Cocoa SwiftUI

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
import SwiftUI
import SwiftUIBackports

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import XCTest
@testable import CandidateWindow

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import SwiftExtension
// MARK: - NSSize extension
@ -238,3 +238,21 @@ public extension NSApplication {
return machine == "arm64"
}
}
// MARK: - NSApp Activation Helper
// This is to deal with changes brought by macOS 14.
public extension NSApplication {
func popup() {
#if compiler(>=5.9) && canImport(AppKit, _version: "14.0")
if #available(macOS 14.0, *) {
NSApp.activate()
} else {
NSApp.activate(ignoringOtherApps: true)
}
#else
NSApp.activate(ignoringOtherApps: true)
#endif
}
}

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import IMKUtils
// MARK: - NSEvent Extension - Reconstructors

View File

@ -6,8 +6,8 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import AppKit
import AVFoundation
import Cocoa
public extension NSSound {
static func buzz(fart: Bool = false) {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import InputMethodKit
public extension NSWindowController {

View File

@ -2,7 +2,7 @@
// Written by Alexis Bridoux - https://github.com/ABridoux
// Ref: https://gist.github.com/ABridoux/b935c21c7ead92033d39b357fae6366b
import Cocoa
import AppKit
import SwiftUI
// MARK: Model

View File

@ -3,7 +3,7 @@
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
import Cocoa
import AppKit
import XCTest
@testable import Megrez

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
public class Notifier: NSWindowController {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Combine
import Foundation
import LangModelAssembly

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
public extension String {
mutating func convertToPhonabets(newToneOne: String = "") {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
public class PopupCompositionBuffer: NSWindowController {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
public protocol CtlCandidateDelegate {
func candidatePairs(conv: Bool) -> [(keyArray: [String], value: String)]

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import InputMethodKit
// IMEState

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
extension NSEvent: InputSignalProtocol {}

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
import NSAttributedTextView
import Shared

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
public enum Uninstaller {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
public class UpdateSputnik {
public static let shared: UpdateSputnik = .init()
@ -113,7 +113,7 @@ public class UpdateSputnik {
alert.informativeText = NSLocalizedString("You are already using the latest version.", comment: "")
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
return
}
@ -144,7 +144,7 @@ public class UpdateSputnik {
}
let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
switch result {
case .alertFirstButtonReturn:
DispatchQueue.main.async {
@ -172,6 +172,24 @@ public class UpdateSputnik {
alert.informativeText = content
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
}
// MARK: - NSApp Activation Helper
// This is to deal with changes brought by macOS 14.
private extension NSApplication {
func popup() {
#if compiler(>=5.9) && canImport(AppKit, _version: "14.0")
if #available(macOS 14.0, *) {
NSApp.activate()
} else {
NSApp.activate(ignoringOtherApps: true)
}
#else
NSApp.activate(ignoringOtherApps: true)
#endif
}
}

View File

@ -130,7 +130,7 @@ public extension AppDelegate {
}
alert.addButton(withTitle: NSLocalizedString("Not Now", comment: ""))
let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
if result == NSApplication.ModalResponse.alertFirstButtonReturn {
NSWorkspace.shared.openFile(
LMMgr.dataFolderPath(isDefaultFolder: true), withApplication: "Finder"
@ -167,6 +167,6 @@ public extension AppDelegate {
// New About Window
@IBAction func about(_: Any) {
CtlAboutWindow.show()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
}

View File

@ -302,7 +302,7 @@ public extension LMMgr {
alert.informativeText = content
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
return false
}

View File

@ -358,7 +358,7 @@ public extension SessionCtl {
break modeCheck
}
let result = sharedAlertForInputModeToggling.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
if result == NSApplication.ModalResponse.alertFirstButtonReturn {
neta.activate()
}

View File

@ -225,11 +225,11 @@ public extension SessionCtl {
// CtlPrefUIShared.shared.controller.window?.setPosition(vertical: .top, horizontal: .right, padding: 20)
default: CtlPrefUI.show()
}
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
return
}
CtlPrefWindow.show()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
@objc func showCheatSheet(_: Any? = nil) {
@ -241,7 +241,7 @@ public extension SessionCtl {
@objc func showClientListMgr(_: Any? = nil) {
CtlClientListMgr.show()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
@objc func toggleCassetteMode(_: Any? = nil) {
@ -253,7 +253,7 @@ public extension SessionCtl {
let informativeText = "Please reconfigure the cassette path to a valid one before enabling this mode."
alert.informativeText = informativeText.localized
let result = alert.runModal()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
if result == NSApplication.ModalResponse.alertFirstButtonReturn {
LMMgr.resetCassettePath()
PrefMgr.shared.cassetteEnabled = false
@ -367,7 +367,7 @@ public extension SessionCtl {
}
@objc func selfTerminate(_: Any? = nil) {
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
NSApp.terminate(nil)
}
@ -428,6 +428,6 @@ public extension SessionCtl {
@objc func showAbout(_: Any? = nil) {
CtlAboutWindow.show()
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
}

View File

@ -67,7 +67,7 @@ class CtlPrefUI: NSWindowController, NSWindowDelegate {
sharedWindow.orderFrontRegardless() //
sharedWindow.level = .statusBar
shared.showWindow(shared)
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
private var currentLanguageSelectItem: NSMenuItem?

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import Shared
enum PrefUITabs: String, CaseIterable {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
class CtlAboutWindow: NSWindowController {
@IBOutlet var appVersionLabel: NSTextField!
@ -23,7 +23,7 @@ class CtlAboutWindow: NSWindowController {
sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true
shared.showWindow(shared)
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
override func windowDidLoad() {

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewDataSource {
@IBOutlet var tblClients: NSTableView!
@ -24,7 +24,7 @@ class CtlClientListMgr: NSWindowController, NSTableViewDelegate, NSTableViewData
sharedWindow.level = .statusBar
sharedWindow.titlebarAppearsTransparent = true
shared.showWindow(shared)
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
override func windowDidLoad() {

View File

@ -73,7 +73,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
sharedWindow.level = .statusBar
shared.showWindow(shared)
if resetPhraseEditor { shared.initPhraseEditor() }
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
private var currentLanguageSelectItem: NSMenuItem?

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import LangModelAssembly
class CtlRevLookupWindow: NSWindowController, NSWindowDelegate {
@ -22,7 +22,7 @@ class CtlRevLookupWindow: NSWindowController, NSWindowDelegate {
window.level = .statusBar
window.titlebarAppearsTransparent = true
shared.showWindow(shared)
NSApp.activate(ignoringOtherApps: true)
NSApp.popup()
}
}

View File

@ -6,7 +6,7 @@
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import AppKit
import CocoaExtension
import IMKUtils
import InputMethodKit