Files
ReiKey/shared/AboutWindowController.m
Patrick Wardle 81f354320d version 1.0.0 checkin
added installer
improved icon (fixes #6)
added quit option to login item menu (fixes #4)
improved preference handling (fixes #3)
now ignore alerts from same process
2019-01-03 14:50:47 -10:00

103 lines
2.4 KiB
Objective-C

//
// AboutWindowController.m
// ReiKey
//
// Created by Patrick Wardle on 12/24/18.
// Copyright © 2018 Objective-See. All rights reserved.
//
#import "consts.h"
#import "utilities.h"
#import "AboutWindowController.h"
@implementation AboutWindowController
@synthesize patrons;
@synthesize versionLabel;
//automatically called when nib is loaded
// ->center window
-(void)awakeFromNib
{
//center
[self.window center];
}
//automatically invoked when window is loaded
// set to window to white, set app version, patrons, etc
-(void)windowDidLoad
{
//version
NSString* version = nil;
//super
[super windowDidLoad];
//not in dark mode?
// make window white
if(YES != isDarkMode())
{
//make white
self.window.backgroundColor = NSColor.whiteColor;
}
//grab app version
version = getAppVersion();
if(nil == version)
{
//default
version = @"unknown";
}
//set version sting
self.versionLabel.stringValue = version;
//load patrons
// <3 you guys & girls
self.patrons.string = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"patrons" ofType:@"txt"] encoding:NSUTF8StringEncoding error:NULL];
if(nil == self.patrons.string)
{
//default
self.patrons.string = @"error: failed to load patrons :/";
}
//make 'Support Us' button first responder
[self.window makeFirstResponder:[self.window.contentView viewWithTag:BUTTON_SUPPORT_US]];
return;
}
//automatically invoked when window is closing
// ->make window unmodal
-(void)windowWillClose:(NSNotification *)notification
{
//make un-modal
[[NSApplication sharedApplication] stopModal];
return;
}
//automatically invoked when user clicks any of the buttons
// ->perform actions, such as loading patreon or products URL
-(IBAction)buttonHandler:(id)sender
{
//support us button
if(((NSButton*)sender).tag == BUTTON_SUPPORT_US)
{
//open URL
// ->invokes user's default browser
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PATREON_URL]];
}
//more info button
else if(((NSButton*)sender).tag == BUTTON_MORE_INFO)
{
//open URL
// ->invokes user's default browser
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:PRODUCT_URL]];
}
return;
}
@end