ctlIME // Add CheatSheet window.

This commit is contained in:
ShikiSuen 2022-08-25 19:30:12 +08:00
parent 781fee7b12
commit 006f4cccc9
10 changed files with 117 additions and 1 deletions

View File

@ -29,6 +29,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
@IBOutlet var window: NSWindow?
private var ctlPrefWindowInstance: ctlPrefWindow?
private var ctlAboutWindowInstance: ctlAboutWindow? // New About Window
private var WebWindowInstance: Any?
private var checkTask: URLSessionTask?
private var updateNextStepURL: URL?
public var fsStreamHelper = FSEventStreamHelper(
@ -97,6 +98,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, ctlNonModalAlertWindowDelega
NSApp.setActivationPolicy(.accessory)
}
func showCheatSheet() {
if #available(macOS 10.13, *) {
WebWindowInstance = ctlWebWindow.init(windowNibName: "frmWebWindow")
guard let WebWindowInstance = WebWindowInstance as? ctlWebWindow else { return }
guard let theWindow = WebWindowInstance.window else { return }
theWindow.center()
theWindow.orderFrontRegardless() //
theWindow.level = .statusBar
theWindow.titlebarAppearsTransparent = true
theWindow.title = NSLocalizedString("CheatSheet", comment: "")
return
}
guard let url = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return }
NSWorkspace.shared.openFile(url.path, withApplication: "Safari")
}
// New About Window
func showAbout() {
if ctlAboutWindowInstance == nil {

View File

@ -169,6 +169,10 @@ extension ctlInputMethod {
withTitle: NSLocalizedString("About vChewing…", comment: ""),
action: #selector(showAbout(_:)), keyEquivalent: ""
)
menu.addItem(
withTitle: NSLocalizedString("CheatSheet", comment: "") + "",
action: #selector(showCheatSheet(_:)), keyEquivalent: ""
)
if optionKeyPressed {
menu.addItem(
withTitle: NSLocalizedString("Uninstall vChewing…", comment: ""),
@ -199,7 +203,12 @@ extension ctlInputMethod {
NSApp.activate(ignoringOtherApps: true)
}
@objc func toggleSCPCTypingMode(_: Any?) {
@objc func showCheatSheet(_: Any?) {
(NSApp.delegate as? AppDelegate)?.showCheatSheet()
NSApp.activate(ignoringOtherApps: true)
}
@objc func toggleSCPCTypingMode(_: Any? = nil) {
resetKeyHandler()
NotifierController.notify(
message: String(

View File

@ -2,6 +2,7 @@
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability." = "vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.";
"About vChewing…" = "About vChewing…";
"vChewing Preferences…" = "vChewing Preferences…";
"CheatSheet" = "CheatSheet";
"Uninstallation" = "Uninstallation";
"Uninstall vChewing…" = "Uninstall vChewing…";
"This will remove vChewing Input Method from this user account, requiring your confirmation." = "This will remove vChewing Input Method from this user account, requiring your confirmation.";

View File

@ -2,6 +2,7 @@
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability." = "vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability.";
"About vChewing…" = "About vChewing…";
"vChewing Preferences…" = "vChewing Preferences…";
"CheatSheet" = "CheatSheet";
"Uninstallation" = "Uninstallation";
"Uninstall vChewing…" = "Uninstall vChewing…";
"This will remove vChewing Input Method from this user account, requiring your confirmation." = "This will remove vChewing Input Method from this user account, requiring your confirmation.";

View File

@ -3,6 +3,7 @@
"About vChewing…" = "威注音について…";
"vChewing Preferences…" = "入力機能設定…";
"Uninstallation" = "入力アプリの卸除(おろしのぞき)";
"CheatSheet" = "取扱説明";
"Uninstall vChewing…" = "入力アプリを卸除く…";
"This will remove vChewing Input Method from this user account, requiring your confirmation." = "これにて威注音入力アプリをこのアカウントから卸除しますが、宜しいですか。";
"Check Later" = "後でやる";

View File

@ -2,6 +2,7 @@
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability." = "威注音输入法的使用者半衰记忆模组在观测时崩溃,相关半衰记忆资料档案内容已全部清空。";
"About vChewing…" = "关于威注音…";
"vChewing Preferences…" = "威注音偏好设定…";
"CheatSheet" = "热键指南";
"Uninstallation" = "卸除输入法";
"Uninstall vChewing…" = "卸除威注音…";
"This will remove vChewing Input Method from this user account, requiring your confirmation." = "此举会将威注音自当前系统使用者帐户卸除。请确认。";

View File

@ -2,6 +2,7 @@
"vChewing crashed while handling previously loaded UOM observation data. These data files are cleaned now to ensure the usability." = "威注音輸入法的使用者半衰記憶模組在觀測時崩潰,相關半衰記憶資料檔案內容已全部清空。";
"About vChewing…" = "關於威注音…";
"vChewing Preferences…" = "威注音偏好設定…";
"CheatSheet" = "熱鍵指南";
"Uninstallation" = "卸除輸入法";
"Uninstall vChewing…" = "卸除威注音…";
"This will remove vChewing Input Method from this user account, requiring your confirmation." = "此舉會將威注音自當前系統使用者帳戶卸除。請確認。";

View File

@ -0,0 +1,21 @@
// Copyright (c) 2021 and onwards The vChewing Project (MIT-NTL License).
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// ... with NTL restriction stating that:
// No trademark license is granted to use the trade names, trademarks, service
// marks, or product names of Contributor, except as required to fulfill notice
// requirements defined in MIT License.
import Cocoa
import WebKit
@available(macOS 10.13, *)
class ctlWebWindow: NSWindowController, WKUIDelegate {
@IBOutlet var webView: WKWebView!
override func windowDidLoad() {
super.windowDidLoad()
guard let webPageURL = Bundle.main.url(forResource: "shortcuts", withExtension: "html") else { return }
webView.loadFileURL(webPageURL, allowingReadAccessTo: webPageURL)
}
}

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21223" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment version="101300" identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21223"/>
<plugIn identifier="com.apple.WebKit2IBPlugin" version="21223"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="_TtC8vChewing28_TtC8vChewing13frmWebWindow" customModule="vChewing" customModuleProvider="target">
<connections>
<outlet property="webView" destination="7DH-xo-f3c" id="qft-2P-MFO"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="CheatSheet" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" titlebarAppearsTransparent="YES" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" fullSizeContentView="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="196" y="240" width="960" height="600"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<view key="contentView" id="se5-gp-TjO" customClass="NSVisualEffectView" customModule="vChewing" customModuleProvider="target">
<rect key="frame" x="0.0" y="0.0" width="960" height="600"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<wkWebView wantsLayer="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7DH-xo-f3c">
<rect key="frame" x="20" y="20" width="920" height="544"/>
<wkWebViewConfiguration key="configuration" allowsAirPlayForMediaPlayback="NO">
<audiovisualMediaTypes key="mediaTypesRequiringUserActionForPlayback" none="YES"/>
<wkPreferences key="preferences" javaScriptCanOpenWindowsAutomatically="NO" javaScriptEnabled="NO"/>
</wkWebViewConfiguration>
</wkWebView>
</subviews>
<constraints>
<constraint firstItem="7DH-xo-f3c" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" constant="36" id="AT9-7E-nxL"/>
<constraint firstAttribute="bottom" secondItem="7DH-xo-f3c" secondAttribute="bottom" constant="20" symbolic="YES" id="IXb-dn-jPA"/>
<constraint firstItem="7DH-xo-f3c" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" constant="20" symbolic="YES" id="U3r-hM-64J"/>
<constraint firstAttribute="trailing" secondItem="7DH-xo-f3c" secondAttribute="trailing" constant="20" symbolic="YES" id="h7o-7F-AlR"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
<point key="canvasLocation" x="206" y="123"/>
</window>
</objects>
</document>

View File

@ -27,6 +27,8 @@
5B3A87BC28597CDB0090E163 /* LMSymbolNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B3A87BB28597CDB0090E163 /* LMSymbolNode.swift */; };
5B40730C281672610023DFFF /* lmAssociates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B407309281672610023DFFF /* lmAssociates.swift */; };
5B40730D281672610023DFFF /* lmReplacements.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B40730A281672610023DFFF /* lmReplacements.swift */; };
5B46794728B790A600941452 /* frmWebWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 5B46794528B790A600941452 /* frmWebWindow.xib */; };
5B46794928B790B900941452 /* ctlWebWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B46794828B790B900941452 /* ctlWebWindow.swift */; };
5B54E743283A7D89001ECBDC /* lmCoreNS.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B54E742283A7D89001ECBDC /* lmCoreNS.swift */; };
5B5948CE289CC04500C85824 /* LMInstantiator_DateTimeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5948CD289CC04500C85824 /* LMInstantiator_DateTimeExtension.swift */; };
5B5E535227EF261400C6AA1E /* IME.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B5E535127EF261400C6AA1E /* IME.swift */; };
@ -238,6 +240,8 @@
5B3A87BB28597CDB0090E163 /* LMSymbolNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LMSymbolNode.swift; sourceTree = "<group>"; };
5B407309281672610023DFFF /* lmAssociates.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; lineEnding = 0; path = lmAssociates.swift; sourceTree = "<group>"; usesTabs = 0; };
5B40730A281672610023DFFF /* lmReplacements.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; lineEnding = 0; path = lmReplacements.swift; sourceTree = "<group>"; usesTabs = 0; };
5B46794628B790A600941452 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/frmWebWindow.xib; sourceTree = "<group>"; };
5B46794828B790B900941452 /* ctlWebWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ctlWebWindow.swift; sourceTree = "<group>"; };
5B54E742283A7D89001ECBDC /* lmCoreNS.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = lmCoreNS.swift; sourceTree = "<group>"; };
5B5948CD289CC04500C85824 /* LMInstantiator_DateTimeExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LMInstantiator_DateTimeExtension.swift; sourceTree = "<group>"; };
5B5E535127EF261400C6AA1E /* IME.swift */ = {isa = PBXFileReference; explicitFileType = sourcecode.swift; fileEncoding = 4; indentWidth = 2; lineEnding = 0; path = IME.swift; sourceTree = "<group>"; tabWidth = 2; usesTabs = 0; };
@ -571,6 +575,7 @@
5B62A33C27AE7CC100A19448 /* ctlAboutWindow.swift */,
D47F7DCF278C0897002F9DD7 /* ctlNonModalAlertWindow.swift */,
D47F7DCD278BFB57002F9DD7 /* ctlPrefWindow.swift */,
5B46794828B790B900941452 /* ctlWebWindow.swift */,
);
path = WindowControllers;
sourceTree = "<group>";
@ -581,6 +586,7 @@
5BBBB76927AED5DB0023B93A /* frmAboutWindow.xib */,
5BBBB76527AED5DB0023B93A /* frmNonModalAlertWindow.xib */,
5B7BC4AE27AFFBE800F66C24 /* frmPrefWindow.xib */,
5B46794528B790A600941452 /* frmWebWindow.xib */,
6A187E2816004C5900466B2E /* MainMenu.xib */,
);
path = WindowNIBs;
@ -1045,6 +1051,7 @@
5BBBB77427AED70B0023B93A /* MenuIcon-SCVIM@2x.png in Resources */,
D4E33D8A27A838CF006DB1CF /* Localizable.strings in Resources */,
5BF9DA2828840E6200DBD48E /* template-exclusions.txt in Resources */,
5B46794728B790A600941452 /* frmWebWindow.xib in Resources */,
5BDCBB2E27B4E67A00D0CC59 /* vChewingPhraseEditor.app in Resources */,
5BBBB76027AED54C0023B93A /* Fart.m4a in Resources */,
6A2E40F6253A69DA00D1AE1D /* Images.xcassets in Resources */,
@ -1205,6 +1212,7 @@
5B2170E1289FACAD00BE7304 /* 0_Megrez.swift in Sources */,
5BF9EC1628A2BFC600333639 /* lmPlainBopomofo.swift in Sources */,
5B3A87BC28597CDB0090E163 /* LMSymbolNode.swift in Sources */,
5B46794928B790B900941452 /* ctlWebWindow.swift in Sources */,
5BA9FD4327FEF3C8002DE248 /* Preferences.swift in Sources */,
5BA9FD4427FEF3C8002DE248 /* SegmentedControlStyleViewController.swift in Sources */,
5B78EE0D28A562B4009456C1 /* suiPrefPaneDevZone.swift in Sources */,
@ -1299,6 +1307,14 @@
name = shortcuts.html;
sourceTree = "<group>";
};
5B46794528B790A600941452 /* frmWebWindow.xib */ = {
isa = PBXVariantGroup;
children = (
5B46794628B790A600941452 /* Base */,
);
name = frmWebWindow.xib;
sourceTree = "<group>";
};
5B73FB6027B2BE1300E9BF49 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (