2022-01-20 18:27:56 +00:00
|
|
|
// This file Copyright © 2007-2022 Transmission authors and contributors.
|
|
|
|
// It may be used under the MIT (SPDX: MIT) license.
|
|
|
|
// License text can be found in the licenses/ folder.
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2018-09-30 10:37:30 +00:00
|
|
|
#include <libtransmission/version.h>
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2018-09-30 10:37:30 +00:00
|
|
|
#import "AboutWindowController.h"
|
2018-04-17 09:16:18 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
@interface AboutWindowController ()
|
|
|
|
|
|
|
|
@property(nonatomic) IBOutlet NSTextView* fTextView;
|
|
|
|
@property(nonatomic) IBOutlet NSTextView* fLicenseView;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fVersionField;
|
|
|
|
@property(nonatomic) IBOutlet NSTextField* fCopyrightField;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fLicenseButton;
|
|
|
|
@property(nonatomic) IBOutlet NSButton* fLicenseCloseButton;
|
|
|
|
@property(nonatomic) IBOutlet NSPanel* fLicenseSheet;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2007-09-16 01:02:06 +00:00
|
|
|
@implementation AboutWindowController
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
AboutWindowController* fAboutBoxInstance = nil;
|
|
|
|
|
|
|
|
+ (AboutWindowController*)aboutController
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
if (!fAboutBoxInstance)
|
2021-08-15 09:41:48 +00:00
|
|
|
{
|
|
|
|
fAboutBoxInstance = [[self alloc] initWithWindowNibName:@"AboutWindow"];
|
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
return fAboutBoxInstance;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)awakeFromNib
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fVersionField.stringValue = @(LONG_VERSION_STRING);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fCopyrightField.stringValue = [NSBundle.mainBundle localizedStringForKey:@"NSHumanReadableCopyright" value:nil
|
2022-03-30 21:52:23 +00:00
|
|
|
table:@"InfoPlist"];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-06-21 17:25:16 +00:00
|
|
|
NSAttributedString* credits = [[NSAttributedString alloc]
|
|
|
|
initWithURL:[NSBundle.mainBundle URLForResource:@"Credits" withExtension:@"rtf"]
|
|
|
|
options:@{ NSDocumentTypeDocumentAttribute : NSRTFTextDocumentType }
|
|
|
|
documentAttributes:nil
|
|
|
|
error:nil];
|
2022-06-20 19:45:01 +00:00
|
|
|
[self.fTextView.textStorage setAttributedString:credits];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2007-09-24 12:28:44 +00:00
|
|
|
//size license button
|
2022-02-22 16:04:20 +00:00
|
|
|
CGFloat const oldButtonWidth = NSWidth(self.fLicenseButton.frame);
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fLicenseButton.title = NSLocalizedString(@"License", "About window -> license button");
|
|
|
|
[self.fLicenseButton sizeToFit];
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
NSRect buttonFrame = self.fLicenseButton.frame;
|
2009-12-23 02:02:11 +00:00
|
|
|
buttonFrame.size.width += 10.0;
|
|
|
|
buttonFrame.origin.x -= NSWidth(buttonFrame) - oldButtonWidth;
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fLicenseButton.frame = buttonFrame;
|
2007-09-24 12:28:44 +00:00
|
|
|
}
|
2007-09-16 01:02:06 +00:00
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)windowDidLoad
|
2007-09-24 12:28:44 +00:00
|
|
|
{
|
2021-08-07 07:27:56 +00:00
|
|
|
[self.window center];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (void)windowWillClose:(id)sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
|
|
|
fAboutBoxInstance = nil;
|
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (IBAction)showLicense:(id)sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2021-08-15 09:41:48 +00:00
|
|
|
NSString* licenseText = [NSString stringWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"COPYING" ofType:nil]
|
|
|
|
usedEncoding:nil
|
|
|
|
error:NULL];
|
2022-02-22 16:04:20 +00:00
|
|
|
self.fLicenseView.string = licenseText;
|
|
|
|
self.fLicenseCloseButton.title = NSLocalizedString(@"OK", "About window -> license close button");
|
2017-01-24 17:53:16 +00:00
|
|
|
|
2022-02-22 16:04:20 +00:00
|
|
|
[self.window beginSheet:self.fLicenseSheet completionHandler:nil];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
2021-08-15 09:41:48 +00:00
|
|
|
- (IBAction)hideLicense:(id)sender
|
2007-09-16 01:02:06 +00:00
|
|
|
{
|
2019-02-03 04:20:43 +00:00
|
|
|
[self.window endSheet:self.fLicenseSheet];
|
2007-09-16 01:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@end
|