Skip to content

Commit

Permalink
fix: Adapt Keybindings For Platform + Fix macOS Bundle
Browse files Browse the repository at this point in the history
* Keybindings should not match the platform.
  Resolves #26.
* Fixing macOS bundle.
  • Loading branch information
vkhitrin committed Dec 29, 2024
1 parent 5bab72c commit 2daf066
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 41 deletions.
69 changes: 34 additions & 35 deletions res/macOS/cosmicding.app/Contents/Info.plist
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>cosmicding</string>
<key>CFBundleIdentifier</key>
<string>com.vkhitrin.cosmicding</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>cosmicding</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>{{ VERSION }}</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>{{ BUILD }}</string>
<key>CFBundleIconFile</key>
<string>cosmicding.icns</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMainNibFile</key>
<string></string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>CFBundleDisplayName</key>
<string>cosmicding</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
<key>CFBundleURLTypes</key>
</dict>
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>cosmicding</string>
<key>CFBundleIdentifier</key>
<string>com.vkhitrin.cosmicding</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>cosmicding</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>__VERSION__</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>__BUILD__</string>
<key>CFBundleIconFile</key>
<string>AppIcon.icns</string>
<key>NSHighResolutionCapable</key>
<true />
<key>NSMainNibFile</key>
<string></string>
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true />
<key>CFBundleDisplayName</key>
<string>cosmicding</string>
<key>NSRequiresAquaSystemAppearance</key>
<string>NO</string>
</dict>
</plist>
28 changes: 22 additions & 6 deletions src/key_binds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,35 @@ pub fn key_binds() -> HashMap<KeyBind, MenuAction> {
([$($modifier:ident),* $(,)?], $key:expr, $action:ident) => {{
key_binds.insert(
KeyBind {
modifiers: vec![$(Modifier::$modifier),*],
modifiers: vec![$($modifier),*],
key: $key,
},
MenuAction::$action,
);
}};
}

bind!([Ctrl], Key::Character(",".into()), Settings);
bind!([Ctrl], Key::Character("i".into()), About);
bind!([Ctrl, Shift], Key::Character("n".into()), AddAccount);
bind!([Ctrl], Key::Character("n".into()), AddBookmark);
bind!([Ctrl], Key::Character("r".into()), RefreshBookmarks);
let primary_modifier = if cfg!(target_os = "macos") {
Modifier::Super // Use Cmd (Command) on macOS
} else {
Modifier::Ctrl // Default to Ctrl for other platforms (could be adjusted as needed)
};

let secondary_modifier = Modifier::Shift;

bind!([primary_modifier], Key::Character(",".into()), Settings);
bind!([primary_modifier], Key::Character("i".into()), About);
bind!(
[primary_modifier, secondary_modifier],
Key::Character("n".into()),
AddAccount
);
bind!([primary_modifier], Key::Character("n".into()), AddBookmark);
bind!(
[primary_modifier],
Key::Character("r".into()),
RefreshBookmarks
);

key_binds
}

0 comments on commit 2daf066

Please sign in to comment.