Add fade global shortcut

Defaulting to ctrl-cmd-O, though I may change this if
someone has any better ideas for a default.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2023-06-30 22:13:44 -07:00
parent 0fb28001f9
commit 0efc3d4ad7
No known key found for this signature in database
9 changed files with 57 additions and 13 deletions

View file

@ -658,6 +658,11 @@ static AppController *kAppController = nil;
toAction:^{
[self clickSpam];
}];
[binder bindShortcutWithDefaultsKey:CogFadeShortcutKey
toAction:^{
[self clickFade];
}];
}
- (void)clickPlay {
@ -684,6 +689,10 @@ static AppController *kAppController = nil;
[playbackController spam:nil];
}
- (void)clickFade {
[playbackController fade:nil];
}
- (void)clickSeek:(NSTimeInterval)position {
[playbackController seek:self toTime:position];
}

View file

@ -133,6 +133,7 @@
</customView>
<customObject id="6" userLabel="HotKeyPane" customClass="HotKeyPane">
<connections>
<outlet property="fadeShortcutView" destination="vEd-Af-7tR" id="DMK-Z9-Sm5"/>
<outlet property="nextShortcutView" destination="Dse-4d-oBd" id="mYF-gy-OEU"/>
<outlet property="playShortcutView" destination="OBW-Zy-nz0" id="OkD-1k-vay"/>
<outlet property="prevShortcutView" destination="Ujw-ux-fCg" id="oOW-gF-QBo"/>
@ -141,7 +142,7 @@
</connections>
</customObject>
<customView id="11" userLabel="HotKeyView">
<rect key="frame" x="0.0" y="0.0" width="640" height="132"/>
<rect key="frame" x="0.0" y="0.0" width="640" height="163"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="YtT-gE-hX3">
@ -156,7 +157,7 @@
</connections>
</button>
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="24">
<rect key="frame" x="18" y="103" width="145" height="17"/>
<rect key="frame" x="34" y="134" width="145" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Play:" id="198">
<font key="font" metaFont="system"/>
@ -165,7 +166,7 @@
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="25">
<rect key="frame" x="18" y="72" width="145" height="17"/>
<rect key="frame" x="34" y="103" width="145" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Previous:" id="199">
<font key="font" metaFont="system"/>
@ -174,7 +175,7 @@
</textFieldCell>
</textField>
<textField focusRingType="none" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="26">
<rect key="frame" x="18" y="42" width="145" height="17"/>
<rect key="frame" x="4" y="73" width="175" height="17"/>
<autoresizingMask key="autoresizingMask"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="right" title="Next:" id="200">
<font key="font" metaFont="system"/>
@ -183,7 +184,7 @@
</textFieldCell>
</textField>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="eid-M4-6Cs">
<rect key="frame" x="18" y="11" width="145" height="17"/>
<rect key="frame" x="4" y="14" width="175" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Copy now playing:" id="SMd-GA-jrH">
<font key="font" metaFont="system"/>
@ -192,23 +193,36 @@
</textFieldCell>
</textField>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="OBW-Zy-nz0" userLabel="Play Shortcut" customClass="MASShortcutView">
<rect key="frame" x="169" y="102" width="163" height="19"/>
<rect key="frame" x="185" y="133" width="163" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ujw-ux-fCg" userLabel="Previous Shortcut" customClass="MASShortcutView">
<rect key="frame" x="169" y="71" width="163" height="19"/>
<rect key="frame" x="185" y="102" width="163" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Dse-4d-oBd" userLabel="Next Shortcut" customClass="MASShortcutView">
<rect key="frame" x="169" y="41" width="163" height="19"/>
<rect key="frame" x="185" y="72" width="163" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="80X-iX-vxp" userLabel="Spam Shortcut" customClass="MASShortcutView">
<rect key="frame" x="169" y="10" width="163" height="19"/>
<rect key="frame" x="185" y="13" width="163" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" allowsCharacterPickerTouchBarItem="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Gp4-rA-1UF">
<rect key="frame" x="4" y="44" width="175" height="17"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="Fade in/out:" id="D5K-pO-8Sj">
<font key="font" metaFont="system"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="vEd-Af-7tR" userLabel="Fade Shortcut" customClass="MASShortcutView">
<rect key="frame" x="185" y="43" width="163" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</customView>
</subviews>
<point key="canvasLocation" x="-151" y="-34"/>
<point key="canvasLocation" x="-151" y="-18.5"/>
</customView>
<userDefaultsController representsSharedInstance="YES" id="52" userLabel="Shared Defaults"/>
<customObject id="57" userLabel="OutputPane" customClass="OutputPane">
@ -418,7 +432,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="EEt-uJ-j6o">
<rect key="frame" x="8" y="0.0" width="443" height="24"/>
<rect key="frame" x="18" y="0.0" width="443" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7l9-R2-FVF">
@ -453,7 +467,7 @@
<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
<prototypeCellViews>
<tableCellView id="EDi-gi-Vg9">
<rect key="frame" x="468" y="0.0" width="100" height="24"/>
<rect key="frame" x="478" y="0.0" width="100" height="24"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0TJ-dK-Rfk">

View file

@ -16,6 +16,7 @@
@property(strong) IBOutlet MASShortcutView *nextShortcutView;
@property(strong) IBOutlet MASShortcutView *prevShortcutView;
@property(strong) IBOutlet MASShortcutView *spamShortcutView;
@property(strong) IBOutlet MASShortcutView *fadeShortcutView;
- (IBAction)resetToDefaultShortcuts:(id)sender;

View file

@ -48,18 +48,24 @@ MASShortcut *shortcutWithMigration(NSString *oldKeyCodePrefName,
@"hotKeySpamModifiers",
CogSpamShortcutKey,
kVK_ANSI_C);
MASShortcut *fadeShortcut = shortcutWithMigration(@"hotKeyFadeKeyCode",
@"hotKeyFadeModifiers",
CogFadeShortcutKey,
kVK_ANSI_O);
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];
// Register default values to be used for the first app start
NSDictionary<NSString *, NSData *> *defaultShortcuts = @{
CogPlayShortcutKey: playShortcutData,
CogNextShortcutKey: nextShortcutData,
CogPrevShortcutKey: prevShortcutData,
CogSpamShortcutKey: spamShortcutData
CogSpamShortcutKey: spamShortcutData,
CogFadeShortcutKey: fadeShortcutData
};
defaultsController =
@ -70,6 +76,7 @@ MASShortcut *shortcutWithMigration(NSString *oldKeyCodePrefName,
_nextShortcutView.associatedUserDefaultsKey = CogNextShortcutKey;
_prevShortcutView.associatedUserDefaultsKey = CogPrevShortcutKey;
_spamShortcutView.associatedUserDefaultsKey = CogSpamShortcutKey;
_fadeShortcutView.associatedUserDefaultsKey = CogFadeShortcutKey;
}
- (NSString *)title {

View file

@ -238,3 +238,6 @@
/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */
"ws4-en-un8.title" = "Add other files in the same folder when adding a file";
/* Class = "NSTextFieldCell"; title = "Fade in/out:"; ObjectID = "Gp4-rA-1UF"; */
"Gp4-rA-1UF.title" = "Fade in/out:";

View file

@ -237,3 +237,6 @@
/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */
"ws4-en-un8.title" = "Añadir otros archivos en la misma carpeta al añadir un archivo";
/* Class = "NSTextFieldCell"; title = "Fade in/out:"; ObjectID = "Gp4-rA-1UF"; */
"Gp4-rA-1UF.title" = "Fundido:";

View file

@ -199,3 +199,6 @@
/* Class = "NSButtonCell"; title = "Add other files in the same folder when adding a file"; ObjectID = "ws4-en-un8"; */
"ws4-en-un8.title" = "Add other files in the same folder when adding a file";
/* Class = "NSTextFieldCell"; title = "Fade in/out:"; ObjectID = "Gp4-rA-1UF"; */
"Gp4-rA-1UF.title" = "Fade in/out:";

View file

@ -238,3 +238,6 @@
/* Class = "NSTextFieldCell"; title = "hh:mm:ss.ms"; ObjectID = "zaI-0m-tQf"; */
"zaI-0m-tQf.title" = "ss:dd:ss.ms";
/* Class = "NSTextFieldCell"; title = "Fade in/out:"; ObjectID = "Gp4-rA-1UF"; */
"Gp4-rA-1UF.title" = "Fade in/out:";

View file

@ -9,3 +9,4 @@ 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";