Re-enable hotkeys and change preferences storage
Change hotkey storage system, hopefully this will fix the stability issues that have been plaguing it for a while now. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
parent
e9df18c067
commit
6036000214
4 changed files with 61 additions and 48 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
#import "Shortcuts.h"
|
||||
#import <MASShortcut/Shortcut.h>
|
||||
#import <MASShortcut/MASDictionaryTransformer.h>
|
||||
|
||||
#import <Sparkle/Sparkle.h>
|
||||
|
||||
|
@ -209,11 +210,11 @@ static BOOL consentLastEnabled = NO;
|
|||
[randomizeButton setToolTip:NSLocalizedString(@"RandomizeButtonTooltip", @"")];
|
||||
[fileButton setToolTip:NSLocalizedString(@"FileButtonTooltip", @"")];
|
||||
|
||||
if(@available(macOS 15, *)) {
|
||||
[self registerDefaultHotKeys];
|
||||
|
||||
[self registerHotKeys];
|
||||
}
|
||||
[self registerDefaultHotKeys];
|
||||
|
||||
[self migrateHotKeys];
|
||||
|
||||
[self registerHotKeys];
|
||||
|
||||
(void)[spotlightWindowController init];
|
||||
|
||||
|
@ -760,23 +761,24 @@ static NSDictionary *shortcutDefaults = nil;
|
|||
MASShortcut *seekFwdShortcut = [MASShortcut shortcutWithKeyCode:kVK_RightArrow
|
||||
modifierFlags:NSEventModifierFlagControl | NSEventModifierFlagCommand];
|
||||
|
||||
NSData *playShortcutData = [NSKeyedArchiver archivedDataWithRootObject:playShortcut];
|
||||
NSData *nextShortcutData = [NSKeyedArchiver archivedDataWithRootObject:nextShortcut];
|
||||
NSData *prevShortcutData = [NSKeyedArchiver archivedDataWithRootObject:prevShortcut];
|
||||
NSData *spamShortcutData = [NSKeyedArchiver archivedDataWithRootObject:spamShortcut];
|
||||
NSData *fadeShortcutData = [NSKeyedArchiver archivedDataWithRootObject:fadeShortcut];
|
||||
NSData *seekBkwdShortcutData = [NSKeyedArchiver archivedDataWithRootObject:seekBkwdShortcut];
|
||||
NSData *seekFwdShortcutData = [NSKeyedArchiver archivedDataWithRootObject:seekFwdShortcut];
|
||||
MASDictionaryTransformer *transformer = [MASDictionaryTransformer new];
|
||||
NSDictionary *playShortcutDict = [transformer reverseTransformedValue:playShortcut];
|
||||
NSDictionary *nextShortcutDict = [transformer reverseTransformedValue:nextShortcut];
|
||||
NSDictionary *prevShortcutDict = [transformer reverseTransformedValue:prevShortcut];
|
||||
NSDictionary *spamShortcutDict = [transformer reverseTransformedValue:spamShortcut];
|
||||
NSDictionary *fadeShortcutDict = [transformer reverseTransformedValue:fadeShortcut];
|
||||
NSDictionary *seekBkwdShortcutDict = [transformer reverseTransformedValue:seekBkwdShortcut];
|
||||
NSDictionary *seekFwdShortcutDict = [transformer reverseTransformedValue:seekFwdShortcut];
|
||||
|
||||
// Register default values to be used for the first app start
|
||||
NSDictionary<NSString *, NSData *> *defaultShortcuts = @{
|
||||
CogPlayShortcutKey: playShortcutData,
|
||||
CogNextShortcutKey: nextShortcutData,
|
||||
CogPrevShortcutKey: prevShortcutData,
|
||||
CogSpamShortcutKey: spamShortcutData,
|
||||
CogFadeShortcutKey: fadeShortcutData,
|
||||
CogSeekBackwardShortcutKey: seekBkwdShortcutData,
|
||||
CogSeekForwardShortcutKey: seekFwdShortcutData
|
||||
NSDictionary<NSString *, NSDictionary *> *defaultShortcuts = @{
|
||||
CogPlayShortcutKey: playShortcutDict,
|
||||
CogNextShortcutKey: nextShortcutDict,
|
||||
CogPrevShortcutKey: prevShortcutDict,
|
||||
CogSpamShortcutKey: spamShortcutDict,
|
||||
CogFadeShortcutKey: fadeShortcutDict,
|
||||
CogSeekBackwardShortcutKey: seekBkwdShortcutDict,
|
||||
CogSeekForwardShortcutKey: seekFwdShortcutDict
|
||||
};
|
||||
|
||||
shortcutDefaults = defaultShortcuts;
|
||||
|
@ -790,6 +792,20 @@ static NSDictionary *shortcutDefaults = nil;
|
|||
}];
|
||||
}
|
||||
|
||||
- (void)migrateHotKeys {
|
||||
NSArray *inKeys = @[CogPlayShortcutKeyV1, CogNextShortcutKeyV1, CogPrevShortcutKeyV1, CogSpamShortcutKeyV1, CogFadeShortcutKeyV1, CogSeekBackwardShortcutKeyV1, CogSeekForwardShortcutKeyV1];
|
||||
NSArray *outKeys = @[CogPlayShortcutKey, CogNextShortcutKey, CogPrevShortcutKey, CogSpamShortcutKey, CogFadeShortcutKey, CogSeekBackwardShortcutKey, CogSeekForwardShortcutKey];
|
||||
for(size_t i = 0, j = [inKeys count]; i < j; ++i) {
|
||||
NSString *inKey = inKeys[i];
|
||||
NSString *outKey = outKeys[i];
|
||||
id value = [[NSUserDefaults standardUserDefaults] objectForKey:inKey];
|
||||
if(value && value != [NSNull null]) {
|
||||
[[NSUserDefaults standardUserDefaults] setObject:value forKey:outKey];
|
||||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:inKey];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerHotKeys {
|
||||
MASShortcutBinder *binder = [MASShortcutBinder sharedBinder];
|
||||
[binder bindShortcutWithDefaultsKey:CogPlayShortcutKey
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit a7d42071344fb63c3dcee1dc7d468a089600d4e5
|
||||
Subproject commit c4a91c10e47310dba71782c46577e31117d0b6ef
|
|
@ -41,26 +41,15 @@
|
|||
[[NSBundle bundleWithIdentifier:@"org.cogx.cog.preferences"] loadNibNamed:@"Preferences"
|
||||
owner:plugin
|
||||
topLevelObjects:nil];
|
||||
if(@available(macOS 15, *)) {
|
||||
return @[[plugin playlistPane],
|
||||
[plugin hotKeyPane],
|
||||
[plugin updatesPane],
|
||||
[plugin outputPane],
|
||||
[plugin generalPane],
|
||||
[plugin notificationsPane],
|
||||
[plugin appearancePane],
|
||||
[plugin midiPane],
|
||||
[plugin rubberbandPane]];
|
||||
} else {
|
||||
return @[[plugin playlistPane],
|
||||
[plugin updatesPane],
|
||||
[plugin outputPane],
|
||||
[plugin generalPane],
|
||||
[plugin notificationsPane],
|
||||
[plugin appearancePane],
|
||||
[plugin midiPane],
|
||||
[plugin rubberbandPane]];
|
||||
}
|
||||
return @[[plugin playlistPane],
|
||||
[plugin hotKeyPane],
|
||||
[plugin updatesPane],
|
||||
[plugin outputPane],
|
||||
[plugin generalPane],
|
||||
[plugin notificationsPane],
|
||||
[plugin appearancePane],
|
||||
[plugin midiPane],
|
||||
[plugin rubberbandPane]];
|
||||
}
|
||||
|
||||
- (HotKeyPane *)hotKeyPane {
|
||||
|
|
|
@ -5,10 +5,18 @@
|
|||
// Created by Dzmitry Neviadomski on 25.01.21.
|
||||
//
|
||||
|
||||
static NSString *const CogPlayShortcutKey = @"cogPlayShortcut";
|
||||
static NSString *const CogNextShortcutKey = @"cogNextShortcut";
|
||||
static NSString *const CogPrevShortcutKey = @"cogPrevShortcut";
|
||||
static NSString *const CogSpamShortcutKey = @"cogSpamShortcut";
|
||||
static NSString *const CogFadeShortcutKey = @"cogFadeShortcut";
|
||||
static NSString *const CogSeekBackwardShortcutKey = @"cogSeekBackwardShortcut";
|
||||
static NSString *const CogSeekForwardShortcutKey = @"cogSeekForwardShortcut";
|
||||
static NSString *const CogPlayShortcutKey = @"cogPlayShortcutV2";
|
||||
static NSString *const CogNextShortcutKey = @"cogNextShortcutV2";
|
||||
static NSString *const CogPrevShortcutKey = @"cogPrevShortcutV2";
|
||||
static NSString *const CogSpamShortcutKey = @"cogSpamShortcutV2";
|
||||
static NSString *const CogFadeShortcutKey = @"cogFadeShortcutV2";
|
||||
static NSString *const CogSeekBackwardShortcutKey = @"cogSeekBackwardShortcutV2";
|
||||
static NSString *const CogSeekForwardShortcutKey = @"cogSeekForwardShortcutV2";
|
||||
|
||||
static NSString *const CogPlayShortcutKeyV1 = @"cogPlayShortcut";
|
||||
static NSString *const CogNextShortcutKeyV1 = @"cogNextShortcut";
|
||||
static NSString *const CogPrevShortcutKeyV1 = @"cogPrevShortcut";
|
||||
static NSString *const CogSpamShortcutKeyV1 = @"cogSpamShortcut";
|
||||
static NSString *const CogFadeShortcutKeyV1 = @"cogFadeShortcut";
|
||||
static NSString *const CogSeekBackwardShortcutKeyV1 = @"cogSeekBackwardShortcut";
|
||||
static NSString *const CogSeekForwardShortcutKeyV1 = @"cogSeekForwardShortcut";
|
||||
|
|
Loading…
Reference in a new issue