New About Window // dev phase 3-7.

- Fix an issue that the IME crashes when the first time the About window loads.
- Make sure the confirm button works even if the NSWindowButtons are not visible. Previously they were disabled, hindering the confirm button from being functional.
- Make sure the About Window always gets pushed to the front every time the user clicks the "about..." menu item.
- Attempt to let the About window dealloc correctly.
This commit is contained in:
ShikiSuen 2022-01-08 00:27:47 +08:00
parent 039b9d9a01
commit 4418440e36
6 changed files with 39 additions and 23 deletions

View File

@ -33,6 +33,7 @@
//
#import <Cocoa/Cocoa.h>
#import "frmAboutWindow.h"
@class PreferencesWindowController;
@ -44,11 +45,13 @@
NSMutableData *_receivingData;
NSURL *_updateNextStepURL;
PreferencesWindowController *_preferencesWindowController;
frmAboutWindow *_aboutWindowController;
}
- (void)checkForUpdate;
- (void)checkForUpdateForced:(BOOL)forced;
- (void)showPreferences;
- (void)showAbout;
@property (weak, nonatomic) IBOutlet NSWindow *window;
@end

View File

@ -55,6 +55,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
- (void)dealloc
{
_preferencesWindowController = nil;
_aboutWindowController = nil;
_updateCheckConnection = nil;
}
@ -274,9 +275,17 @@ static const NSTimeInterval kTimeoutInterval = 60.0;
return YES;
}
- (void)showAbout {
if (!_aboutWindowController) {
_aboutWindowController = [[frmAboutWindow alloc] initWithWindowNibName:@"frmAboutWindow"];
}
[[_aboutWindowController window] center];
[[_aboutWindowController window] orderFrontRegardless];
}
- (IBAction) about:(id)sender {
// Show the window:
[[frmAboutWindow defaultController] showWithSender:self];
[(AppDelegate *)[NSApp delegate] showAbout];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
@end

View File

@ -16,10 +16,12 @@
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window title="About vChewing for macOS" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" tabbingMode="disallowed" titlebarAppearsTransparent="YES" id="ttlAboutWindow">
<windowStyleMask key="styleMask" titled="YES" texturedBackground="YES"/>
<window title="About vChewing for macOS" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" animationBehavior="default" tabbingMode="disallowed" titlebarAppearsTransparent="YES" id="ttlAboutWindow">
<windowStyleMask key="styleMask" titled="YES" closable="YES"/>
<rect key="contentRect" x="196" y="240" width="533" height="430"/>
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1055"/>
<rect key="screenRect" x="0.0" y="0.0" width="1600" height="875"/>
<value key="minSize" type="size" width="533" height="430"/>
<value key="maxSize" type="size" width="533" height="430"/>
<view key="contentView" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="533" height="430"/>
<autoresizingMask key="autoresizingMask"/>
@ -49,16 +51,13 @@
<color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
</textView>
</subviews>
<connections>
<binding destination="CaN-wP-mkf" name="hidden" keyPath="values" id="Vgn-ZH-3hq"/>
</connections>
</clipView>
<scroller key="horizontalScroller" hidden="YES" wantsLayer="YES" verticalHuggingPriority="750" horizontal="YES" id="sfo-oN-iBH">
<rect key="frame" x="-100" y="-100" width="240" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" horizontal="NO" id="X6W-MB-JfO">
<rect key="frame" x="410" y="1" width="16" height="176"/>
<scroller key="verticalScroller" wantsLayer="YES" verticalHuggingPriority="750" controlSize="mini" horizontal="NO" id="X6W-MB-JfO">
<rect key="frame" x="412" y="1" width="14" height="176"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
</scrollView>
@ -67,7 +66,7 @@
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="119" id="eiH-Q0-Ud8"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="clipping" title="vChewing for macOS" id="lblAppTitle">
<textFieldCell key="cell" lineBreakMode="clipping" title="vChewing for macOS" id="lblAppTitle" userLabel="appNameLabel">
<font key="font" metaFont="cellTitle"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
@ -103,7 +102,8 @@
<textFieldCell key="cell" selectable="YES" id="lblCredits">
<font key="font" metaFont="cellTitle"/>
<string key="title">McBopomofo Engine by Mengjuei Hsieh, Lukhnos Liu, Zonble Yang, et al.
vChewing macOS Development Reinforced by Hiraku Wang.vChewing Phrase Database Maintained by Shiki Suen.</string>
vChewing macOS Development Reinforced by Hiraku Wang.
vChewing Phrase Database Maintained by Shiki Suen.</string>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -131,6 +131,9 @@ vChewing macOS Development Reinforced by Hiraku Wang.vChewing Phrase Database
DQ
</string>
</buttonCell>
<connections>
<action selector="performClose:" target="-1" id="0yK-v8-KQd"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="d81-Fe-uNT">
<rect key="frame" x="13" y="21" width="379" height="83"/>

View File

@ -38,6 +38,7 @@
#import "Gramambular.h"
#import "FastLM.h"
#import "UserOverrideModel.h"
#import "frmAboutWindow.h"
@interface vChewingInputMethodController : IMKInputController
{

View File

@ -39,7 +39,6 @@
#import "OVStringHelper.h"
#import "OVUTF8Helper.h"
#import "AppDelegate.h"
#import "frmAboutWindow.h"
#import "VTHorizontalCandidateController.h"
#import "VTVerticalCandidateController.h"
#import "vChewing-Swift.h"
@ -1327,7 +1326,9 @@ static double FindHighestScore(const vector<NodeAnchor>& nodes, double epsilon)
- (void)showAbout:(id)sender
{
[[frmAboutWindow defaultController] showWithSender:sender];
// show the About window, and also make the IME app itself the focus
[(AppDelegate *)[NSApp delegate] showAbout];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
- (void)toggleChineseConverter:(id)sender

View File

@ -60,27 +60,26 @@
- (void) windowDidLoad {
[super windowDidLoad];
[self.window standardWindowButton:NSWindowCloseButton].hidden = true;
[self.window standardWindowButton:NSWindowMiniaturizeButton].hidden = true;
[self.window standardWindowButton:NSWindowZoomButton].hidden = true;
[self updateInfo];
// If you add more custom subviews to display additional information about
// your app, configure them here
}
- (void) updateInfo {
NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary];
NSString *installingVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:(id)kCFBundleVersionKey];
NSString *versionString = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
NSDictionary* localizedInfoDictionary = [[NSBundle mainBundle] localizedInfoDictionary];
self.appNameLabel.stringValue = [localizedInfoDictionary objectForKey:@"CFBundleName"];
self.appVersionLabel.stringValue = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
self.appVersionLabel.stringValue = [NSString stringWithFormat:@"%@ Build %@", versionString, installingVersion];
self.appCopyrightLabel.stringValue = [localizedInfoDictionary objectForKey:@"NSHumanReadableCopyright"];
self.appEULAContent.string = [localizedInfoDictionary objectForKey:@"CFEULAContent"];
}
- (void) showWithSender:(id)sender {
// FIXME: updating the strings every time is a temporary workaround
[self updateInfo];
[self.window orderFront:sender];
}
@end