From 65ffae6022aca244ac7304036a86540bd09e9058 Mon Sep 17 00:00:00 2001 From: revintec Date: Sun, 14 Dec 2014 16:26:25 +0800 Subject: [PATCH 1/7] remove MenuBarLyrics content when iTunes pauses --- .../LyricX.xcodeproj/project.pbxproj | 6 +- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MainController.m | 85 +++++++++++-------- DynamicLyrics/LyricX/MenuBarLyrics.m | 11 ++- .../project.pbxproj | 4 +- 5 files changed, 65 insertions(+), 43 deletions(-) diff --git a/DynamicLyrics/LyricX.xcodeproj/project.pbxproj b/DynamicLyrics/LyricX.xcodeproj/project.pbxproj index e31b765..8f51778 100644 --- a/DynamicLyrics/LyricX.xcodeproj/project.pbxproj +++ b/DynamicLyrics/LyricX.xcodeproj/project.pbxproj @@ -692,7 +692,7 @@ 02710EA9152A839F006D4BFF /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -703,6 +703,7 @@ GCC_PREFIX_HEADER = "LyricX/LyricX-Prefix.pch"; INFOPLIST_FILE = "LyricX/LyricX-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_CODE_SIGN_FLAGS = ""; OTHER_LDFLAGS = "-licucore"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; @@ -714,7 +715,7 @@ 02710EAA152A839F006D4BFF /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -725,6 +726,7 @@ GCC_PREFIX_HEADER = "LyricX/LyricX-Prefix.pch"; INFOPLIST_FILE = "LyricX/LyricX-Info.plist"; MACOSX_DEPLOYMENT_TARGET = 10.7; + OTHER_CODE_SIGN_FLAGS = ""; OTHER_LDFLAGS = "-licucore"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE = ""; diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index 041f21d..daab95d 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1320 + 1345 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MainController.m b/DynamicLyrics/LyricX/MainController.m index fef65c6..47ed5f9 100644 --- a/DynamicLyrics/LyricX/MainController.m +++ b/DynamicLyrics/LyricX/MainController.m @@ -110,22 +110,30 @@ - (void) iTunesPlayerInfo:(NSNotification *)note iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; - if ([[[note userInfo] objectForKey:@"Player State"] isEqualToString:@"Stopped"]) { + NSString*state=[[note userInfo] objectForKey:@"Player State"]; + + if ([state isEqualToString:@"Stopped"]) { [nc postNotificationName:@"LyricsChanged" object:self userInfo:[NSDictionary dictionaryWithObject:@"DynamicLyrics!" forKey:@"Lyrics"]]; return; + }else if([state isEqualToString:@"Paused"]){ + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + [dict setObject:@"iTunesPause" forKey:@"Type"]; + [dict setObject:@YES forKey:@"isPausing"]; + [self performSelectorOnMainThread:@selector(WorkingThread:) withObject:dict waitUntilDone:YES]; + }else if([state isEqualToString:@"Playing"]){ + { + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + [dict setObject:@"iTunesPause" forKey:@"Type"]; + [dict setObject:@NO forKey:@"isPausing"]; + [self performSelectorOnMainThread:@selector(WorkingThread:) withObject:dict waitUntilDone:YES]; + } + + if (self.iTunesCurrentTrack == [iTunes currentTrack])return; + self.iTunesCurrentTrack = [iTunes currentTrack]; + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + [dict setObject:@"iTunesSongChanged" forKey:@"Type"]; + [self WorkingThread:dict]; } - - - if ((note != nil) && (![[[note userInfo] objectForKey:@"Player State"] isEqualToString:@"Playing"])) { - return; - } - - if (self.iTunesCurrentTrack == [iTunes currentTrack]) return; - self.iTunesCurrentTrack = [iTunes currentTrack]; - - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - [dict setObject:@"iTunesSongChanged" forKey:@"Type"]; - [self WorkingThread:dict]; } } @@ -221,7 +229,8 @@ - (void) WorkingThread:(NSMutableDictionary*)tmpDict //this thread should work in main thread //iTunesPosition or iTunesSongChanged handler @autoreleasepool { - if ([[tmpDict objectForKey:@"Type"] isEqualToString:@"iTunesSongChanged"]) + NSString*type=[tmpDict objectForKey:@"Type"]; + if ([type isEqualToString:@"iTunesSongChanged"]) { //iTunesSongChanged NSLog(@"%@",[iTunesCurrentTrack name]); @@ -260,7 +269,7 @@ - (void) WorkingThread:(NSMutableDictionary*)tmpDict } - else + else if([type isEqualToString:@"iTunesPosition"]) { //iTunesPosition NSString *_currentPlayerPosition = [NSString stringWithString:[tmpDict objectForKey:@"currentPlayerPosition"]]; @@ -316,6 +325,9 @@ - (void) WorkingThread:(NSMutableDictionary*)tmpDict } + }else if([type isEqualToString:@"iTunesPause"]){ + id obj=[tmpDict objectForKey:@"isPausing"]; + [nc postNotificationName:@"iTunesPaused" object:self userInfo:[NSDictionary dictionaryWithObject:obj forKey:@"isPausing"]]; } } } @@ -407,29 +419,28 @@ - (void)iTunesMonitoringThread [[NSApplication sharedApplication] terminate:self]; //exit(0); //现在不通过Helper结束DynamicLyrics了,因为SandBox的缘故,我又懒得弄NSConnection,直接自己退出=。= } - if ([iTunes isRunning] && [iTunes playerState] == iTunesEPlSPlaying) { - if (iTunesVersion >= 1103042001000000) - { - PlayerPosition = [iTunesNEW playerPosition]; + if ([iTunes isRunning]) { + if([iTunes playerState] == iTunesEPlSPlaying){ - } else - { - PlayerPosition = [iTunesOLD playerPosition]; - } - - if ((currentPlayerPosition / 1000) != PlayerPosition && currentPlayerPosition % 1000 < 900) - currentPlayerPosition = PlayerPosition * 1000; - NSMutableDictionary *dict = [NSMutableDictionary dictionary]; - - - [dict setObject:@"iTunesPosition" forKey:@"Type"]; - [dict setObject:[NSString stringWithFormat:@"%lu",currentPlayerPosition] forKey:@"currentPlayerPosition"]; - [self performSelectorOnMainThread:@selector(WorkingThread:) withObject:dict waitUntilDone:YES]; - - } - else { - sleep(1); - } + if (iTunesVersion >= 1103042001000000) + { + PlayerPosition = [iTunesNEW playerPosition]; + + } else + { + PlayerPosition = [iTunesOLD playerPosition]; + } + + if ((currentPlayerPosition / 1000) != PlayerPosition && currentPlayerPosition % 1000 < 900) + currentPlayerPosition = PlayerPosition * 1000; + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + + + [dict setObject:@"iTunesPosition" forKey:@"Type"]; + [dict setObject:[NSString stringWithFormat:@"%lu",currentPlayerPosition] forKey:@"currentPlayerPosition"]; + [self performSelectorOnMainThread:@selector(WorkingThread:) withObject:dict waitUntilDone:YES]; + }else sleep(1); + }else sleep(1); } } } diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index 45d85b4..b1845f2 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -36,6 +36,7 @@ -(id) initWithMenu:(NSMenu *)AppMenu; [_statusItem setMenu:AppMenu]; nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(iTunesLyricsChanged:) name:@NC_LyricsChanged object:nil]; + [nc addObserver:self selector:@selector(iTunesPaused:) name:@"iTunesPaused" object:nil]; NSLog(@"%@",@"MenuBarLyrics"); @@ -104,6 +105,12 @@ -(void) hideSmoothTitle:(NSDictionary *)dict [pool release]; } +-(void)iTunesPaused:(NSNotification*)notification{ + bool pausing=[[[notification userInfo]valueForKey:@"isPausing"]boolValue]; + NSLog(@"%s",pausing?"Paused":"Playing"); + [_statusItem setAttributedTitle:nil]; + [_statusItem setImage:[NSImage imageNamed:@"StatusIcon"]]; +} -(void)iTunesLyricsChanged:(NSNotification *)note { @@ -134,7 +141,9 @@ -(void)iTunesLyricsChanged:(NSNotification *)note [_queue cancelAllOperations]; if ([ud boolForKey:@Pref_Enable_MenuBar_Lyrics] || forceUpdate) { - if ([self.CurrentSongLyrics isEqualToString:@""]) { +// NSString*trimmed=[self.CurrentSongLyrics stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; + NSString*trimmed=self.CurrentSongLyrics; + if ([trimmed isEqualToString:@""]){ [_statusItem setAttributedTitle:nil]; [_statusItem setImage:[NSImage imageNamed:@"StatusIcon"]]; }else{ diff --git a/DynamicLyricsHelper/DynamicLyricsHelper.xcodeproj/project.pbxproj b/DynamicLyricsHelper/DynamicLyricsHelper.xcodeproj/project.pbxproj index 9001634..589bb70 100644 --- a/DynamicLyricsHelper/DynamicLyricsHelper.xcodeproj/project.pbxproj +++ b/DynamicLyricsHelper/DynamicLyricsHelper.xcodeproj/project.pbxproj @@ -252,7 +252,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = DynamicLyricsHelper/DynamicLyricsHelper.entitlements; - CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = c89; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -270,7 +270,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_ENTITLEMENTS = DynamicLyricsHelper/DynamicLyricsHelper.entitlements; - CODE_SIGN_IDENTITY = "Developer ID Application: Zhu Zheng (R5RMP6G3GQ)"; + CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; GCC_C_LANGUAGE_STANDARD = c89; GCC_PRECOMPILE_PREFIX_HEADER = YES; From e919b18a62ba45af8a591fd989a9bd8220770447 Mon Sep 17 00:00:00 2001 From: revintec Date: Sun, 14 Dec 2014 23:14:49 +0800 Subject: [PATCH 2/7] left click toggles DesktopLyrics, right click shows menu --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/LyricsView.m | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.h | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 24 +++++++++++++++++++----- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index daab95d..89d3406 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1345 + 1453 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/LyricsView.m b/DynamicLyrics/LyricX/LyricsView.m index 292cbf8..4d92765 100644 --- a/DynamicLyrics/LyricX/LyricsView.m +++ b/DynamicLyrics/LyricX/LyricsView.m @@ -29,7 +29,7 @@ - (id)initWithFrame:(NSRect)frame self = [super initWithFrame:frame]; if (self) { nc = [NSNotificationCenter defaultCenter]; - [nc addObserver:self selector:@selector(iTunesLyricsChanged:) name:@"LyricsChanged" object:nil]; + [nc addObserver:self selector:@selector(iTunesLyricsChanged:) name:@NC_LyricsChanged object:nil]; rootLayer = [[CALayer layer] retain]; diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.h b/DynamicLyrics/LyricX/MenuBarLyrics.h index d562267..302cab5 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.h +++ b/DynamicLyrics/LyricX/MenuBarLyrics.h @@ -13,10 +13,10 @@ NSNotificationCenter *nc; NSStatusItem *_statusItem; NSOperationQueue *_queue; - } @property(nonatomic, retain) NSString *CurrentSongLyrics; +@property(retain)NSMenu*AppMenu; -(id) initWithMenu:(NSMenu *)AppMenu; diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index b1845f2..edc0a5a 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -7,6 +7,7 @@ // #import "MenuBarLyrics.h" +#import "LyricXAppDelegate.h" #import "Constants.h" @interface NSStatusBar (NSStatusBar_Private) @@ -33,7 +34,10 @@ -(id) initWithMenu:(NSMenu *)AppMenu; [image setTemplate:YES]; [_statusItem setImage:image]; [_statusItem setHighlightMode:YES]; - [_statusItem setMenu:AppMenu]; + self.AppMenu=AppMenu; + [_statusItem setTarget:self]; + [_statusItem setAction:@selector(toggleDesktopLyrics:)]; + [_statusItem sendActionOn:NSLeftMouseUpMask|NSRightMouseUpMask]; nc = [NSNotificationCenter defaultCenter]; [nc addObserver:self selector:@selector(iTunesLyricsChanged:) name:@NC_LyricsChanged object:nil]; [nc addObserver:self selector:@selector(iTunesPaused:) name:@"iTunesPaused" object:nil]; @@ -43,7 +47,20 @@ -(id) initWithMenu:(NSMenu *)AppMenu; } return self; } - +-(void)toggleDesktopLyrics:(id)sender{ + NSEvent*event=[NSApp currentEvent]; + if([event type]!=NSRightMouseUp&&!([event modifierFlags]&NSControlKeyMask)){ + NSUserDefaults*df=[NSUserDefaults standardUserDefaults]; + bool edl=[[df valueForKey:@Pref_Enable_Desktop_Lyrics]boolValue]; + [df setBool:!edl forKey:@Pref_Enable_Desktop_Lyrics]; + // FIXME refreshing problems, response is delayed + // this is main thread, no need for performSelectorOnMainThread + [(AppDelegate*)[NSApp delegate]DisabledDesktopLyrics:self]; + [self showSmoothTitle:@"PleaseWait…"]; + // fuck [NSEvent keyEventWithType:<#(NSEventType)#> location:<#(NSPoint)#> modifierFlags:<#(NSEventModifierFlags)#> timestamp:<#(NSTimeInterval)#> windowNumber:<#(NSInteger)#> context:<#(NSGraphicsContext *)#> characters:<#(NSString *)#> charactersIgnoringModifiers:<#(NSString *)#> isARepeat:<#(BOOL)#> keyCode:<#(unsigned short)#>] + // are apple's engineers all have shit in there brain!? + }else [_statusItem popUpStatusItemMenu:self.AppMenu]; +} -(void) dealloc { self.CurrentSongLyrics = nil; @@ -51,7 +68,6 @@ -(void) dealloc [_statusItem release]; [super dealloc]; } - -(void) showSmoothTitle:(NSString *)title { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; @@ -104,14 +120,12 @@ -(void) hideSmoothTitle:(NSDictionary *)dict [_statusItem setTitle:@""]; [pool release]; } - -(void)iTunesPaused:(NSNotification*)notification{ bool pausing=[[[notification userInfo]valueForKey:@"isPausing"]boolValue]; NSLog(@"%s",pausing?"Paused":"Playing"); [_statusItem setAttributedTitle:nil]; [_statusItem setImage:[NSImage imageNamed:@"StatusIcon"]]; } - -(void)iTunesLyricsChanged:(NSNotification *)note { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; From a9407e8f4d576864808a91a396ade0804ab9d2a2 Mon Sep 17 00:00:00 2001 From: revintec Date: Sun, 14 Dec 2014 23:23:04 +0800 Subject: [PATCH 3/7] shrink to fit the lyrics --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index 89d3406..dc6208d 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1453 + 1456 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index edc0a5a..3c364e7 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -68,11 +68,24 @@ -(void) dealloc [_statusItem release]; [super dealloc]; } +-(bool)isStatusBarWideEnoughToDisplayLyrics{ + // TODO + return true; +} -(void) showSmoothTitle:(NSString *)title { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; CGFloat white = (style && [style isEqualToString:@"Dark"]) ? 1 : 0; + { + NSMutableDictionary *d = [NSMutableDictionary dictionary]; + [d setObject:[NSFont fontWithName: @"Lucida Grande" size: 15] forKey:NSFontAttributeName]; + NSAttributedString *shadowTitle = [[NSAttributedString alloc] initWithString:title attributes:d]; + [_statusItem setAttributedTitle:shadowTitle]; + if(![self isStatusBarWideEnoughToDisplayLyrics]) + title=@"…"; + } + for (float alpha = 0.3; alpha < 1.01; alpha+=0.02) { From 8c51934080bb3e87d23a74501a7dc6060f28a9a3 Mon Sep 17 00:00:00 2001 From: revintec Date: Tue, 16 Dec 2014 13:24:22 +0800 Subject: [PATCH 4/7] nasty workaround to toggle DesktopLyrics --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 38 ++++++++++++++----- DynamicLyrics/LyricX/en.lproj/MainMenu.xib | 12 +++--- .../LyricX/zh-Hans.lproj/MainMenu.xib | 12 +++--- 4 files changed, 42 insertions(+), 22 deletions(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index dc6208d..a583528 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1456 + 1503 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index 3c364e7..d662ad0 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -47,18 +47,38 @@ -(id) initWithMenu:(NSMenu *)AppMenu; } return self; } +-(bool)_toggleDesktopLyrics:(NSMenuItem*)item{ + CGKeyCode key=kVK_ANSI_X;NSString*kx=@"x"; + CGEventRef kd=CGEventCreateKeyboardEvent(nil,key,true); + CGEventRef ku=CGEventCreateKeyboardEvent(nil,key,false); + if(!kd||!ku){ + [_statusItem performSelectorOnMainThread:@selector(setEnabled:) withObject:true waitUntilDone:false]; + if(kd)CFRelease(kd); + if(ku)CFRelease(ku); + return false; + } + NSString*kv=[item keyEquivalent]; + NSUInteger km=[item keyEquivalentModifierMask]; + [item setKeyEquivalent:kx]; + [item setKeyEquivalentModifierMask:0]; + [NSThread sleepForTimeInterval:0.1]; + CGEventTapLocation loc=kCGHIDEventTap; + CGEventPost(loc,kd); + CGEventPost(loc,ku); + [NSThread sleepForTimeInterval:0.1]; + [item setKeyEquivalent:kv]; + [item setKeyEquivalentModifierMask:km]; + CFRelease(kd);CFRelease(ku); + [_statusItem performSelectorOnMainThread:@selector(setEnabled:) withObject:true waitUntilDone:false]; + return true; +} -(void)toggleDesktopLyrics:(id)sender{ NSEvent*event=[NSApp currentEvent]; if([event type]!=NSRightMouseUp&&!([event modifierFlags]&NSControlKeyMask)){ - NSUserDefaults*df=[NSUserDefaults standardUserDefaults]; - bool edl=[[df valueForKey:@Pref_Enable_Desktop_Lyrics]boolValue]; - [df setBool:!edl forKey:@Pref_Enable_Desktop_Lyrics]; - // FIXME refreshing problems, response is delayed - // this is main thread, no need for performSelectorOnMainThread - [(AppDelegate*)[NSApp delegate]DisabledDesktopLyrics:self]; - [self showSmoothTitle:@"PleaseWait…"]; - // fuck [NSEvent keyEventWithType:<#(NSEventType)#> location:<#(NSPoint)#> modifierFlags:<#(NSEventModifierFlags)#> timestamp:<#(NSTimeInterval)#> windowNumber:<#(NSInteger)#> context:<#(NSGraphicsContext *)#> characters:<#(NSString *)#> charactersIgnoringModifiers:<#(NSString *)#> isARepeat:<#(BOOL)#> keyCode:<#(unsigned short)#>] - // are apple's engineers all have shit in there brain!? + [_statusItem setEnabled:false]; + NSMenuItem*item=[self.AppMenu itemWithTag:100]; + [self performSelectorInBackground:@selector(_toggleDesktopLyrics:) withObject:item]; + [_statusItem popUpStatusItemMenu:self.AppMenu]; }else [_statusItem popUpStatusItemMenu:self.AppMenu]; } -(void) dealloc diff --git a/DynamicLyrics/LyricX/en.lproj/MainMenu.xib b/DynamicLyrics/LyricX/en.lproj/MainMenu.xib index 29baee2..de06eaa 100644 --- a/DynamicLyrics/LyricX/en.lproj/MainMenu.xib +++ b/DynamicLyrics/LyricX/en.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - - + + @@ -11,7 +11,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -231,4 +231,4 @@ - \ No newline at end of file + diff --git a/DynamicLyrics/LyricX/zh-Hans.lproj/MainMenu.xib b/DynamicLyrics/LyricX/zh-Hans.lproj/MainMenu.xib index 4f20e0b..70ea85e 100644 --- a/DynamicLyrics/LyricX/zh-Hans.lproj/MainMenu.xib +++ b/DynamicLyrics/LyricX/zh-Hans.lproj/MainMenu.xib @@ -1,8 +1,8 @@ - + - - + + @@ -11,7 +11,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -231,4 +231,4 @@ - \ No newline at end of file + From 939d7e905dc64bab2612e5431f238019a031f8f4 Mon Sep 17 00:00:00 2001 From: revintec Date: Fri, 19 Dec 2014 15:26:11 +0800 Subject: [PATCH 5/7] change MenuBarLyrics default font --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index a583528..5ad7124 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1503 + 1510 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index d662ad0..ae326e1 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -94,12 +94,13 @@ -(bool)isStatusBarWideEnoughToDisplayLyrics{ } -(void) showSmoothTitle:(NSString *)title { + NSString*font=@"Bradley Hand"; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; CGFloat white = (style && [style isEqualToString:@"Dark"]) ? 1 : 0; { NSMutableDictionary *d = [NSMutableDictionary dictionary]; - [d setObject:[NSFont fontWithName: @"Lucida Grande" size: 15] forKey:NSFontAttributeName]; + [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; NSAttributedString *shadowTitle = [[NSAttributedString alloc] initWithString:title attributes:d]; [_statusItem setAttributedTitle:shadowTitle]; if(![self isStatusBarWideEnoughToDisplayLyrics]) @@ -113,7 +114,7 @@ -(void) showSmoothTitle:(NSString *)title NSColor *color = [NSColor colorWithCalibratedWhite:white alpha:alpha]; NSMutableDictionary *d = [NSMutableDictionary dictionary]; [d setObject:color forKey:NSForegroundColorAttributeName]; - [d setObject:[NSFont fontWithName: @"Lucida Grande" size: 15] forKey:NSFontAttributeName]; + [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; NSAttributedString *shadowTitle = [[NSAttributedString alloc] initWithString:title attributes:d]; From 5f9d6b4fdc1fa013325058af1e629b604d98d2d1 Mon Sep 17 00:00:00 2001 From: revintec Date: Sat, 20 Dec 2014 22:57:29 +0800 Subject: [PATCH 6/7] small refactor --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index 5ad7124..f207da5 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1510 + 1525 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index ae326e1..8e9342f 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -95,12 +95,16 @@ -(bool)isStatusBarWideEnoughToDisplayLyrics{ -(void) showSmoothTitle:(NSString *)title { NSString*font=@"Bradley Hand"; +// font=@"Comic Sans MS"; + NSMutableDictionary *d = [NSMutableDictionary dictionary]; + [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; + [d setObject:[NSNumber numberWithInt: 0] forKey:NSBaselineOffsetAttributeName]; + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *style = [[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"]; CGFloat white = (style && [style isEqualToString:@"Dark"]) ? 1 : 0; { - NSMutableDictionary *d = [NSMutableDictionary dictionary]; - [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; NSAttributedString *shadowTitle = [[NSAttributedString alloc] initWithString:title attributes:d]; [_statusItem setAttributedTitle:shadowTitle]; if(![self isStatusBarWideEnoughToDisplayLyrics]) @@ -112,9 +116,7 @@ -(void) showSmoothTitle:(NSString *)title { NSColor *color = [NSColor colorWithCalibratedWhite:white alpha:alpha]; - NSMutableDictionary *d = [NSMutableDictionary dictionary]; [d setObject:color forKey:NSForegroundColorAttributeName]; - [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; NSAttributedString *shadowTitle = [[NSAttributedString alloc] initWithString:title attributes:d]; From c69c8d453f0fbb5c5b66053fc2c0333db61e4d9f Mon Sep 17 00:00:00 2001 From: revintec Date: Sun, 21 Dec 2014 16:18:01 +0800 Subject: [PATCH 7/7] baseline change to 1.0 for "y" in BradleyHand font --- DynamicLyrics/LyricX/LyricX-Info.plist | 2 +- DynamicLyrics/LyricX/MenuBarLyrics.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DynamicLyrics/LyricX/LyricX-Info.plist b/DynamicLyrics/LyricX/LyricX-Info.plist index f207da5..c9e831d 100644 --- a/DynamicLyrics/LyricX/LyricX-Info.plist +++ b/DynamicLyrics/LyricX/LyricX-Info.plist @@ -19,7 +19,7 @@ CFBundleShortVersionString 2.1 CFBundleVersion - 1525 + 1538 LSApplicationCategoryType public.app-category.music LSMinimumSystemVersion diff --git a/DynamicLyrics/LyricX/MenuBarLyrics.m b/DynamicLyrics/LyricX/MenuBarLyrics.m index 8e9342f..a58eb3d 100644 --- a/DynamicLyrics/LyricX/MenuBarLyrics.m +++ b/DynamicLyrics/LyricX/MenuBarLyrics.m @@ -95,10 +95,10 @@ -(bool)isStatusBarWideEnoughToDisplayLyrics{ -(void) showSmoothTitle:(NSString *)title { NSString*font=@"Bradley Hand"; -// font=@"Comic Sans MS"; +// font=@"Jxixinkai"; NSMutableDictionary *d = [NSMutableDictionary dictionary]; [d setObject:[NSFont fontWithName: font size: 15] forKey:NSFontAttributeName]; - [d setObject:[NSNumber numberWithInt: 0] forKey:NSBaselineOffsetAttributeName]; + [d setObject:[NSNumber numberWithInt: 1] forKey:NSBaselineOffsetAttributeName]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];