-
Notifications
You must be signed in to change notification settings - Fork 0
/
WelcomeDialog.m
85 lines (69 loc) · 2.57 KB
/
WelcomeDialog.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
* This file is part of nzbget
*
* Copyright (C) 2007-2013 Andrey Prygunkov <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Revision$
* $Date$
*
*/
#import "WelcomeDialog.h"
@implementation WelcomeDialog
- (id)init {
self = [super initWithWindowNibName:@"WelcomeDialog"];
return self;
}
- (void)setMainDelegate:(id)mainDelegate{
_mainDelegate = mainDelegate;
}
- (void)showDialog {
BOOL doNotShowWelcomeDialog = [[NSUserDefaults standardUserDefaults] boolForKey:@"DoNotShowWelcomeDialog"];
if (doNotShowWelcomeDialog) {
[_mainDelegate performSelector:@selector(welcomeContinue)];
return;
}
DLog(@"creating window");
NSWindow *window = [self window];
DLog(@"creating window - END");
// set file icon
NSImage *image = [NSImage imageNamed:@"mainicon.icns"];
[_imageView setImage:image];
// load warning icon
[_badgeView setImage:[[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertNoteIcon)]];
[[_messageText textStorage] readFromURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Welcome" ofType:@"rtf"]] options:nil documentAttributes:nil];
// adjust height of text control and window
[[_messageText layoutManager] ensureLayoutForTextContainer:[_messageText textContainer]];
NSSize scrollSize = [_messageTextScrollView frame].size;
float deltaHeight = [_messageText frame].size.height - scrollSize.height + 6;
if (deltaHeight < 0) {
deltaHeight = 0;
}
NSSize winSize = [[window contentView] frame ].size;
winSize.height += deltaHeight;
[window setContentSize:winSize];
// set active control
[window makeFirstResponder:_okButton];
// show modal dialog
[NSApp activateIgnoringOtherApps:TRUE];
[window center];
[self showWindow:nil];
}
- (IBAction)okButtonPressed:(id)sender {
[self close];
[_mainDelegate performSelector:@selector(welcomeContinue)];
}
@end