Browse Source

Common Superclass for Floating Window and Panel and other changes.

v1.2.4
Abhishek Banthia 9 years ago
parent
commit
5f73b4db11
  1. 1
      Clocker/Appearance Tab/CLAppearanceViewController.h
  2. 95
      Clocker/Appearance Tab/CLAppearanceViewController.m
  3. 32
      Clocker/CLParentPanelController.h
  4. 165
      Clocker/CLParentPanelController.m
  5. 2
      Clocker/Onboarding/CLOnboardingWindowController.m
  6. 17
      Clocker/PanelController.h
  7. 231
      Clocker/PanelController.m
  8. 20
      Clocker/Preferences/CLPreferencesViewController.m
  9. 2
      Clocker/en.lproj/Localizable.strings
  10. 8
      Clocker/en.lproj/Panel.xib

1
Clocker/Appearance Tab/CLAppearanceViewController.h

@ -10,5 +10,4 @@
@interface CLAppearanceViewController : NSViewController @interface CLAppearanceViewController : NSViewController
@end @end

95
Clocker/Appearance Tab/CLAppearanceViewController.m

@ -11,6 +11,7 @@
#import "PanelController.h" #import "PanelController.h"
#import "CommonStrings.h" #import "CommonStrings.h"
#import "CLTimezoneData.h" #import "CLTimezoneData.h"
#import "CLFloatingWindowController.h"
@interface CLAppearanceViewController () @interface CLAppearanceViewController ()
@property (weak) IBOutlet NSSegmentedControl *timeFormat; @property (weak) IBOutlet NSSegmentedControl *timeFormat;
@ -42,12 +43,16 @@
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:timeFormat.selectedSegment] forKey:CL24hourFormatSelectedKey]; [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:timeFormat.selectedSegment] forKey:CL24hourFormatSelectedKey];
[self refreshMainTableview]; [self refreshMainTableview:YES andUpdateFloatingWindow:YES];
} }
- (IBAction)themeChanged:(id)sender - (IBAction)themeChanged:(id)sender
{ {
NSSegmentedControl *themeSegment = (NSSegmentedControl *)sender; NSSegmentedControl *themeSegment = (NSSegmentedControl *)sender;
//Get the current display mode
[self refreshMainTableview:NO andUpdateFloatingWindow:YES];
ApplicationDelegate *appDelegate = [[NSApplication sharedApplication] delegate]; ApplicationDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
PanelController *panelController = appDelegate.panelController; PanelController *panelController = appDelegate.panelController;
[panelController.backgroundView setNeedsDisplay:YES]; [panelController.backgroundView setNeedsDisplay:YES];
@ -71,18 +76,41 @@
} }
- (IBAction)displayModeChanged:(id)sender
{
NSSegmentedControl *modeSegment = (NSSegmentedControl *)sender;
ApplicationDelegate *sharedDelege = (ApplicationDelegate*)[NSApplication sharedApplication].delegate;
if (modeSegment.selectedSegment == 1)
{
sharedDelege.floatingWindow = [CLFloatingWindowController sharedFloatingWindow];
[sharedDelege.floatingWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
}
else
{
sharedDelege.floatingWindow = [CLFloatingWindowController sharedFloatingWindow];
[sharedDelege.floatingWindow.window close];
[sharedDelege.panelController updateDefaultPreferences];
}
}
- (IBAction)changeRelativeDayDisplay:(id)sender - (IBAction)changeRelativeDayDisplay:(id)sender
{ {
NSSegmentedControl *relativeDayControl = (NSSegmentedControl*) sender; NSSegmentedControl *relativeDayControl = (NSSegmentedControl*) sender;
NSNumber *selectedIndex = [NSNumber numberWithInteger:relativeDayControl.selectedSegment]; NSNumber *selectedIndex = [NSNumber numberWithInteger:relativeDayControl.selectedSegment];
[[NSUserDefaults standardUserDefaults] setObject:selectedIndex forKey:CLRelativeDateKey]; [[NSUserDefaults standardUserDefaults] setObject:selectedIndex forKey:CLRelativeDateKey];
[self refreshMainTableview]; [self refreshMainTableview:YES andUpdateFloatingWindow:YES];
} }
- (void)refreshMainTableview - (void)refreshMainTableview:(BOOL)panel andUpdateFloatingWindow:(BOOL)value
{ {
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (panel)
{
ApplicationDelegate *appDelegate = [[NSApplication sharedApplication] delegate]; ApplicationDelegate *appDelegate = [[NSApplication sharedApplication] delegate];
PanelController *panelController = appDelegate.panelController; PanelController *panelController = appDelegate.panelController;
@ -92,48 +120,34 @@
[panelController.mainTableview reloadData]; [panelController.mainTableview reloadData];
[appDelegate.menubarController shouldIconBeUpdated:YES]; [appDelegate.menubarController shouldIconBeUpdated:YES];
});
} }
- (NSImage *)imageWithSubviewsWithTextField:(NSTextField *)textField if (value)
{ {
NSSize mySize = textField.bounds.size; //Get the current display mode
NSSize imgSize = NSMakeSize( mySize.width, mySize.height ); NSNumber *displayMode = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowAppInForeground];
NSBitmapImageRep *bir = [textField bitmapImageRepForCachingDisplayInRect:[textField bounds]]; if (displayMode.integerValue == 1)
[bir setSize:imgSize];
[textField cacheDisplayInRect:[textField bounds] toBitmapImageRep:bir];
NSImage* image = [[NSImage alloc]initWithSize:imgSize];
[image addRepresentation:bir];
return image;
}
- (NSImage *)textWithTextField:(NSTextField *)textField
{ {
NSString *myString = textField.stringValue; //Get the Floating window instance
unsigned char *string = (unsigned char *) [myString UTF8String]; for (NSWindow *window in [NSApplication sharedApplication].windows)
NSSize mySize = NSMakeSize(50,100); //or measure the string {
if ([window.windowController isKindOfClass:[CLFloatingWindowController class]])
NSBitmapImageRep *bir = [[NSBitmapImageRep alloc] {
initWithBitmapDataPlanes:&string CLFloatingWindowController *currentInstance = (CLFloatingWindowController *)window.windowController;
pixelsWide:mySize.width pixelsHigh:mySize.height [currentInstance.mainTableview reloadData];
bitsPerSample:8
samplesPerPixel:3 // or 4 with alpha
hasAlpha:NO
isPlanar:NO
colorSpaceName:NSDeviceRGBColorSpace
bitmapFormat:0
bytesPerRow:0 // 0 == determine automatically
bitsPerPixel:0]; // 0 == determine automatically
//draw text using -(void)drawInRect:(NSRect)aRect withAttributes:(NSDictionary *)attributes //Only one instance where we need to update panel color and in that instance we pass panel as NO
NSImage* image = [[NSImage alloc]initWithSize:mySize]; if (!panel)
[image addRepresentation:bir]; {
return image; [currentInstance updatePanelColor];
}
}
}
}
}
});
} }
- (IBAction)changeMenuBarDisplayPreferences:(id)sender - (IBAction)changeMenuBarDisplayPreferences:(id)sender
@ -147,6 +161,11 @@
[userDefaults setObject:shouldCityBeShown forKey:@"shouldCityBeShown"]; [userDefaults setObject:shouldCityBeShown forKey:@"shouldCityBeShown"];
} }
- (IBAction)showFutureSlider:(id)sender
{
//Get the current display mode
[self refreshMainTableview:NO andUpdateFloatingWindow:YES];
}
@end @end

32
Clocker/CLParentPanelController.h

@ -0,0 +1,32 @@
//
// CLParentPanelController.h
// Clocker
//
// Created by Abhishek Banthia on 4/4/16.
//
//
#import <Cocoa/Cocoa.h>
#import "CLOneWindowController.h"
@interface CLParentPanelController : NSWindowController<NSWindowDelegate, NSTableViewDataSource, NSTableViewDelegate>
@property (nonatomic, strong) NSMutableArray *defaultPreferences;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, assign) NSInteger futureSliderValue;
@property (nonatomic) BOOL showReviewCell;
@property (weak) IBOutlet NSButton *shutdownButton;
@property (weak) IBOutlet NSButton *preferencesButton;
@property (weak) IBOutlet NSSlider *futureSlider;
@property (weak) IBOutlet NSTableView *mainTableview;
@property (weak) IBOutlet NSLayoutConstraint *scrollViewHeight;
@property (nonatomic, strong) CLOneWindowController *oneWindow;
- (void)updateDefaultPreferences;
- (void)showOptions:(BOOL)value;
- (void)removeContextHelpForSlider;
- (void)updatePanelColor;
@end

165
Clocker/CLParentPanelController.m

@ -0,0 +1,165 @@
//
// CLParentPanelController.m
// Clocker
//
// Created by Abhishek Banthia on 4/4/16.
//
//
#import "CLParentPanelController.h"
#import "CLRatingCellView.h"
#import "CLTimezoneData.h"
#import "CommonStrings.h"
#import "CLOneWindowController.h"
@interface CLParentPanelController ()
@end
@implementation CLParentPanelController
- (void)awakeFromNib
{
[super awakeFromNib];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isKindOfClass:[NSString class]]) {
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLThemeKey];
}
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
self.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
}
else
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon"];
self.preferencesButton.image = [NSImage imageNamed:NSImageNameActionTemplate];
}
self.mainTableview.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone;
}
- (void) updateDefaultPreferences
{
NSArray *defaultZones = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
self.defaultPreferences = self.defaultPreferences == nil ? [[NSMutableArray alloc] initWithArray:defaultZones] : [NSMutableArray arrayWithArray:defaultZones];
self.scrollViewHeight.constant = self.showReviewCell ?
(self.defaultPreferences.count+1)*55+40 : self.defaultPreferences.count*55 + 30;
if (self.defaultPreferences.count == 1) {
self.futureSlider.hidden = YES;
}
else
{
self.futureSlider.hidden = NO;
}
[self updatePanelColor];
}
- (void)updatePanelColor
{
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
[self.mainTableview setBackgroundColor:[NSColor blackColor]];
self.window.alphaValue = 0.90;
}
else
{
[self.mainTableview setBackgroundColor:[NSColor whiteColor]];
self.window.alphaValue = 1;
}
}
- (void)showOptions:(BOOL)value
{
if (self.defaultPreferences.count == 0)
{
value = YES;
}
dispatch_async(dispatch_get_main_queue(), ^{
self.shutdownButton.hidden = !value;
self.preferencesButton.hidden = !value;
});
}
- (IBAction)sliderMoved:(id)sender
{
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitMinute
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
self.dateFormatter.dateStyle = kCFDateFormatterNoStyle;
self.dateFormatter.timeStyle = kCFDateFormatterShortStyle;
NSString *relativeDate = [currentCalendar isDateInToday:newDate] ? @"Today" : @"Tomorrow";
NSString *helper = [self.dateFormatter stringFromDate:newDate];
NSHelpManager *helpManager = [NSHelpManager sharedHelpManager];
NSPoint pointInScreen = [NSEvent mouseLocation];
pointInScreen.y -= 5;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", relativeDate, helper]];
[NSHelpManager setContextHelpModeActive:YES];
[helpManager setContextHelp:attributedString forObject:self.futureSlider];
[helpManager showContextHelpForObject:self.futureSlider locationHint:pointInScreen];
[self.mainTableview reloadData];
}
- (void)removeContextHelpForSlider
{
NSEvent *newEvent = [NSEvent mouseEventWithType:NSLeftMouseDown
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
newEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
}
#pragma mark -
#pragma mark Preferences Target-Action
#pragma mark -
- (IBAction)openPreferences:(id)sender
{
self.oneWindow = [CLOneWindowController sharedWindow];
[self.oneWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
}
@end

2
Clocker/Onboarding/CLOnboardingWindowController.m

@ -30,6 +30,8 @@ static CLOnboardingWindowController *sharedOnboardingWindow;
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
} }
+ (instancetype)sharedWindow + (instancetype)sharedWindow
{ {
if (sharedOnboardingWindow == nil) if (sharedOnboardingWindow == nil)

17
Clocker/PanelController.h

@ -28,7 +28,7 @@
#import "BackgroundView.h" #import "BackgroundView.h"
#import "StatusItemView.h" #import "StatusItemView.h"
#import "CLOneWindowController.h" #import "CLParentPanelController.h"
@class PanelController; @class PanelController;
@class CLTimezoneData; @class CLTimezoneData;
@ -43,7 +43,7 @@
#pragma mark - #pragma mark -
@interface PanelController : NSWindowController <NSWindowDelegate, NSTableViewDataSource, NSTableViewDelegate> @interface PanelController : CLParentPanelController <NSWindowDelegate, NSTableViewDataSource, NSTableViewDelegate>
{ {
BOOL _hasActivePanel; BOOL _hasActivePanel;
__unsafe_unretained BackgroundView *_backgroundView; __unsafe_unretained BackgroundView *_backgroundView;
@ -53,19 +53,9 @@
} }
@property (nonatomic, strong) CLOneWindowController *oneWindow;
@property (nonatomic, strong) NSMutableArray *defaultPreferences;
@property (nonatomic, strong) NSDateFormatter *dateFormatter;
@property (nonatomic, assign) NSInteger futureSliderValue;
@property (nonatomic) BOOL hasActivePanel; @property (nonatomic) BOOL hasActivePanel;
@property (nonatomic) BOOL showReviewCell;
@property (nonatomic, unsafe_unretained, readonly) id<PanelControllerDelegate> delegate; @property (nonatomic, unsafe_unretained, readonly) id<PanelControllerDelegate> delegate;
@property (nonatomic, unsafe_unretained) IBOutlet BackgroundView *backgroundView; @property (nonatomic, unsafe_unretained) IBOutlet BackgroundView *backgroundView;
@property (weak) IBOutlet NSTableView *mainTableview;
@property (weak) IBOutlet NSLayoutConstraint *scrollViewHeight;
@property (weak) IBOutlet NSButton *shutdownButton;
@property (weak) IBOutlet NSButton *preferencesButton;
@property (weak) IBOutlet NSSlider *futureSlider;
@property (strong, nonatomic) PanelController *panelWindow; @property (strong, nonatomic) PanelController *panelWindow;
@property (strong, nonatomic) NSTimer *floatingWindowTimer; @property (strong, nonatomic) NSTimer *floatingWindowTimer;
@ -73,8 +63,5 @@
- (void)openPanel; - (void)openPanel;
- (void)closePanel; - (void)closePanel;
- (void)updateDefaultPreferences; - (void)updateDefaultPreferences;
- (void)showOptions:(BOOL)value;
- (void)removeContextHelpForSlider;
- (void)updatePanelColor;
@end @end

231
Clocker/PanelController.m

@ -90,28 +90,6 @@ static PanelController *sharedPanel = nil;
self.dateFormatter = [NSDateFormatter new]; self.dateFormatter = [NSDateFormatter new];
} }
if ([[[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey] isKindOfClass:[NSString class]]) {
[[NSUserDefaults standardUserDefaults] setObject:@0 forKey:CLThemeKey];
}
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue == 1)
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon-White"];
self.preferencesButton.image = [NSImage imageNamed:@"Settings-White"];
}
else
{
self.shutdownButton.image = [NSImage imageNamed:@"PowerIcon"];
self.preferencesButton.image = [NSImage imageNamed:NSImageNameActionTemplate];
}
[self updateDefaultPreferences];
self.mainTableview.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone;
NSPanel *panel = (id)[self window]; NSPanel *panel = (id)[self window];
[panel setAcceptsMouseMovedEvents:YES]; [panel setAcceptsMouseMovedEvents:YES];
[panel setLevel:NSPopUpMenuWindowLevel]; [panel setLevel:NSPopUpMenuWindowLevel];
@ -121,59 +99,12 @@ static PanelController *sharedPanel = nil;
//Register for drag and drop //Register for drag and drop
[self.mainTableview registerForDraggedTypes: [NSArray arrayWithObject:CLDragSessionKey]]; [self.mainTableview registerForDraggedTypes: [NSArray arrayWithObject:CLDragSessionKey]];
[self updatePanelColor]; [super updatePanelColor];
} [super updateDefaultPreferences];
/*
- (void)openAsFloatingWindow
{
if (self.panelWindow)
{
[self.panelWindow.window makeKeyAndOrderFront:nil];
return;
} }
[[NSUserDefaults standardUserDefaults] setObject:@1 forKey:CLShowAppInForeground];
self.panelWindow = [PanelController sharedPanel];
self.panelWindow.window.level = NSFloatingWindowLevel;
self.panelWindow.window.styleMask = NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask;
self.panelWindow.window.titlebarAppearsTransparent = YES;
self.panelWindow.window.titleVisibility = NSWindowTitleVisible;
[self.panelWindow showWindow:nil];
NSSize maxWindowSize;
maxWindowSize.width = self.window.frame.size.width;
maxWindowSize.height = self.window.frame.size.height+40;
NSSize minWindowSize;
minWindowSize.width = 110;
minWindowSize.height = 50;
NSSize currentSize;
currentSize.width = self.window.frame.size.width;
currentSize.height = self.window.frame.size.height;
self.panelWindow.window.contentMaxSize = maxWindowSize;
self.panelWindow.window.contentMinSize = minWindowSize;
[self.panelWindow.window setContentSize:currentSize];
[NSApp activateIgnoringOtherApps:YES];
self.floatingWindowTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self selector:@selector(updateTime)
userInfo:nil
repeats:YES];
}
- (void)updateTime
{
if (self.panelWindow)
{
[self.panelWindow.mainTableview reloadData];
}
}*/
#pragma mark - #pragma mark -
#pragma mark Updating Timezones #pragma mark Updating Timezones
@ -181,21 +112,7 @@ static PanelController *sharedPanel = nil;
- (void) updateDefaultPreferences - (void) updateDefaultPreferences
{ {
[super updateDefaultPreferences];
NSArray *defaultZones = [[NSUserDefaults standardUserDefaults] objectForKey:CLDefaultPreferenceKey];
self.defaultPreferences = self.defaultPreferences == nil ? [[NSMutableArray alloc] initWithArray:defaultZones] : [NSMutableArray arrayWithArray:defaultZones];
self.scrollViewHeight.constant = self.showReviewCell ?
(self.defaultPreferences.count+1)*55+40 : self.defaultPreferences.count*55 + 30;
if (self.defaultPreferences.count == 1) {
self.futureSlider.hidden = YES;
}
else
{
self.futureSlider.hidden = NO;
}
} }
#pragma mark - Public accessors #pragma mark - Public accessors
@ -417,15 +334,6 @@ static PanelController *sharedPanel = nil;
#pragma mark NSTableview Drag and Drop #pragma mark NSTableview Drag and Drop
#pragma mark - #pragma mark -
- (BOOL)tableView:(NSTableView *)tableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:rowIndexes];
[pboard declareTypes:[NSArray arrayWithObject:CLDragSessionKey] owner:self];
[pboard setData:data forType:CLDragSessionKey];
return YES;
}
-(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row -(void)tableView:(NSTableView *)tableView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{ {
if ([object isKindOfClass:[NSString class]]) if ([object isKindOfClass:[NSString class]])
@ -444,137 +352,4 @@ static PanelController *sharedPanel = nil;
} }
} }
-(BOOL)tableView:(NSTableView *)tableView acceptDrop:(id<NSDraggingInfo>)info row:(NSInteger)row dropOperation:(NSTableViewDropOperation)dropOperation
{
NSPasteboard *pBoard = [info draggingPasteboard];
NSData *data = [pBoard dataForType:CLDragSessionKey];
NSIndexSet *rowIndexes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
[self.defaultPreferences exchangeObjectAtIndex:rowIndexes.firstIndex
withObjectAtIndex:row];
[[NSUserDefaults standardUserDefaults] setObject:self.defaultPreferences
forKey:CLDefaultPreferenceKey];
[[NSApplication sharedApplication].windows enumerateObjectsUsingBlock:^(NSWindow * _Nonnull window, NSUInteger idx, BOOL * _Nonnull stop) {
if ([window.windowController isMemberOfClass:[CLOneWindowController class]]) {
CLOneWindowController *ref = (CLOneWindowController *) window.windowController;
[ref.preferencesView refereshTimezoneTableView];
}
}];
[self.mainTableview reloadData];
return YES;
}
-(NSDragOperation)tableView:(NSTableView *)tableView validateDrop:(id<NSDraggingInfo>)info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)dropOperation
{
return NSDragOperationEvery;
}
#pragma mark -
#pragma mark Preferences Target-Action
#pragma mark -
- (IBAction)openPreferences:(id)sender
{
self.oneWindow = [CLOneWindowController sharedWindow];
[self.oneWindow showWindow:nil];
[NSApp activateIgnoringOtherApps:YES];
}
#pragma mark -
#pragma mark Hiding Buttons on Mouse Exit
#pragma mark -
- (void)showOptions:(BOOL)value
{
if (self.defaultPreferences.count == 0)
{
value = YES;
}
dispatch_async(dispatch_get_main_queue(), ^{
self.shutdownButton.hidden = !value;
self.preferencesButton.hidden = !value;
});
}
- (IBAction)sliderMoved:(id)sender
{
NSCalendar *currentCalendar = [NSCalendar autoupdatingCurrentCalendar];
NSDate *newDate = [currentCalendar dateByAddingUnit:NSCalendarUnitMinute
value:self.futureSliderValue
toDate:[NSDate date]
options:kNilOptions];
self.dateFormatter.dateStyle = kCFDateFormatterNoStyle;
self.dateFormatter.timeStyle = kCFDateFormatterShortStyle;
NSString *relativeDate = [currentCalendar isDateInToday:newDate] ? @"Today" : @"Tomorrow";
NSString *helper = [self.dateFormatter stringFromDate:newDate];
NSHelpManager *helpManager = [NSHelpManager sharedHelpManager];
NSPoint pointInScreen = [NSEvent mouseLocation];
pointInScreen.y -= 5;
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@ %@", relativeDate, helper]];
[NSHelpManager setContextHelpModeActive:YES];
[helpManager setContextHelp:attributedString forObject:self.futureSlider];
[helpManager showContextHelpForObject:self.futureSlider locationHint:pointInScreen];
[self.mainTableview reloadData];
}
- (void)removeContextHelpForSlider
{
NSEvent *newEvent = [NSEvent mouseEventWithType:NSLeftMouseDown
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
newEvent = [NSEvent mouseEventWithType:NSLeftMouseUp
location:self.window.mouseLocationOutsideOfEventStream
modifierFlags:0
timestamp:0
windowNumber:self.window.windowNumber
context:self.window.graphicsContext
eventNumber:0
clickCount:1
pressure:0];
[NSApp postEvent:newEvent atStart:NO];
}
- (void)updatePanelColor
{
NSNumber *theme = [[NSUserDefaults standardUserDefaults] objectForKey:CLThemeKey];
if (theme.integerValue)
{
[self.mainTableview setBackgroundColor:[NSColor blackColor]];
self.window.alphaValue = 0.90;
}
else
{
[self.mainTableview setBackgroundColor:[NSColor whiteColor]];
self.window.alphaValue = 1;
}
}
@end @end

20
Clocker/Preferences/CLPreferencesViewController.m

@ -530,6 +530,26 @@ NSString *const CLTryAgainMessage = @"Try again, maybe?";
[panelController.mainTableview reloadData]; [panelController.mainTableview reloadData];
//Get the current display mode
NSNumber *displayMode = [[NSUserDefaults standardUserDefaults] objectForKey:CLShowAppInForeground];
if (displayMode.integerValue == 1)
{
//Get the Floating window instance
for (NSWindow *window in [NSApplication sharedApplication].windows)
{
if ([window.windowController isKindOfClass:[CLFloatingWindowController class]])
{
CLFloatingWindowController *currentInstance = (CLFloatingWindowController *)window.windowController;
[currentInstance updateDefaultPreferences];
[currentInstance.mainTableview reloadData];
}
}
}
}); });
} }

2
Clocker/en.lproj/Localizable.strings

@ -14,3 +14,5 @@
"iRateRateButton" = "Rate It Now"; "iRateRateButton" = "Rate It Now";
"iRateRemindButton" = "Remind Me Later"; "iRateRemindButton" = "Remind Me Later";
"iRateUpdateMessage" = "Update now?"; "iRateUpdateMessage" = "Update now?";
"ClockerVersion" = "Version %@";
"CLFeedbackAlertTitle" = "Thank you for helping make Clocker even better!";

8
Clocker/en.lproj/Panel.xib

@ -57,7 +57,7 @@
<rect key="frame" x="1" y="0.0" width="279" height="60"/> <rect key="frame" x="1" y="0.0" width="279" height="60"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews> <subviews>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" tag="100" translatesAutoresizingMaskIntoConstraints="NO" id="etF-33-bCB"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" tag="100" preferredMaxLayoutWidth="150" translatesAutoresizingMaskIntoConstraints="NO" id="etF-33-bCB">
<rect key="frame" x="7" y="33" width="154" height="22"/> <rect key="frame" x="7" y="33" width="154" height="22"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="150" id="32b-h6-joo"/> <constraint firstAttribute="width" constant="150" id="32b-h6-joo"/>
@ -72,7 +72,7 @@
<action selector="labelDidChange:" target="qbN-ba-fho" id="7uY-zA-yJS"/> <action selector="labelDidChange:" target="qbN-ba-fho" id="7uY-zA-yJS"/>
</connections> </connections>
</textField> </textField>
<textField verticalHuggingPriority="750" tag="102" translatesAutoresizingMaskIntoConstraints="NO" id="QUd-7D-q14"> <textField verticalHuggingPriority="750" tag="102" preferredMaxLayoutWidth="72" translatesAutoresizingMaskIntoConstraints="NO" id="QUd-7D-q14">
<rect key="frame" x="8" y="11" width="76" height="20"/> <rect key="frame" x="8" y="11" width="76" height="20"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="20" id="42Y-hy-Uo7"/> <constraint firstAttribute="height" constant="20" id="42Y-hy-Uo7"/>
@ -84,7 +84,7 @@
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell> </textFieldCell>
</textField> </textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="101" translatesAutoresizingMaskIntoConstraints="NO" id="vnv-J2-7r1"> <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="101" preferredMaxLayoutWidth="110" translatesAutoresizingMaskIntoConstraints="NO" id="vnv-J2-7r1">
<rect key="frame" x="159" y="21" width="114" height="35"/> <rect key="frame" x="159" y="21" width="114" height="35"/>
<constraints> <constraints>
<constraint firstAttribute="height" constant="35" id="3WU-de-OQL"/> <constraint firstAttribute="height" constant="35" id="3WU-de-OQL"/>
@ -120,7 +120,7 @@
<rect key="frame" x="58" y="30" width="16" height="16"/> <rect key="frame" x="58" y="30" width="16" height="16"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="ClockerIcon-16" id="8gl-Vi-0VF"/> <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="ClockerIcon-16" id="8gl-Vi-0VF"/>
</imageView> </imageView>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" translatesAutoresizingMaskIntoConstraints="NO" id="JNw-ld-oz9"> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" allowsExpansionToolTips="YES" preferredMaxLayoutWidth="185" translatesAutoresizingMaskIntoConstraints="NO" id="JNw-ld-oz9">
<rect key="frame" x="79" y="28" width="189" height="20"/> <rect key="frame" x="79" y="28" width="189" height="20"/>
<constraints> <constraints>
<constraint firstAttribute="width" constant="185" id="i6p-pO-tfO"/> <constraint firstAttribute="width" constant="185" id="i6p-pO-tfO"/>

Loading…
Cancel
Save