Skip to content

Commit 37b581f

Browse files
committed
persistence
1 parent edc2ce5 commit 37b581f

File tree

5 files changed

+69
-45
lines changed

5 files changed

+69
-45
lines changed

AppDelegate.m

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,17 @@ -(void)applicationDidFinishLaunching:(NSNotification *)notification
9292
else
9393
{
9494
//started via login item?
95-
NSAppleEventDescriptor* event = NSAppleEventManager.sharedAppleEventManager.currentAppleEvent;
96-
if (event) {
97-
NSAppleEventDescriptor* descriptor = [event paramDescriptorForKeyword:keyAELaunchedAsLogInItem];
98-
if (descriptor && [descriptor booleanValue]) {
99-
startScan = YES;
95+
NSAppleEventDescriptor *event =
96+
NSAppleEventManager.sharedAppleEventManager.currentAppleEvent;
97+
98+
if (event && event.eventID == kAEOpenApplication) {
99+
NSAppleEventDescriptor *prop =
100+
[event paramDescriptorForKeyword:keyAEPropData];
101+
102+
if (prop && prop.enumCodeValue == keyAELaunchedAsLogInItem) {
103+
startScan = YES;
104+
}
100105
}
101-
}
102106

103107
//init
104108
[self initializeForScan:startScan];

PrefsWindowController.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@
2525

2626
//buttons
2727

28-
//button for filtering out OS componets
28+
//button: filtering out OS componets
2929
@property (weak) IBOutlet NSButton* showTrustedItemsBtn;
3030

31-
//button disabling update check
32-
@property (weak) IBOutlet NSButton *disableUpdateCheckBtn;
31+
//button: start at login
32+
@property (weak) IBOutlet NSButton* startAtLoginBtn;
3333

34-
//button for disabling talking to VT
35-
@property (weak) IBOutlet NSButton* disableVTQueriesBtn;
34+
//button: disable update check
35+
@property (weak) IBOutlet NSButton* disableUpdateCheckBtn;
3636

37-
//button for saving output
38-
@property (weak) IBOutlet NSButton* saveOutputBtn;
37+
//button: disable VT checks (hash)
38+
@property (weak) IBOutlet NSButton* disableVTQueriesBtn;
3939

4040
//button for ok/close
4141
@property (weak) IBOutlet NSButton *okButton;
@@ -55,13 +55,13 @@
5555
//disable talking to VT
5656
@property BOOL disableVTQueries;
5757

58-
//save results (at end of scan)
59-
@property BOOL saveOutput;
60-
58+
//VT API key
6159
@property (weak) IBOutlet NSTextField* apiTextField;
6260

61+
//how to get a VT key
6362
@property (strong) IBOutlet NSView* getAPIHelp;
6463

64+
//link (how to get a VT key)
6565
@property (weak) IBOutlet HyperlinkTextField* getAPILink;
6666

6767
/* METHODS */

PrefsWindowController.m

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
@implementation PrefsWindowController
1515

1616
@synthesize okButton;
17-
@synthesize saveOutput;
1817
@synthesize disableVTQueries;
1918
@synthesize showTrustedItems;
2019
@synthesize disableUpdateCheck;
@@ -50,40 +49,40 @@ -(void)windowDidLoad
5049
if(YES == self.showTrustedItems)
5150
{
5251
//set
53-
self.showTrustedItemsBtn.state = STATE_ENABLED;
52+
self.showTrustedItemsBtn.state = NSControlStateValueOn;
5453
}
5554

5655
//TODO: add start at load
5756

57+
//check if 'show trusted items' button should be selected
58+
if(YES == self.startAtLogin)
59+
{
60+
//set
61+
self.startAtLoginBtn.state = NSControlStateValueOn;
62+
}
63+
5864
//check if 'disable update check' button should be selected
5965
if(YES == self.disableUpdateCheck)
6066
{
6167
//set
62-
self.disableUpdateCheckBtn.state = STATE_ENABLED;
68+
self.disableUpdateCheckBtn.state = NSControlStateValueOn;
6369
}
6470

6571
//check if 'disable vt queries' button should be selected
6672
if(YES == self.disableVTQueries)
6773
{
6874
//set
69-
self.disableVTQueriesBtn.state = STATE_ENABLED;
70-
}
71-
72-
//check if 'save output' button should be selected
73-
if(YES == self.saveOutput)
74-
{
75-
//set
76-
self.saveOutputBtn.state = STATE_ENABLED;
75+
self.disableVTQueriesBtn.state = NSControlStateValueOn;
7776
}
7877

7978
//VT API key
8079
if(0 != self.vtAPIKey.length) {
81-
80+
81+
//set
8282
self.apiTextField.stringValue = self.vtAPIKey;
8383
}
8484

85-
86-
85+
8786
return;
8887
}
8988

@@ -173,18 +172,18 @@ -(void)savePrefs
173172
//init
174173
defaults = [NSUserDefaults standardUserDefaults];
175174

176-
//save hiding OS components flag
175+
//grab 'include macOS/known items'
177176
self.showTrustedItems = self.showTrustedItemsBtn.state;
178177

179-
//save current state of 'disable update checks'
178+
//grab 'start at login' state
179+
self.startAtLogin = self.startAtLoginBtn.state;
180+
181+
//grab 'disable update checks' state
180182
self.disableUpdateCheck = self.disableUpdateCheckBtn.state;
181183

182-
//save disabling VT flag
184+
//grab: disable VT state
183185
self.disableVTQueries = self.disableVTQueriesBtn.state;
184186

185-
//save save output flag
186-
self.saveOutput = self.saveOutputBtn.state;
187-
188187
//grab API key
189188
self.vtAPIKey = self.apiTextField.stringValue;
190189

UI/Base.lproj/PrefsWindow.xib

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<outlet property="getAPILink" destination="Jd6-fc-ZcX" id="8os-j9-kOf"/>
1616
<outlet property="okButton" destination="HZZ-Es-mpy" id="GKU-Jc-ENB"/>
1717
<outlet property="showTrustedItemsBtn" destination="4xV-kQ-iaT" id="aEg-d4-Orl"/>
18+
<outlet property="startAtLoginBtn" destination="CtF-8L-7w6" id="gNH-bY-m8A"/>
1819
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
1920
</connections>
2021
</customObject>
@@ -28,16 +29,8 @@
2829
<rect key="frame" x="0.0" y="0.0" width="565" height="310"/>
2930
<autoresizingMask key="autoresizingMask"/>
3031
<subviews>
31-
<button focusRingType="none" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4xV-kQ-iaT">
32-
<rect key="frame" x="20" y="226" width="379" height="48"/>
33-
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
34-
<buttonCell key="cell" type="check" title="Include macOS/known items." bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="WN8-cQ-8xh">
35-
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
36-
<font key="font" size="13" name="Menlo-Regular"/>
37-
</buttonCell>
38-
</button>
3932
<button focusRingType="none" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dJU-Ok-N6U">
40-
<rect key="frame" x="20" y="181" width="379" height="48"/>
33+
<rect key="frame" x="20" y="174" width="379" height="24"/>
4134
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
4235
<buttonCell key="cell" type="check" title="Disable automatic update check." bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="idJ-pd-k6U">
4336
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -110,6 +103,22 @@
110103
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
111104
</textFieldCell>
112105
</textField>
106+
<button focusRingType="none" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="4xV-kQ-iaT">
107+
<rect key="frame" x="20" y="235" width="379" height="24"/>
108+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
109+
<buttonCell key="cell" type="check" title="Include macOS/known items." bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="WN8-cQ-8xh">
110+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
111+
<font key="font" size="13" name="Menlo-Regular"/>
112+
</buttonCell>
113+
</button>
114+
<button focusRingType="none" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="CtF-8L-7w6">
115+
<rect key="frame" x="20" y="204" width="379" height="24"/>
116+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
117+
<buttonCell key="cell" type="check" title="Start at login (+perform scan)." bezelStyle="regularSquare" imagePosition="left" focusRingType="none" inset="2" id="7e0-cR-939">
118+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
119+
<font key="font" size="13" name="Menlo-Regular"/>
120+
</buttonCell>
121+
</button>
113122
</subviews>
114123
</view>
115124
<connections>

UI/mul.lproj/PrefsWindow.xcstrings

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"sourceLanguage" : "en",
33
"strings" : {
4+
"7e0-cR-939.title" : {
5+
"comment" : "Class = \"NSButtonCell\"; title = \"Start at login (+perform scan).\"; ObjectID = \"7e0-cR-939\";",
6+
"extractionState" : "extracted_with_value",
7+
"localizations" : {
8+
"en" : {
9+
"stringUnit" : {
10+
"state" : "new",
11+
"value" : "Start at login (+perform scan)."
12+
}
13+
}
14+
}
15+
},
416
"CMD-Kc-WiI.title" : {
517
"comment" : "Class = \"NSTextFieldCell\"; title = \"API Key:\"; ObjectID = \"CMD-Kc-WiI\";",
618
"extractionState" : "extracted_with_value",

0 commit comments

Comments
 (0)