From 039b9d9a0145b1ee11044f39f2f3245e1bdb4f1a Mon Sep 17 00:00:00 2001 From: Hiraku Date: Mon, 10 Jan 2022 16:23:14 +0800 Subject: [PATCH] New About Window // dev phase 2. Fix an issue that the About window failed from retrieving and presenting specified data fields from info.plist file. --- Source/AppDelegate.m | 2 +- Source/Base.lproj/frmAboutWindow.xib | 3 +++ Source/InputMethodController.mm | 2 +- Source/frmAboutWindow.h | 3 ++- Source/frmAboutWindow.m | 25 ++++++++++++++++++------- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Source/AppDelegate.m b/Source/AppDelegate.m index 5e9369c0..245441c4 100644 --- a/Source/AppDelegate.m +++ b/Source/AppDelegate.m @@ -276,7 +276,7 @@ static const NSTimeInterval kTimeoutInterval = 60.0; - (IBAction) about:(id)sender { // Show the window: - [[frmAboutWindow defaultController].window orderFront:self]; + [[frmAboutWindow defaultController] showWithSender:self]; } @end diff --git a/Source/Base.lproj/frmAboutWindow.xib b/Source/Base.lproj/frmAboutWindow.xib index 50d36558..bef94b49 100644 --- a/Source/Base.lproj/frmAboutWindow.xib +++ b/Source/Base.lproj/frmAboutWindow.xib @@ -8,6 +8,9 @@ + + + diff --git a/Source/InputMethodController.mm b/Source/InputMethodController.mm index 7fa19449..1a985214 100644 --- a/Source/InputMethodController.mm +++ b/Source/InputMethodController.mm @@ -1327,7 +1327,7 @@ static double FindHighestScore(const vector& nodes, double epsilon) - (void)showAbout:(id)sender { - [[frmAboutWindow defaultController].window orderFront:sender]; + [[frmAboutWindow defaultController] showWithSender:sender]; } - (void)toggleChineseConverter:(id)sender diff --git a/Source/frmAboutWindow.h b/Source/frmAboutWindow.h index 3c2c2d73..c667deb0 100644 --- a/Source/frmAboutWindow.h +++ b/Source/frmAboutWindow.h @@ -3,7 +3,7 @@ // Tile Map Editor // // Created & Original Rights by Nicolás Miari on 2016/02/11. -// Patched by Shiki Suen for the vChewing Project. +// Patched by Hiraku Wang and Shiki Suen for the vChewing Project. // Released under MIT License. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -29,6 +29,7 @@ @interface frmAboutWindow : NSWindowController + (instancetype) defaultController; +- (void) showWithSender:(id)sender; @property (nonatomic) IBOutlet NSTextField *appNameLabel; @property (nonatomic) IBOutlet NSTextField *appVersionLabel; diff --git a/Source/frmAboutWindow.m b/Source/frmAboutWindow.m index 4b608a9d..e90a969b 100644 --- a/Source/frmAboutWindow.m +++ b/Source/frmAboutWindow.m @@ -3,7 +3,7 @@ // Tile Map Editor // // Created & Original Rights by Nicolás Miari on 2016/02/11. -// Patched by Shiki Suen for the vChewing Project. +// Patched by Hiraku Wang and Shiki Suen for the vChewing Project. // Released under MIT License. // // Permission is hereby granted, free of charge, to any person obtaining a copy @@ -61,15 +61,26 @@ [super windowDidLoad]; - NSDictionary* infoDictionary = [[NSBundle mainBundle] infoDictionary]; - - self.appNameLabel.stringValue = [infoDictionary objectForKey:@"CFBundleName"]; - self.appVersionLabel.stringValue = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; - self.appCopyrightLabel.stringValue = [infoDictionary objectForKey:@"NSHumanReadableCopyright"]; - self.appEULAContent.string = [infoDictionary objectForKey:@"CFEULAContent"]; + [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]; + NSDictionary* localizedInfoDictionary = [[NSBundle mainBundle] localizedInfoDictionary]; + + self.appNameLabel.stringValue = [localizedInfoDictionary objectForKey:@"CFBundleName"]; + self.appVersionLabel.stringValue = [infoDictionary objectForKey:@"CFBundleShortVersionString"]; + 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