-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NFC] Refactor EZPreferencesWindowController into Swift (#202)
- Loading branch information
Showing
8 changed files
with
66 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
Easydict/Feature/PerferenceWindow/EZPreferencesWindowController.h
This file was deleted.
Oops, something went wrong.
58 changes: 0 additions & 58 deletions
58
Easydict/Feature/PerferenceWindow/EZPreferencesWindowController.m
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
Easydict/Feature/PerferenceWindow/PreferencesWindowController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// PreferencesWindowController.swift | ||
// Easydict | ||
// | ||
// Created by Kyle on 2023/10/28. | ||
// Copyright © 2023 izual. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import MASPreferences | ||
import AppKit | ||
|
||
@objc(EZPreferencesWindowController) | ||
public final class PreferencesWindowController: MASPreferencesWindowController { | ||
|
||
@objc public private(set) var isShowing = false | ||
|
||
@objc public static let shared: PreferencesWindowController = { | ||
let viewControllers = [ | ||
EZSettingViewController(), | ||
EZServiceViewController(), | ||
EZDisableAutoSelectTextViewController(), | ||
EZPrivacyViewController(), | ||
EZAboutViewController(), | ||
] | ||
let appName = (Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String) ?? "" | ||
return PreferencesWindowController(viewControllers: viewControllers, title: appName) | ||
}() | ||
|
||
|
||
@objc public func show() { | ||
isShowing = true | ||
guard let window else { | ||
return | ||
} | ||
window.makeKeyAndOrderFront(nil) | ||
if !window.isKeyWindow { | ||
NSApp.activate(ignoringOtherApps: true) | ||
} | ||
window.center() | ||
} | ||
|
||
public override func windowWillClose(_ notification: Notification) { | ||
isShowing = false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters