Skip to content
This repository has been archived by the owner on May 2, 2021. It is now read-only.

Commit

Permalink
add pref whether interact with web page when launches
Browse files Browse the repository at this point in the history
  • Loading branch information
Tae Won Ha committed Apr 5, 2014
1 parent 476afb7 commit fdd0149
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 16 deletions.
1 change: 1 addition & 0 deletions Qdesktop/QDAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@property (weak) IBOutlet NSTextField *urlField;
@property (weak) IBOutlet NSTextField *intervalTextField;
@property (weak) IBOutlet NSButton *regularReloadCheckbox;
@property (weak) IBOutlet NSButton *interactWhenLaunchesCheckbox;

#pragma mark IBActions
- (IBAction)toggleBackground:(id)sender;
Expand Down
25 changes: 22 additions & 3 deletions Qdesktop/QDAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
static NSString *const qDefaultReloadRegularlyKey = @"update-regularly";
static NSString *const qDefaultIntervalKey = @"interval";
static const int qDefaultIntervalValue = 15;
static NSString *const qDefaultInteractWhenLaunchesKey = @"interact-when-launches";
static const BOOL qDefaultInteractWhenLaunchesValue = NO;

@interface QDAppDelegate ()

Expand All @@ -25,6 +27,7 @@ @interface QDAppDelegate ()
@property BOOL reloadRegularly;
@property NSInteger interval;
@property NSTimer *timer;
@property BOOL interactWhenLaunches;

@end

Expand Down Expand Up @@ -103,9 +106,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[self resetTimer];

#ifndef DEBUG
[self toggleBackground:self];
#endif
if (!self.interactWhenLaunches) {
[self toggleBackground:self];
}
}

#pragma mark Private
Expand Down Expand Up @@ -137,12 +140,17 @@ - (void)setDefaultsIfNecessary {
if ([self.userDefaults objectForKey:qDefaultIntervalKey] == nil) {
[self.userDefaults setInteger:qDefaultIntervalValue forKey:qDefaultIntervalKey];
}

if ([self.userDefaults objectForKey:qDefaultInteractWhenLaunchesKey] == nil) {
[self.userDefaults setBool:qDefaultInteractWhenLaunchesValue forKey:qDefaultInteractWhenLaunchesKey];
}
}

- (void)readDefaults {
self.url = [NSURL URLWithString:[self.userDefaults objectForKey:qDefaultUrlKey]];
self.reloadRegularly = [self.userDefaults boolForKey:qDefaultReloadRegularlyKey];
self.interval = [self.userDefaults integerForKey:qDefaultIntervalKey];
self.interactWhenLaunches = [self.userDefaults boolForKey:qDefaultInteractWhenLaunchesKey];
}

- (void)storeNewDefaults {
Expand All @@ -157,6 +165,12 @@ - (void)storeNewDefaults {

self.interval = self.intervalTextField.integerValue;
[self.userDefaults setInteger:self.interval forKey:qDefaultIntervalKey];

self.interactWhenLaunches = NO;
if (self.interactWhenLaunchesCheckbox.state == NSOnState) {
self.interactWhenLaunches = YES;
}
[self.userDefaults setBool:self.interactWhenLaunches forKey:qDefaultInteractWhenLaunchesKey];
}

- (void)syncPrefsUiElements {
Expand All @@ -168,6 +182,11 @@ - (void)syncPrefsUiElements {
}

self.intervalTextField.integerValue = self.interval;

self.interactWhenLaunchesCheckbox.state = NSOffState;
if (self.interactWhenLaunches) {
self.interactWhenLaunchesCheckbox.state = NSOnState;
}
}

- (void)resetTimer {
Expand Down
54 changes: 41 additions & 13 deletions Qdesktop/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
</menu>
<customObject id="494" customClass="QDAppDelegate">
<connections>
<outlet property="interactWhenLaunchesCheckbox" destination="5uC-rY-o3C" id="JtP-lJ-uf2"/>
<outlet property="intervalTextField" destination="743" id="762"/>
<outlet property="regularReloadCheckbox" destination="644" id="741"/>
<outlet property="statusMenu" destination="557" id="569"/>
Expand Down Expand Up @@ -420,10 +421,22 @@
</window>
<menu id="557">
<items>
<menuItem title="Toggle Background" id="568">
<menuItem title="Interact With Web Page" id="568">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleBackground:" target="494" id="612"/>
<binding destination="494" name="enabled" keyPath="self.window.background" id="dFf-0E-ABC"/>
</connections>
</menuItem>
<menuItem title="Enter Background Mode" id="h3M-NP-mSF">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="toggleBackground:" target="494" id="ajF-Ri-o4h"/>
<binding destination="494" name="enabled" keyPath="self.window.background" id="sGo-4a-dA8">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="587"/>
Expand Down Expand Up @@ -483,16 +496,16 @@
</menu>
<window title="Load URL" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="592">
<windowStyleMask key="styleMask" titled="YES" resizable="YES"/>
<rect key="contentRect" x="196" y="240" width="489" height="138"/>
<rect key="contentRect" x="196" y="240" width="489" height="161"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
<value key="minSize" type="size" width="300" height="121"/>
<value key="maxSize" type="size" width="1280" height="121"/>
<view key="contentView" id="593">
<rect key="frame" x="0.0" y="0.0" width="489" height="138"/>
<rect key="frame" x="0.0" y="0.0" width="489" height="161"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="594">
<rect key="frame" x="18" y="101" width="28" height="14"/>
<rect key="frame" x="18" y="124" width="28" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="URL:" id="595">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -501,7 +514,7 @@
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="596">
<rect key="frame" x="52" y="99" width="417" height="19"/>
<rect key="frame" x="52" y="122" width="417" height="19"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="597">
<font key="font" metaFont="smallSystem"/>
Expand Down Expand Up @@ -544,7 +557,7 @@ Gw
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="644">
<rect key="frame" x="49" y="72" width="135" height="18"/>
<rect key="frame" x="49" y="95" width="135" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Reload the URL every" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="645">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -554,8 +567,19 @@ Gw
<action selector="toggleRegularReload:" target="494" id="742"/>
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="5uC-rY-o3C">
<rect key="frame" x="49" y="72" width="422" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="When Qdesktop launches, interact with web page" bezelStyle="regularSquare" imagePosition="left" controlSize="small" inset="2" id="rU6-xm-zeQ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
<connections>
<action selector="toggleRegularReload:" target="494" id="kEP-jl-7Vd"/>
</connections>
</button>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="684">
<rect key="frame" x="248" y="74" width="47" height="14"/>
<rect key="frame" x="248" y="97" width="47" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="minutes" id="685">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -564,7 +588,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="743">
<rect key="frame" x="190" y="72" width="52" height="19"/>
<rect key="frame" x="190" y="95" width="52" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<constraints>
<constraint firstAttribute="width" constant="52" id="750"/>
Expand Down Expand Up @@ -610,18 +634,22 @@ Gw
<constraint firstItem="743" firstAttribute="top" secondItem="596" secondAttribute="bottom" constant="8" symbolic="YES" id="772"/>
<constraint firstItem="644" firstAttribute="baseline" secondItem="743" secondAttribute="baseline" id="773"/>
<constraint firstItem="684" firstAttribute="baseline" secondItem="743" secondAttribute="baseline" id="774"/>
<constraint firstItem="775" firstAttribute="top" secondItem="644" secondAttribute="bottom" constant="8" symbolic="YES" id="777"/>
<constraint firstItem="775" firstAttribute="leading" secondItem="594" secondAttribute="leading" id="780"/>
<constraint firstItem="781" firstAttribute="top" secondItem="775" secondAttribute="bottom" constant="8" symbolic="YES" id="795"/>
<constraint firstItem="781" firstAttribute="leading" secondItem="644" secondAttribute="leading" id="796"/>
<constraint firstItem="599" firstAttribute="trailing" secondItem="775" secondAttribute="trailing" id="803"/>
<constraint firstAttribute="trailing" secondItem="599" secondAttribute="trailing" constant="20" symbolic="YES" id="804"/>
<constraint firstItem="599" firstAttribute="leading" secondItem="601" secondAttribute="trailing" constant="8" symbolic="YES" id="805"/>
<constraint firstAttribute="bottom" secondItem="599" secondAttribute="bottom" constant="20" symbolic="YES" id="806"/>
<constraint firstAttribute="bottom" secondItem="601" secondAttribute="bottom" constant="20" symbolic="YES" id="807"/>
<constraint firstItem="775" firstAttribute="trailing" secondItem="599" secondAttribute="trailing" id="HYQ-Cm-H4n"/>
<constraint firstItem="5uC-rY-o3C" firstAttribute="leading" secondItem="781" secondAttribute="leading" id="VuY-zm-E8E"/>
<constraint firstAttribute="bottom" secondItem="781" secondAttribute="bottom" constant="46" id="YtF-9n-ID6"/>
<constraint firstItem="5uC-rY-o3C" firstAttribute="top" secondItem="743" secondAttribute="bottom" constant="8" symbolic="YES" id="ewE-9d-p1C"/>
<constraint firstItem="781" firstAttribute="top" secondItem="775" secondAttribute="bottom" constant="8" id="iTp-SR-3He"/>
<constraint firstItem="5uC-rY-o3C" firstAttribute="trailing" secondItem="775" secondAttribute="trailing" id="mae-RH-xn6"/>
<constraint firstItem="775" firstAttribute="leading" secondItem="594" secondAttribute="leading" id="t0u-Fo-sa6"/>
<constraint firstItem="781" firstAttribute="leading" secondItem="593" secondAttribute="leading" constant="52" id="xN0-Kj-2rf"/>
</constraints>
</view>
</window>
<customObject id="767" customClass="SUUpdater"/>
<userDefaultsController representsSharedInstance="YES" id="Mu8-ru-sxC"/>
</objects>
</document>

0 comments on commit fdd0149

Please sign in to comment.