Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ab7ae3c
Update deploment targets to MacOS 12.4
GustavBertram May 13, 2026
5c79e44
Update to recommended project settings:
GustavBertram May 13, 2026
5f86185
Change flags to the correct type
GustavBertram May 13, 2026
c076344
Make implicit self-> explicit
GustavBertram May 13, 2026
8bff4ae
Update to new event modiefier flags
GustavBertram May 13, 2026
60a0a49
Remove duplicate key in string literal
GustavBertram May 13, 2026
d72f874
Update hotkey cell color
GustavBertram May 13, 2026
5cdb03d
Update the General tab in the Preferences Window to allow for selecti…
GustavBertram May 13, 2026
585ad4d
Fixed the width of the options in the Notification tab in the Prefere…
GustavBertram May 13, 2026
61373d2
Enable recommended Generated Asset Symbol Extensions setting
GustavBertram May 13, 2026
a60aef4
Update the UserNotification API
GustavBertram May 13, 2026
ff38147
Update User Notification Center
GustavBertram May 13, 2026
e76281d
Update menuItem state constants
GustavBertram May 13, 2026
37e5759
Update the Status Icon code
GustavBertram May 13, 2026
38d40fc
Fix build warnings for the tests, and add OSX 12.4 as the test platform
GustavBertram May 13, 2026
785f403
Fix more build errors in the tests, for implicit self, and updated ho…
GustavBertram May 13, 2026
e3323ae
Update assertions to remove warnings
GustavBertram May 13, 2026
7763fd2
Fix test project building
GustavBertram May 18, 2026
014cc43
Inhibit warnings from compilation of old test libraries
GustavBertram May 18, 2026
0ce1c89
Fix two failing tests
GustavBertram May 18, 2026
b9e084a
Bump the version number to 1.2.1, add my name to contributors
GustavBertram May 18, 2026
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ Thank you to all the contributors to Tomighty OSX:
* Matthew Andersen (@mattandersen)
* Devon Tucker (@dvntucker)
* Misha Tavkhelidze (@mtavkhelidze)
* Gustav Bertram (@gustavbertram)

Please let us know if you feel your name is missing from this list (and feel free to update it with your PRs).
5 changes: 3 additions & 2 deletions src/Podfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# no pods for main target yet

target :TomightyTests do
pod 'OCHamcrest', '~> 3.0'
pod 'OCMockito', '~> 1.0'
platform :osx, '12.4'
pod 'OCHamcrest', '~> 3.0', :inhibit_warnings => true
pod 'OCMockito', '~> 1.0', :inhibit_warnings => true
end
117 changes: 68 additions & 49 deletions src/Tomighty.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions src/Tomighty/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="5053" systemVersion="13C64" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="24765" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="5053"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24765"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -10,7 +11,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customObject id="494" customClass="TYAppDelegate">
<connections>
<outlet property="pomodoroCountMenuItem" destination="zxM-G5-msF" id="YaM-Mx-U4a"/>
Expand Down Expand Up @@ -84,6 +85,7 @@
</connections>
</menuItem>
</items>
<point key="canvasLocation" x="140" y="151"/>
</menu>
</objects>
</document>
147 changes: 69 additions & 78 deletions src/Tomighty/Base.lproj/PreferencesWindow.xib

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/Tomighty/Core/Agent/TYSoundAgent.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ - (void)playSoundsInResponseToEventsFrom:(id <TYEventBus>)eventBus
{
[eventBus subscribeTo:TIMER_START subscriber:^(id timerContext)
{
if([preferences getInt:PREF_PLAY_SOUND_WHEN_TIMER_STARTS])
if([self->preferences getInt:PREF_PLAY_SOUND_WHEN_TIMER_STARTS])
{
[soundPlayer play:SOUND_TIMER_START];
[self->soundPlayer play:SOUND_TIMER_START];
}
}];

[eventBus subscribeTo:TIMER_STOP subscriber:^(id eventData) {
[soundPlayer stopCurrentLoop];
[self->soundPlayer stopCurrentLoop];
}];

[eventBus subscribeTo:POMODORO_START subscriber:^(id timerContext)
{
[soundPlayer stopCurrentLoop];
if([preferences getInt:PREF_PLAY_TICKTOCK_SOUND_DURING_POMODORO])
[self->soundPlayer stopCurrentLoop];
if([self->preferences getInt:PREF_PLAY_TICKTOCK_SOUND_DURING_POMODORO])
{
[soundPlayer loop:SOUND_TIMER_TICK];
[self->soundPlayer loop:SOUND_TIMER_TICK];
}
}];

[eventBus subscribeTo:BREAK_START subscriber:^(id timerContext)
{
[soundPlayer stopCurrentLoop];
if([preferences getInt:PREF_PLAY_TICKTOCK_SOUND_DURING_BREAK])
[self->soundPlayer stopCurrentLoop];
if([self->preferences getInt:PREF_PLAY_TICKTOCK_SOUND_DURING_BREAK])
{
[soundPlayer loop:SOUND_TIMER_TICK];
[self->soundPlayer loop:SOUND_TIMER_TICK];
}
}];

[eventBus subscribeTo:TIMER_GOES_OFF subscriber:^(id timerContext)
{
if([preferences getInt:PREF_PLAY_SOUND_WHEN_TIMER_GOES_OFF])
if([self->preferences getInt:PREF_PLAY_SOUND_WHEN_TIMER_GOES_OFF])
{
[soundPlayer play:SOUND_TIMER_GOES_OFF];
[self->soundPlayer play:SOUND_TIMER_GOES_OFF];
}
}];
}
Expand Down
39 changes: 22 additions & 17 deletions src/Tomighty/Core/Agent/TYUserInterfaceAgent.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

#import <Carbon/Carbon.h>
#import <UserNotifications/UserNotifications.h>
#import "TYUserInterfaceAgent.h"
#import "TYTimerContext.h"

Expand All @@ -29,57 +30,61 @@ - (id)initWith:(id <TYAppUI>)theAppUI preferences:(id <TYPreferences>)aPreferenc
- (void)dispatchNewNotification: (NSString*) text
{
if ([preferences getInt:PREF_ENABLE_NOTIFICATIONS]) {
NSUserNotification *notification = [[NSUserNotification alloc] init];
notification.title = text;
notification.soundName = NSUserNotificationDefaultSoundName;

[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:notification];
UNMutableNotificationContent *content = [[UNMutableNotificationContent alloc] init];
content.title = text;
content.sound = [UNNotificationSound defaultSound];

UNNotificationRequest *request = [UNNotificationRequest requestWithIdentifier:[[NSUUID UUID] UUIDString]
content:content
trigger:nil];

[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:nil];
}
}

- (void)updateAppUiInResponseToEventsFrom:(id <TYEventBus>)eventBus
{
[eventBus subscribeTo:APP_INIT subscriber:^(id eventData) {
[ui switchToIdleState];
[ui updateRemainingTime:0 withMode:TYAppUIRemainingTimeModeDefault];
[ui setStatusIconTextFormat:(TYAppUIStatusIconTextFormat) [preferences getInt:PREF_STATUS_ICON_TIME_FORMAT]];
[ui updatePomodoroCount:0];
[self->ui switchToIdleState];
[self->ui updateRemainingTime:0 withMode:TYAppUIRemainingTimeModeDefault];
[self->ui setStatusIconTextFormat:(TYAppUIStatusIconTextFormat) [self->preferences getInt:PREF_STATUS_ICON_TIME_FORMAT]];
[self->ui updatePomodoroCount:0];
}];

[eventBus subscribeTo:POMODORO_START subscriber:^(id eventData) {
[ui switchToPomodoroState];
[self->ui switchToPomodoroState];
[self dispatchNewNotification:@"Pomodoro started"];
}];

[eventBus subscribeTo:TIMER_STOP subscriber:^(id eventData) {
[ui switchToIdleState];
[self->ui switchToIdleState];
}];

[eventBus subscribeTo:SHORT_BREAK_START subscriber:^(id eventData) {
[ui switchToShortBreakState];
[self->ui switchToShortBreakState];
[self dispatchNewNotification:@"Short break started"];
}];

[eventBus subscribeTo:LONG_BREAK_START subscriber:^(id eventData) {
[ui switchToLongBreakState];
[self->ui switchToLongBreakState];
[self dispatchNewNotification:@"Long break started"];
}];

[eventBus subscribeTo:TIMER_TICK subscriber:^(id <TYTimerContext> timerContext) {
[ui updateRemainingTime:[timerContext getRemainingSeconds] withMode:TYAppUIRemainingTimeModeDefault];
[self->ui updateRemainingTime:[timerContext getRemainingSeconds] withMode:TYAppUIRemainingTimeModeDefault];
}];

[eventBus subscribeTo:TIMER_START subscriber:^(id <TYTimerContext> timerContext) {
[ui updateRemainingTime:[timerContext getRemainingSeconds] withMode:TYAppUIRemainingTimeModeStart];
[self->ui updateRemainingTime:[timerContext getRemainingSeconds] withMode:TYAppUIRemainingTimeModeStart];
}];

[eventBus subscribeTo:POMODORO_COUNT_CHANGE subscriber:^(NSNumber *pomodoroCount) {
[ui updatePomodoroCount:[pomodoroCount intValue]];
[self->ui updatePomodoroCount:[pomodoroCount intValue]];
}];

[eventBus subscribeTo:PREFERENCE_CHANGE subscriber:^(NSString *preferenceKey) {
if ([preferenceKey isEqualToString:PREF_STATUS_ICON_TIME_FORMAT]) {
[ui setStatusIconTextFormat:(TYAppUIStatusIconTextFormat) [preferences getInt:PREF_STATUS_ICON_TIME_FORMAT]];
[self->ui setStatusIconTextFormat:(TYAppUIStatusIconTextFormat) [self->preferences getInt:PREF_STATUS_ICON_TIME_FORMAT]];
}
}];
}
Expand Down
5 changes: 3 additions & 2 deletions src/Tomighty/Core/Hotkey/TYHotkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/// @credits
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>

@class NSColor;
@class NSFont;
Expand All @@ -32,11 +33,11 @@
@property (readonly) BOOL cmd;
@property (readonly) BOOL valid;
@property (nonatomic, assign) SInt32 code;
@property (nonatomic, assign) UInt32 flags;
@property (nonatomic, assign) NSEventModifierFlags flags;
@property (readonly) UInt32 carbonFlags;
@property (nonatomic, strong) NSString *string;

+ (id)hotkeyWithCode:(CGKeyCode)code flags:(UInt32)flags;
+ (id)hotkeyWithCode:(CGKeyCode)code flags:(NSEventModifierFlags)flags;
+ (id)hotkeyWithString:(NSString*)string;

- (NSMutableAttributedString*)mutableAttributedString:(NSFont*)font
Expand Down
21 changes: 10 additions & 11 deletions src/Tomighty/Core/Hotkey/TYHotkey.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ @implementation TYHotkey {

#pragma mark Init

+ (id)hotkeyWithCode:(CGKeyCode)code flags:(UInt32)flags
+ (id)hotkeyWithCode:(CGKeyCode)code flags:(NSEventModifierFlags)flags
{
TYHotkey *key = [[TYHotkey alloc] init];
if(key) {
Expand Down Expand Up @@ -53,13 +53,13 @@ - (void)setString:(NSString *)string
for(int i = 0; i < string.length; i++) {
NSString *s = [string substringWithRange:NSMakeRange(i, 1)];
if([s isEqualToString:MVTControlKeyString])
_flags |= NSControlKeyMask;
_flags |= NSEventModifierFlagControl;
else if([s isEqualToString:MVTAlternativeKeyString])
_flags |= NSAlternateKeyMask;
_flags |= NSEventModifierFlagOption;
else if([s isEqualToString:MVTShiftKeyString])
_flags |= NSShiftKeyMask;
_flags |= NSEventModifierFlagShift;
else if([s isEqualToString:MVTCommandKeyString])
_flags |= NSCommandKeyMask;
_flags |= NSEventModifierFlagCommand;
else {
NSString *s = [string
substringWithRange:NSMakeRange(i, string.length - i)];
Expand Down Expand Up @@ -107,22 +107,22 @@ - (UInt32)carbonFlags

- (BOOL)ctrl
{
return _flags & NSControlKeyMask ? TRUE : FALSE;
return _flags & NSEventModifierFlagControl ? TRUE : FALSE;
}

- (BOOL)alt
{
return _flags & NSAlternateKeyMask ? TRUE : FALSE;
return _flags & NSEventModifierFlagOption ? TRUE : FALSE;
}

- (BOOL)shift
{
return _flags & NSShiftKeyMask ? TRUE : FALSE;
return _flags & NSEventModifierFlagShift ? TRUE : FALSE;
}

- (BOOL)cmd
{
return _flags & NSCommandKeyMask ? TRUE : FALSE;
return _flags & NSEventModifierFlagCommand ? TRUE : FALSE;
}

- (BOOL)valid
Expand Down Expand Up @@ -175,7 +175,7 @@ - (NSMutableAttributedString*)mutableAttributedString:(NSFont*)font

}

- (void)_withCodeAndFlags:(CGKeyCode)code flags:(UInt32)flags
- (void)_withCodeAndFlags:(CGKeyCode)code flags:(NSEventModifierFlags)flags
{
_code = code;
_flags = flags;
Expand Down Expand Up @@ -269,7 +269,6 @@ - (NSDictionary*)_makeKeymap
@(kVK_ANSI_LeftBracket): @"[",
@(kVK_ANSI_RightBracket): @"]",
@(kVK_ANSI_Backslash): @"\\",
@(kVK_ANSI_RightBracket): @"]",
@(kVK_CapsLock): @"Capslock",
@(kVK_ANSI_Semicolon): @";",
@(kVK_ANSI_Quote): @"'",
Expand Down
2 changes: 1 addition & 1 deletion src/Tomighty/Core/Hotkey/TYHotkeyCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ - (void)setHotkey:(TYHotkey*)key
NSMutableAttributedString *as;
as = [key mutableAttributedString:self.font
textColor:self.textColor
inactiveColor:[NSColor controlHighlightColor]];
inactiveColor:[NSColor tertiaryLabelColor]];
[as addAttribute:NSParagraphStyleAttributeName value:ps
range:NSMakeRange(0, as.length)];

Expand Down
2 changes: 1 addition & 1 deletion src/Tomighty/Core/Hotkey/TYHotkeyControl.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ - (void)setHotkey:(TYHotkey*)hotkey
{
if(hotkey.valid) {
_key = hotkey;
[_cell setHotkey:_key];
[(TYHotkeyCell *)self.cell setHotkey:_key];
[self sendAction:self.action to:self.target];
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Tomighty/Core/TYDefaultTomighty.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ - (id)initWith:(id <TYTimer>)aTimer
}];

[eventBus subscribeTo:READY_FOR_NEXT_TIMER subscriber:^(id eventData) {
if ([preferences getInt:PREF_CONTINUOUS_MODE] == YES) {
if ([self->preferences getInt:PREF_CONTINUOUS_MODE] == YES) {
//start the next timer, depending on the previous context
id <TYTimerContext> context = eventData;
switch ([context getContextType]) {
case POMODORO:
if (pomodoroCount < pomodoroCycle) {
if (self->pomodoroCount < self->pomodoroCycle) {
[self startShortBreak];
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/Tomighty/Core/Timer/TYDefaultTimer.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ - (void)start:(id<TYTimerContext>)context

if([context getRemainingSeconds] > 0)
{
[eventBus publish:TIMER_TICK data:context];
[self->eventBus publish:TIMER_TICK data:context];
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/Tomighty/Core/Timer/TYSystemTimer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import <Foundation/Foundation.h>

typedef void (^TYSystemTimerTrigger)();
typedef void (^TYSystemTimerTrigger)(void);

@protocol TYSystemTimer <NSObject>

Expand Down
10 changes: 5 additions & 5 deletions src/Tomighty/Core/UI/TYDefaultStatusIcon.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ - (NSStatusItem *)createStatusItem:(NSMenu *)menu
{
NSStatusItem *newStatusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];

[newStatusItem setHighlightMode:YES];
[newStatusItem setImage:[self getIconImage:ICON_STATUS_IDLE template:YES]];
[newStatusItem setAlternateImage:[self getIconImage:ICON_STATUS_ALTERNATE template:YES]];
((NSButtonCell *)newStatusItem.button.cell).highlightsBy = NSChangeBackgroundCellMask | NSContentsCellMask;
newStatusItem.button.image = [self getIconImage:ICON_STATUS_IDLE template:YES];
newStatusItem.button.alternateImage = [self getIconImage:ICON_STATUS_ALTERNATE template:YES];
[newStatusItem setMenu:menu];

return newStatusItem;
}

- (void)changeIcon:(NSString *)iconName
{
[statusItem setImage:[self getIconImage:iconName template:NO]];
statusItem.button.image = [self getIconImage:iconName template:NO];
}

- (NSImage *)getIconImage:(NSString *)iconName template:(BOOL)isTemplate
Expand All @@ -63,7 +63,7 @@ - (NSImage *)getIconImage:(NSString *)iconName template:(BOOL)isTemplate

- (void)setStatusText:(NSString *)statusText
{
statusItem.title = statusText;
statusItem.button.title = statusText;
}

@end
4 changes: 2 additions & 2 deletions src/Tomighty/TYAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
// http://www.apache.org/licenses/LICENSE-2.0.txt
//

#import <AppKit/AppKit.h>
#import <UserNotifications/UserNotifications.h>

#import "TYStatusMenu.h"
#import "TYStatusIcon.h"

@interface TYAppDelegate : NSObject <NSApplicationDelegate, TYStatusMenu, NSUserNotificationCenterDelegate>
@interface TYAppDelegate : NSObject <NSApplicationDelegate, TYStatusMenu, UNUserNotificationCenterDelegate>

@property (weak) IBOutlet NSMenu *statusMenu;
@property (weak) IBOutlet NSMenuItem *remainingTimeMenuItem;
Expand Down
Loading