Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Credits.rtf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\listtable{\list\listtemplateid1\listhybrid{\listlevel\levelnfc23\levelnfcn23\leveljc0\leveljcn0\levelfollow0\levelstartat1\levelspace360\levelindent0{\*\levelmarker \{disc\}}{\leveltext\leveltemplateid1\'01\uc0\u8226 ;}{\levelnumbers;}\fi-360\li720\lin720 }{\listname ;}\listid1}}
Expand All @@ -15,4 +15,4 @@
\ls1\ilvl0\cf0 {\listtext \'95 }{\field{\*\fldinst{HYPERLINK "https://github.com/dimonzozo"}}{\fldrslt Dmitriy}}\
{\listtext \'95 }{\field{\*\fldinst{HYPERLINK "https://github.com/jaysonlane"}}{\fldrslt Jason Lane}}\
{\listtext \'95 }{\field{\*\fldinst{HYPERLINK "https://github.com/tilden"}}{\fldrslt Dan Tilden}}\
}
{\listtext \'95 }{\field{\*\fldinst{HYPERLINK "http://github.com/zvaehn"}}{\fldrslt Sven Schiffer}}}
10 changes: 10 additions & 0 deletions PreferencesWindowController.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@
SRRecorderControl *startPauseShortcutRecorder;
SRRecorderControl *restartShortcutRecorder;
SRRecorderControl *finishShortcutRecorder;

NSButton *startOnStartup;
NSButton *pauseOnSleepButton;
NSButton *pauseOnScreensaverButton;
NSButton *hideSeconds;
NSButton *flashTimeSeparator;
NSButton *showNotifications;
}

@property (nonatomic, retain) IBOutlet SRRecorderControl *startPauseShortcutRecorder;
@property (nonatomic, retain) IBOutlet SRRecorderControl *restartShortcutRecorder;
@property (nonatomic, retain) IBOutlet SRRecorderControl *finishShortcutRecorder;

@property (nonatomic, retain) IBOutlet NSButton *startOnStartup;
@property (nonatomic, retain) IBOutlet NSButton *pauseOnSleepButton;
@property (nonatomic, retain) IBOutlet NSButton *pauseOnScreensaverButton;
@property (nonatomic, retain) IBOutlet NSButton *hideSeconds;
@property (nonatomic, retain) IBOutlet NSButton *showNotifications;
@property (nonatomic, retain) IBOutlet NSButton *flashTimeSeparator;

@end
8 changes: 8 additions & 0 deletions PreferencesWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ @implementation PreferencesWindowController
@synthesize startPauseShortcutRecorder;
@synthesize restartShortcutRecorder;
@synthesize finishShortcutRecorder;
@synthesize startOnStartup;
@synthesize pauseOnSleepButton;
@synthesize pauseOnScreensaverButton;
@synthesize hideSeconds;
@synthesize flashTimeSeparator;
@synthesize showNotifications;

- (id)initWithWindow:(NSWindow *)window
{
Expand All @@ -40,8 +44,12 @@ - (void)windowDidLoad
[self.restartShortcutRecorder bind:NSValueBinding toObject:defaults withKeyPath:@"values.restart" options:nil];
[self.finishShortcutRecorder bind:NSValueBinding toObject:defaults withKeyPath:@"values.finish" options:nil];

[self.startOnStartup bind:NSValueBinding toObject:defaults withKeyPath:@"values.startOnStartup" options:nil];
[self.pauseOnSleepButton bind:NSValueBinding toObject:defaults withKeyPath:@"values.pauseOnSleep" options:nil];
[self.pauseOnScreensaverButton bind:NSValueBinding toObject:defaults withKeyPath:@"values.pauseOnScreensaver" options:nil];
[self.hideSeconds bind:NSValueBinding toObject:defaults withKeyPath:@"values.hideSeconds" options:nil];
[self.flashTimeSeparator bind:NSValueBinding toObject:defaults withKeyPath:@"values.flashTimeSeparator" options:nil];
[self.showNotifications bind:NSValueBinding toObject:defaults withKeyPath:@"values.showNotifications" options:nil];

[self.startPauseShortcutRecorder clearButtonRect];

Expand Down
741 changes: 558 additions & 183 deletions PreferencesWindowController.xib

Large diffs are not rendered by default.

1,174 changes: 1,174 additions & 0 deletions ShortcutRecorder.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Stopwatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
@interface Stopwatch : NSObject {
id<StopwatchDelegate> delegate;

@private
@private
NSTimer* timer;
NSDate* reference;
NSTimeInterval accum;
BOOL separatorIsActive;
}

@property (nonatomic, assign) id<StopwatchDelegate> delegate;
Expand Down
30 changes: 26 additions & 4 deletions Stopwatch.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ @interface Stopwatch ()
@property (nonatomic, retain) NSTimer* timer;
@property (nonatomic, retain) NSDate* reference;
@property (nonatomic) NSTimeInterval accum;
@property (nonatomic) BOOL separatorIsActive;
- (void) tick;
@end

Expand All @@ -21,12 +22,14 @@ @implementation Stopwatch
@synthesize timer;
@synthesize reference;
@synthesize accum;
@synthesize separatorIsActive;

- (id)init {
if (self = [super init]) {
self.timer = nil;
self.reference = [NSDate date];
self.accum = 0;
self.separatorIsActive = TRUE;
}

return self;
Expand All @@ -41,15 +44,31 @@ - (id)initWithDelegate:(id<StopwatchDelegate>)aDelegate {
}

- (NSString*) description {
NSString *seperator = @":";

long seconds = (long) floor([self value]);
long hours = seconds / 3600;
long minutes = (seconds / 60) % 60;
seconds = seconds % 60;

if (hours > 0) {
return [NSString stringWithFormat:@"%02ld:%02ld:%02ld", hours, minutes, seconds];
} else {
return [NSString stringWithFormat:@"%02ld:%02ld", minutes, seconds];
// Toggling seperator
if(self.separatorIsActive || ![[NSUserDefaults standardUserDefaults] boolForKey:@"flashTimeSeparator"]) {
seperator = @":";
self.separatorIsActive = FALSE;
}
else {
seperator = @" ";
self.separatorIsActive = TRUE;
}

if([[NSUserDefaults standardUserDefaults] boolForKey:@"hideSeconds"]) {
return [NSString stringWithFormat:@"%02ld%@%02ld", hours, seperator, minutes];
}
else if (hours > 0) {
return [NSString stringWithFormat:@"%02ld%@%02ld%@%02ld", hours, seperator, minutes, seperator, seconds];
}
else {
return [NSString stringWithFormat:@"%02ld%@%02ld", minutes, seperator, seconds];
}
}

Expand Down Expand Up @@ -98,6 +117,9 @@ - (void) pause {
[self.timer invalidate];
self.timer = nil;

// Force the separator to show
self.separatorIsActive = TRUE;

if (self.delegate) {
[self.delegate didPause:self];
}
Expand Down
20 changes: 16 additions & 4 deletions ThymeAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,23 @@ - (void) didChange:(id)stopwatch {

- (void)notifyStart
{
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:@"Started" notificationName:@"start" iconData:nil priority:0 isSticky:NO clickContext:nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"showNotifications"]) {
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:@"Started" notificationName:@"start" iconData:nil priority:0 isSticky:NO clickContext:nil];
}
}

- (void)notifyPauseWithDescription:(NSString*)description
{
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:[@"Paused at " stringByAppendingString:description] notificationName:@"pause" iconData:nil priority:0 isSticky:NO clickContext:nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"showNotifications"]) {
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:[@"Paused at " stringByAppendingString:description] notificationName:@"pause" iconData:nil priority:0 isSticky:NO clickContext:nil];
}
}

- (void)notifyStopWithDescription:(NSString*)description
{
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:[@"Stopped at " stringByAppendingString:description] notificationName:@"stop" iconData:nil priority:0 isSticky:NO clickContext:nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"showNotifications"]) {
[GrowlApplicationBridge notifyWithTitle:@"Thyme" description:[@"Stopped at " stringByAppendingString:description] notificationName:@"stop" iconData:nil priority:0 isSticky:NO clickContext:nil];
}
}

#pragma mark NSUserDefaultsDidChangeNotification
Expand Down Expand Up @@ -410,7 +416,9 @@ - (void) onScreensaverStart: (NSNotification*) note
- (void) onScreensaverStop: (NSNotification*) note
{
NSLog(@"screensaver stop");
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnScreensaver"]) {
NSLog(@"Clock was active: %hhd", stopwatch.isPaused);

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"pauseOnScreensaver"] && !stopwatch.isPaused) {
[self startWithNotification:NO];
}
}
Expand Down Expand Up @@ -507,6 +515,10 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification

// Start controller
[self resetWithNotification:NO];

if([[NSUserDefaults standardUserDefaults] boolForKey:@"startOnStartup"]) {
[self startTimer];
}
}

/**
Expand Down
8 changes: 8 additions & 0 deletions defaults.plist
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
<true/>
<key>pauseOnSleep</key>
<true/>
<key>hideSeconds</key>
<true/>
<key>flashTimeSeperator</key>
<false/>
<key>startTimerOnStartup</key>
<false/>
<key>showNotifications</key>
<false/>
</dict>
</plist>